Skip to content

Commit

Permalink
feat(build): minified the build size from 1.08 MB => 580 KB
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Jan 29, 2024
1 parent be310ba commit d09abfd
Show file tree
Hide file tree
Showing 16 changed files with 4,798 additions and 1,682 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage/*
custom-fetch.js
commitlint.config.js
release.config.js
.husky/*
.husky/*
scripts/*
13 changes: 7 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve sdk
title: "[BUG]"
title: '[BUG]'
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Which class are you using? '...'
2. Which method are you using? '....'

Expand All @@ -22,10 +22,11 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Environment Setup (please complete the following information):**
- OS: [e.g.Windows, Mac, Linux]
- Sdk version [e.g. 1.0.0]
- Node.js Version [e.g. 16.20.2]
- Package Manager [e.g. pnpm,npm,yarn]

- OS: [e.g.Windows, Mac, Linux]
- Sdk version [e.g. 1.0.0]
- Node.js Version [e.g. 16.20.2]
- Package Manager [e.g. pnpm,npm,yarn]

**Additional context**
Add any other context about the problem here.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea to improve sdk
title: "[Feat]"
title: '[Feat]'
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
push:
branches: [ develop ]
branches: [develop]

jobs:
release:
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# [1.0.0-develop.6](https://github.com/Gateway-DAO/gateway-js-sdk/compare/v1.0.0-develop.5...v1.0.0-develop.6) (2024-01-23)


### Bug Fixes

* **tracking:** refresh .gitignore ([03317a8](https://github.com/Gateway-DAO/gateway-js-sdk/commit/03317a8bc497d119c3232e5ca59f35882d37f289))
- **tracking:** refresh .gitignore ([03317a8](https://github.com/Gateway-DAO/gateway-js-sdk/commit/03317a8bc497d119c3232e5ca59f35882d37f289))

# [1.0.0-develop.5](https://github.com/Gateway-DAO/gateway-js-sdk/compare/v1.0.0-develop.4...v1.0.0-develop.5) (2024-01-23)

Expand Down
34 changes: 18 additions & 16 deletions CODE_BASE_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

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

- 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 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 tests folder has all the unit test for the above classes. We are using mocking to mock the SDK.
- The utils folder has basic utilities functions like validations to validate all user input.

* We are using prettier and eslint to make sure that code format is maintained. Across all the files.
- 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.
46 changes: 24 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@

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

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

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


### Bugs
- 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.

* **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).
### Bugs

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

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

* Once the issue is created you can follow the contributing steps below to start contributing
- 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.
- 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.
- 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.
- 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.
- 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.

- 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

Expand All @@ -64,8 +65,9 @@
```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.

- 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
@Gateway-DAO Team
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ A TypeScript SDK for the Gateway API. This library is built with TypeScript deve
## Installation

### Using npm

```
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
Expand All @@ -51,14 +53,16 @@ const gateway = new Gateway({
url: '',
});
```

**Make sure you add token without Bearer as we add Bearer automatically when you make request. Else it will give you Unauthorized error even if your token is correct**
For example

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

const gateway = new Gateway({
apiKey: 'your-api-key',
token: 'Bearer your-token',
token: 'Bearer your-token',
// wrong will not work just use token: 'your-token'
url: '',
});
Expand Down Expand Up @@ -174,7 +178,6 @@ The Gateway Javascript SDK is licensed under the [MIT License](https://github.co

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)


[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
Expand All @@ -183,4 +186,3 @@ If you want to support the active development of the SDK. [Please go through our
[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

5 changes: 2 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

## Supported Versions


| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |


## Reporting a Vulnerability
***Do not open up a GitHub issue if the bug is a security vulnerability in SDK***. Instead, [please talk to us on Discord](https://discord.gg/tgt3KjcHGs)

**_Do not open up a GitHub issue if the bug is a security vulnerability in SDK_**. Instead, [please talk to us on Discord](https://discord.gg/tgt3KjcHGs)
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"prepare": "husky install",
"build": "tsc"
"build": "rm -rf dist && tsc && scripts/compress.sh && node scripts/compress.js"
},
"lint-staged": {
"*.ts": [
Expand Down Expand Up @@ -43,6 +43,7 @@
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"dts-minify": "^0.3.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^39.1.1",
Expand All @@ -54,8 +55,10 @@
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"terser": "^5.27.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"uglify-js": "^3.17.4"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit d09abfd

Please sign in to comment.