Skip to content

319 - Release dataverse-client-javascript version 2.0.0 #320

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## What did you expect to happen?

## Which version of js-dataverse are you using?
## Which version of dataverse-client-javascript are you using?

## Any related open or closed issues to this bug report?

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

## What existing behavior do you want changed?

## Any brand new behavior do you want to add to js-dataverse?
## Any brand new behavior do you want to add to dataverse-client-javascript?

## Any open or closed issues related to this feature request?
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to js-dataverse
# Contributing to dataverse-client-javascript

First of all thank you very much for your interest in contributing to this project!

Expand Down
54 changes: 46 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
# js-dataverse
## Dataverse JavaScript Client

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

A JavaScript/TypeScript API wrapper for [Dataverse](http://guides.dataverse.org/en/latest/api/).
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.

- [Installation](./docs/installation.md)
- [Use Cases](./docs/useCases.md)
- [Local Development](./docs/localDevelopment.md)
- [Contributing](./CONTRIBUTING.md)
- [License](./LICENSE)
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.

## Features

- **Use case-centric API functions** – Organized around domain-specific actions like `getDataset`, `createCollection`, or `restrictFile`.
- **TypeScript-first** – All use cases include strong typings for inputs and outputs, improving developer experience.

## Installation

Install the package via npm:

```bash
npm install @iqss/dataverse-client-javascript
```

## Usage

```typescript
import { getDataset } from '@iqss/dataverse-client-javascript'

/* ... */

const datasetIdentifier = 'doi:10.77777/FK2/AAAAAA'
const datasetVersion = '1.0'

getDataset.execute(datasetIdentifier, datasetVersion).then((dataset: Dataset) => {
/* ... */
})

/* ... */
```

For detailed information about available use cases see [Use Cases Docs](https://github.com/IQSS/dataverse-client-javascript/blob/main/docs/useCases.md).

For detailed information about usage see [Usage Docs](https://github.com/IQSS/dataverse-client-javascript/blob/main/docs/usage.md).

## Contributing

Want to add a new use case or improve an existing one? Please check the [Contributing](https://github.com/IQSS/dataverse-client-javascript/blob/main/CONTRIBUTING.md) section.

## License

This project is open source and available under the [MIT License](https://github.com/IQSS/dataverse-client-javascript/blob/main/LICENSE).
124 changes: 0 additions & 124 deletions docs/installation.md

This file was deleted.

18 changes: 18 additions & 0 deletions docs/localDevelopment.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,21 @@ Fix linting checks on the code:
```bash
npm run lint:fix
```

## Development Versions of this package

Two different versions are being pushed to the GitHub Packages registry:

1. **PR-Generated Versions**:

- These versions are generated from pull request commits.
- 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.
- These versions are unstable and correspond to the state of the package during the pull request.

2. **Develop Alpha Versions**:
- These versions are generated on every commit made to the `develop` branch, ideally after each pull request is merged.
- They follow the structure `2.1.0-alpha.<number>`, where `number` is an incremental value that starts at 1 and increases with each build.
- These versions are also unstable and represent the latest work in progress on the `develop` branch.

These versions are great for developing a new SPA frontend feature integration.
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.
45 changes: 45 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Initialization

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.

Currently, the supported authentication mechanisms are:

- **API Key**: The recommended authentication mechanism. The API Key should correspond to a particular Dataverse user account.

- **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.

- **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.

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.

For example, in a React application, we can globally initialize the `ApiConfig` object in the `App` file, like this:

```typescript
ApiConfig.init(<DATAVERSE_API_BASE_URL>, DataverseApiAuthMechanism.API_KEY, <DATAVERSE_API_KEY>)

function App() {
/* Yor App code */
}

export default App
```

The same example but with example values set:

```typescript
ApiConfig.init(
'http://localhost:8000/api/v1',
DataverseApiAuthMechanism.API_KEY,
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
)

function App() {
/* Yor App code */
}

export default App
```

We can initialize the `ApiConfig` object as an unauthenticated user, by setting `undefined` as the API Key value.

This will allow use cases that do not require authentication to be successfully executed, but those that do require authentication will fail.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "js-dataverse",
"name": "@iqss/dataverse-client-javascript",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Based on some conversations especially with @GPortas early on, captured in a couple docs and possibly elsewhere, I thought the plan was:

Now it's looking like the plan is:

Is that right?

"version": "2.0.0",
"description": "Dataverse API wrapper package for JavaScript/TypeScript-based applications",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/core/infra/repositories/apiConfigBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const buildRequestConfig = (
/*
We set { withCredentials: true } to send the JSESSIONID cookie in the requests for API authentication.
This is required, along with the session auth feature flag enabled in the backend, to be able to authenticate using the JSESSIONID cookie.
Auth mechanisms like this are configurable to set the one that fits the particular use case of js-dataverse. (For the SPA MVP, it is the session cookie API auth).
Auth mechanisms like this are configurable to set the one that fits the particular use case of dataverse-client-javascript. (For the SPA MVP, it is the session cookie API auth).
*/
requestConfig.withCredentials = true
break
Expand Down