Skip to content

Commit

Permalink
Merge pull request #23 from Gateway-DAO/feat/remaining-stuff
Browse files Browse the repository at this point in the history
chore: added CONTRIBUTING, CODE_BASE_OVERVIEW docs
  • Loading branch information
Siddharth9890 authored Jan 19, 2024
2 parents 8e53510 + 65692c0 commit 03d3613
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ test/*
__mocks__/*
lib/*
custom-fetch.js
coverage/*
coverage/*
dist/*
28 changes: 28 additions & 0 deletions CODE_BASE_OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Code Base Overview

This section will give you an overview of the SDK codebase. We will also discuss in short the tools we use and the implementation.

* If you want to contribute to the SDK make sure you read this document and the [Contributing Guildelines](https://github.com/Gateway-DAO/javascript-sdk/blob/main/CONTRIBUTING.md) before proceeding.

### Graphql Mesh
* We are using graphql mesh which generates a complete type-safe SDK using our graphql Schema.
* Using this tool we are able to auto generate all of queries and mutations and also providing autocomplete feature for developing applications.

### Top Level Folder Structure
* The src folder has all the classes which a developer will use. The following are the classes which we are using:-
1) Auth Class:- Handles all Authentication related methods.
2) Data Model:- Handles all Data Models related methods.
3) Data Request Templates:- Handles all Data Request Template related methods.
4) Organization:- Handles all Organization related methods.
5) PDA:- Handles all PDA related methods.
6) Proof:- Handles all Proof related methods.
7) Request:- Handles all Requests related methods.
8) User:- Handles all User related methods.
9) Transactions:- Handles all User related methods.

* The utils folder has basic utilities functions like validations to validate all user input.

* The tests folder has all the unit test for the above classes. We are using mocking to mock the SDK.

* We are using prettier and eslint to make sure that code format is maintained. Across all the files.

71 changes: 71 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

## How to contribute on SDK

### Open Development
* All work on the SDK happens directly on GitHub. Both core team members and external contributors send pull requests which go through the same review process.

### Semantic Versioning
* The SDK follows [semantic versioning](https://semver.org/). We release patch versions for critical bugfixes, minor versions for new features or non-essential changes, and major versions for any breaking changes.

* When we make breaking changes, we also introduce deprecation warnings in a minor version so that our users learn about the upcoming changes and migrate their code in advance.

* Every significant change is documented in the [changelog file](https://github.com/Gateway-DAO/javascript-sdk/blob/main/CHANGELOG.md).

### Branch Organization
* Submit all changes directly to the ```develop``` branch. We use separate branches for development or for upcoming releases. And then after the bug/feature is working we release in main branch.

* Code that lands in ```develop``` must be compatible with the latest stable release. It may contain additional features, but no breaking changes. We should be able to release a new minor version from the tip of develop at any time.


### Bugs

* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead refer our [security policy](https://github.com/Gateway-DAO/javascript-sdk/blob/main/SECURITY.md).

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/Gateway-dao/javascript-sdk/issues).

* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/Gateway-dao/javascript-sdk/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** demonstrating the expected behavior that is not occurring.

* Once the issue is created you can follow the contributing steps below to start contributing


### **Add a new Feature**

* If you intend to change/add a new feature to the sdk please discuss with us first on [Discord](https://discord.gg/tgt3KjcHGs) before creating a new issue. This lets us reach an agreement on your proposal before you put significant effort into it.

* Do not open an issue on GitHub until you have collected positive feedback about the feature from us.

* We will reject issues which are not discussed with us regarding feature development.

* Once the issue is created you can follow the contributing steps below to start contributing.

### Contributing Guildeline
* You have Node.js installed at LTS with version 16+ and using pnpm as package manager.
* You have knowldge of git.
* Read the [code base overview](https://github.com/Gateway-DAO/javascript-sdk/blob/main/CODE_BASE_OVERVIEW.md) to have a short introduction about how we manage/write code.

### Development Workflow

1. After cloning the repo

2. Install dependencies using pnpm

```sh
pnpm i
```

3. Create the sdk using graphql mesh(it should give .mesh folder with sdk in it)

```sh
pnpm mesh build
```

4. Run test command to test sdk using jest

```sh
pnpm test
```
* We recommend to keep test coverage above 90% this way we make sure that the feature/bug you add don't reduce the test coverage. Also make sure that there are no linting errors as we use prettier and eslint to maintain proper code structure.

Thanks!

@Gateway-DAO Team
68 changes: 27 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Join Discord][discord-image]][discord-url]
[![Build status][travis-image]][test-passing]
[![Run Eslint & Test cases](https://github.com/Gateway-DAO/gateway-js-sdk/actions/workflows/test.yaml/badge.svg)](https://github.com/Gateway-DAO/gateway-js-sdk/actions/workflows/test.yaml)
[![Coverage Status][codecov-image]][codecov-url]

## Introduction
Expand All @@ -18,20 +18,32 @@ A TypeScript SDK for the Gateway API. This library is built with TypeScript deve

- Full type information for methods and responses.
- Bearer Token Support
- Supports Node.js 14+.
- Supports Node.js 16+.

## Installing
## Installation

### Using npm
```
pnpm add @gateway/sdk
npm install @gateway-dao/sdk
```

### Using pnpm
```
pnpm add @gateway-dao/sdk
```

### Using yarn
```
yarn install @gateway-dao/sdk
```


## Gateway Client

To setup the gateway client we will authenticate with a bearer-token and a Api key as follows

```typescript
import { Gateway } from '@gateway/sdk';
import { Gateway } from '@gateway-dao/sdk';

const gateway = new Gateway({
apiKey: 'your-api-key',
Expand All @@ -49,7 +61,7 @@ Make sure to add try catch blocks around methods to catch all the validation and
### Creating a PDA

```typescript
import { Gateway, UserIdentifierType } from '@gateway/sdk';
import { Gateway, UserIdentifierType } from '@gateway-dao/sdk';

const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' });

Expand Down Expand Up @@ -79,7 +91,7 @@ main();
### Getting a Organization

```typescript
import { Gateway } from '@gateway/sdk';
import { Gateway } from '@gateway-dao/sdk';

const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' });

Expand All @@ -103,7 +115,7 @@ main();
### Create a Data request template

```typescript
import { Gateway } from '@gateway/sdk';
import { Gateway } from '@gateway-dao/sdk';

const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' });

Expand Down Expand Up @@ -144,45 +156,19 @@ Incase of any protocol errors we will throw a custom message which is a string w

## License

The Gateway Javascript SDK is licensed under the [MIT License](https://github.com/Gateway-DAO/javascript-sdk/blob/master/LICENSE).
The Gateway Javascript SDK is licensed under the [MIT License](https://github.com/Gateway-DAO/javascript-sdk/blob/main/LICENSE.md).

## Contributing

If you want to support the active development of the SDK [Please talk to us on Discord](https://discord.gg/tgt3KjcHGs).Before contributing!.

### 🔧 Installation
If you want to support the active development of the SDK. [Please go through our Contribution guide](https://github.com/Gateway-DAO/gateway-js-sdk/blob/main/CONTRIBUTING.md)

1. Clone this repo

```sh
git clone https://github.com/Gateway-DAO/javascript-sdk
```

2. Install dependencies using pnpm

```sh
pnpm i
```

3. Create the sdk using graphql mesh(it should give .mesh folder with sdk in it)

```sh
pnpm mesh build
```

4. Run test command to test sdk using jest

```sh
pnpm test
```

[npm-image]: https://img.shields.io/npm/v/docusign-esign.svg?style=flat
[npm-url]: https://npmjs.org/package/@Gateway-dao-js-sdk
[downloads-image]: https://img.shields.io/npm/dm/docusign-esign.svg?style=flat
[downloads-url]: https://npmjs.org/package/docusign-esign
[npm-image]: https://img.shields.io/npm/v/%40gateway-dao%2Fsdk.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@gateway-dao/sdk
[downloads-image]: https://img.shields.io/npm/dm/%40gateway-dao%2Fsdk
[downloads-url]: https://www.npmjs.com/package/@gateway-dao/sdk
[codecov-image]: https://codecov.io/gh/Gateway-DAO/gateway-js-sdk/graph/badge.svg?token=8N92RFGZHI
[codecov-url]: https://codecov.io/gh/Gateway-DAO/gateway-js-sdk
[discord-image]: https://img.shields.io/discord/733027681184251937.svg?style=flat&label=Join%20Community&color=7289DA
[discord-url]: https://discord.gg/tgt3KjcHGs
[github-url]: https://github.com/Gateway-DAO/javascript-sdk
[test-passing]: https://github.com/Gateway-DAO/gateway-js-sdk/actions/workflows/main.yml/badge.svg?branch=main

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@gateway/sdk",
"name": "@gateway-dao/sdk",
"version": "0.0.0",
"description": "A Typescript SDK for the Gateway API",
"main": "dist/src/Gateway.js",
Expand Down Expand Up @@ -50,4 +50,4 @@
"type": "git",
"url": "git+https://github.com/Gateway-DAO/gateway-js-sdk.git"
}
}
}

0 comments on commit 03d3613

Please sign in to comment.