Skip to content
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

39 - Module restructuring and rearchitecture #55

Merged
merged 31 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b28e6c7
Changed: updated dependencies and old package files moved to temporal…
GPortas Mar 31, 2023
bc7a9da
Changed: package.json description
GPortas Mar 31, 2023
30ef551
Removed: unused tsfmt.json file
GPortas Mar 31, 2023
9f0d125
Added: domain use case logic with initial sample use case
GPortas Apr 2, 2023
fb606d0
Added: use case error handling with unit tests and WIP of the reposit…
GPortas Apr 3, 2023
b68e650
Added: DataverseInfoRepository tests
GPortas Apr 4, 2023
49bd7ae
Added: missing '^' prefix to package.json versions
GPortas Apr 4, 2023
80568b5
Added: parametrized API URL for repository impl
GPortas Apr 4, 2023
68a9067
Added: specific test type scripts (test:unit and test:integration)
GPortas Apr 4, 2023
7157fd4
Refactor: test response extracted to variable
GPortas Apr 4, 2023
4ce6c3e
Added: index.ts for 'info' module exports
GPortas Apr 5, 2023
b94975b
Added: package modules initialization
GPortas Apr 5, 2023
ad254f0
Removed: old package code
GPortas Apr 5, 2023
07f2789
Removed: unnecessary packages
GPortas Apr 6, 2023
d72a3cd
Changed: updated README
GPortas Apr 6, 2023
ecac253
Removed: old test path ignore from jest configs
GPortas Apr 6, 2023
36ccce7
Changed: issue and PR templates
GPortas Apr 10, 2023
ebf7f7e
Added: src index.ts
GPortas Apr 10, 2023
c92ea12
Removed: old docs
GPortas Apr 10, 2023
25ada70
Fixed: missing package.json dependencies added
GPortas Apr 10, 2023
58d9d38
Refactor: removed result model and handling errors with exceptions on…
GPortas Apr 10, 2023
72ca474
Added: DataverseVersion model to include both version and build numbers
GPortas Apr 10, 2023
ba18a0a
Changed: README for using only npm and showing node version
GPortas Apr 12, 2023
605f74e
Changed: issue templates format
GPortas Apr 12, 2023
e0ae1ef
Changed: README to better specify deps installation
GPortas Apr 12, 2023
d18dc9b
Refactor: using private readonly in constructor
GPortas Apr 13, 2023
05791e5
Refactor: axios path sequental reading
GPortas Apr 13, 2023
1b2412f
Refactor: removed unnecessary variable
GPortas Apr 13, 2023
ef8d69b
Refactor: string concat in ReadError
GPortas Apr 14, 2023
892ece2
Changed: package-lock
GPortas Apr 14, 2023
8661503
improve README.md and CONTRIBUTING.md #39
pdurbin Apr 19, 2023
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
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended"
]
}
51 changes: 0 additions & 51 deletions .eslintrc.js

This file was deleted.

23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## What steps does it take to reproduce the issue?

## When does this issue occur?

## What happens?

## What did you expect to happen?

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

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

## Screenshots:

No matter the issue, screenshots are always welcome.

To add a screenshot, please use one of the following formats and/or methods described here:

- https://help.github.com/en/articles/file-attachments-on-issues-and-pull-requests
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Overview of the feature request

## What inspired the request?

## What existing behavior do you want changed?

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

## Any open or closed issues related to this feature request?
22 changes: 7 additions & 15 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
## Description
<Description of the pull request>
## What this PR does / why we need it:

## Changes
<A list of the changes that have been made>
## Which issue(s) this PR closes:

## Tests
<A brief description of how the functionality has been tested>
- Closes #

## Checklist
[] The project builds
[] The project passes lint checks
[] The project passes format checks
[] The project passes unit tests
[] I've manually tested the functionality
## Special notes for your reviewer:

## Screenshots
<Screenshots of new functionality if available>
## Suggestions on how to test this:

## Additional information
## Is there a release notes update needed for this change?:

## Additional documentation:
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}
17 changes: 11 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Contributing to js-dataverse

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

## Getting started
1. Make sure that you have installed the project dependencies
2. Build the project `yarn build`
2. Build the project as explained in [README.md](README.md)
3. Fork the repository
4. Apply changes in your own branch
5. Create a Pull Request that we will review
5. Create a pull request that we will review
6. Update README.md if necessary

## Checklist before creating PR
Expand All @@ -17,12 +17,17 @@ First of all thank you very much for your interest in contributing to this proje
- Unit tests for new functionality/fix are added

## Code of Conduct
### GIT
We abide by the upstream Code of Conduct at https://github.com/IQSS/dataverse/blob/develop/CODE_OF_CONDUCT.md and in addition ask the following.

### Git
- Branch names are self descriptive
- Commit messages are short and concise
- Branch is put up to date before creating PR

### Our Responsibilities
### Our responsibilities
- To keep the code clean
- To provide constructive feedback to other developers
- To maintain readable code at all times
- To maintain readable code at all times

## Getting help
Please feel free to reach out in https://chat.dataverse.org or https://groups.google.com/g/dataverse-dev
104 changes: 30 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,62 @@
# dataverse-client-javascript

[![npm](https://img.shields.io/npm/v/js-dataverse.svg)](https://www.npmjs.com/package/js-dataverse)

A JavaScript/TypeScript client for [Dataverse](http://guides.dataverse.org/en/latest/api/).
A JavaScript/TypeScript API wrapper for [Dataverse](http://guides.dataverse.org/en/latest/api/).

## NPM
Module available as `js-dataverse` at https://www.npmjs.com/package/js-dataverse

## Usage
Create a new client:
```
const client = new DataverseClient('https://demo.dataverse.org/')
```

Request dataset information:
```
const response = await client.getDataverseInformation('myDataverseAlias')
```

## Current available functions
`public async getDataverseInformation(alias: string): Promise<AxiosResponse> {`

`public async listDatasets(alias: string): Promise<AxiosResponse> {`

`public async addDataset(dataverseAlias: string, payload: string): Promise<AxiosResponse> {`

`public async addBasicDataset(dataverseAlias: string, datasetInformation: BasicDatasetInformation): Promise<AxiosResponse> {`

`public async search(options: SearchOptions): Promise<AxiosResponse> {`

`public async searchOnlyPublished(options: SearchOptions): Promise<AxiosResponse> {`

`public async getFile(fileId: string): Promise<AxiosResponse> {`

`public async getFileMetadata(fileId: string, draftVersion: boolean = false): Promise<AxiosResponse> {`

`public async getLatestDatasetInformation(datasetId: string): Promise<AxiosResponse> {`

`public async getLatestPublishedDatasetVersion(datasetId: string): Promise<AxiosResponse> {`

`public async getDraftDatasetVersion(datasetId: string): Promise<AxiosResponse> {`

`public async getLatestDatasetInformationFromDOI(doi: string): Promise<AxiosResponse> {`

`public async getDatasetVersions(datasetId: string): Promise<AxiosResponse> {`

```
public async getDatasetVersion(datasetId: string, version: string): Promise<AxiosResponse> {

Note: Version must be published, e.g.:
http://demo.dataverse.org/api/datasets/389608/versions/1
```
Module available as `js-dataverse` at https://www.npmjs.com/package/js-dataverse

`public async listDataverseRoleAssignments(dataverseAlias: string): Promise<AxiosResponse> {`
## Getting Started

`public async getMetric(datasetId: string, metricType: DataverseMetricType, yearMonth?: string): Promise<AxiosResponse> {`
This package is built using `node v19`, so it is recommended to use that version.

`public async getMetricByCountry(datasetId: string, metricType: DataverseMetricType, countryCode?: string, yearMonth?: string) {`
Make sure that you install all the project dependencies:

pdurbin marked this conversation as resolved.
Show resolved Hide resolved
`public async replaceFile(fileId: string, filename: string, fileBuffer: Buffer, jsonData: object = {}): Promise<any> {`
`npm install`

`public async publishDataset(datasetId: string, versionUpgradeType: DatasetVersionUpgradeType = DatasetVersionUpgradeType.MAJOR): Promise<AxiosResponse> {`
## Build project

`public async updateDataset(datasetId: string, datasetInformation: BasicDatasetInformation): Promise<AxiosResponse> {`
In order to build the project, we need to run the following command:

`public async deleteDataset(datasetId: string): Promise<AxiosResponse> {`
`npm run build`

`public async getDatasetFiles(datasetId: string): Promise<AxiosResponse> {`
the build generated will be placed in `dist` folder.

## Build project
## Tests

In order to build the project, we need to run the following command:
### Run all tests

`yarn build` or `npm run build`
`npm run test`

the build generated will be placed in `dist` folder.
### Run unit tests

## Tests and checks
`npm run test:unit`

### Pre-requisites
Make sure that you install all the project dependencies
### Run integration tests

`yarn install` or `npm install`
`npm run test:integration`

Keep consistent, whether you use yarn or npm
### Run test coverage

### Running tests in CICD pipeline
`npm run test:coverage`

`yarn test:ci` or `npm run test:ci`
## Format and lint

### Test coverage
### Run formatter

`yarn test:coverage` or `npm run test:coverage`
`npm run format`

### Format checks
Making sure that the code format is following the guidelines
### Run linter

`yarn format:check` or `npm run format:check`
Running a linting check on the code:

### Lint checks
Running a linting check on the code
`npm run lint`

`yarn eslint:check` or `npm run eslint:check`
Fix linting checks on the code:

`npm run lint:fix`

## Publishing new version

Expand All @@ -114,4 +69,5 @@ Automated publishing of versions could be automated when merging to master. Belo
5. Publish, `npm publish`

## Contributing
[If you are interested in contributing, please click here](/CONTRIBUTING.md)

We love contributors! Please see [CONTRIBUTING.md](CONTRIBUTING.md).
Loading