From 65692c05c2b48a46b0104af06ab72df9010bfd03 Mon Sep 17 00:00:00 2001 From: Siddharth9890 Date: Fri, 19 Jan 2024 18:13:50 +0530 Subject: [PATCH] chore: added CONTRIBUTING, CODE_BASE_OVERVIEW docs --- .eslintignore | 3 +- CODE_BASE_OVERVIEW.md | 28 +++++++++++++++++ CONTRIBUTING.md | 71 +++++++++++++++++++++++++++++++++++++++++++ README.md | 68 ++++++++++++++++------------------------- package.json | 4 +-- 5 files changed, 130 insertions(+), 44 deletions(-) create mode 100644 CODE_BASE_OVERVIEW.md create mode 100644 CONTRIBUTING.md diff --git a/.eslintignore b/.eslintignore index 3888181..e7f605c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,4 +4,5 @@ test/* __mocks__/* lib/* custom-fetch.js -coverage/* \ No newline at end of file +coverage/* +dist/* \ No newline at end of file diff --git a/CODE_BASE_OVERVIEW.md b/CODE_BASE_OVERVIEW.md new file mode 100644 index 0000000..d29abf7 --- /dev/null +++ b/CODE_BASE_OVERVIEW.md @@ -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. + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f272c9b --- /dev/null +++ b/CONTRIBUTING.md @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 3851a37..7d9a2e1 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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', @@ -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' }); @@ -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' }); @@ -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' }); @@ -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 + diff --git a/package.json b/package.json index 1cf5335..417ed96 100644 --- a/package.json +++ b/package.json @@ -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", @@ -50,4 +50,4 @@ "type": "git", "url": "git+https://github.com/Gateway-DAO/gateway-js-sdk.git" } -} +} \ No newline at end of file