Skip to content

Commit

Permalink
Merge pull request #47 from Gateway-DAO/develop
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed mesh added custom script to generate sdk
  • Loading branch information
Siddharth9890 authored Mar 14, 2024
2 parents 1a10c8e + 3795025 commit 2f48413
Show file tree
Hide file tree
Showing 57 changed files with 2,181 additions and 3,898 deletions.
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
jest.config.js
test/*
.mesh/*
__mocks__/*
dist/*
coverage/*
custom-fetch.js
commitlint.config.js
release.config.js
.husky/*
scripts/*
scripts/*
gatewaySdk/
src/testMutationsAndQuery.ts
6 changes: 4 additions & 2 deletions .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: ['main']
branches: ['main', 'develop']

jobs:
release:
Expand All @@ -18,14 +18,16 @@ jobs:
node-version: 18.x
- name: Install pnpm
run: npm install -g pnpm@7.33.5
- name: Install uglifyjs
run: npm install uglify-js -g
- name: Install dependencies
run: pnpm install
- name: Install semantic-release extra plugins
run: pnpm install -D @semantic-release/changelog @semantic-release/git
- name: Lint
run: pnpm lint
- name: Build Graphql queries
run: pnpm mesh build
run: pnpm generate:sdk
- name: Format code
run: pnpm format
- name: Build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ jobs:
uses: actions/checkout@v3
- name: Install pnpm
run: npm install -g pnpm@7.33.5
- name: Install uglifyjs
run: npm install uglify-js -g
- name: Install Project Dependencies
run: pnpm install
- name: Run Eslint
run: pnpm lint
- name: Build Graphql queries
run: pnpm mesh build
run: pnpm generate:sdk
- name: Format code
run: pnpm format
- name: Test project
run: pnpm test
- name: Build
run: pnpm build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node_modules/
.mesh/
.vscode/
.env
dist/
*.tgz
coverage/
coverage/
.DS_STORE
gatewaySdk/
17 changes: 0 additions & 17 deletions .meshrc.yml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pnpm-store/*
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
## [1.1.1](https://github.com/Gateway-DAO/gateway-js-sdk/compare/v1.1.0...v1.1.1) (2024-02-23)


### Bug Fixes

* release triggers ([d08d5f4](https://github.com/Gateway-DAO/gateway-js-sdk/commit/d08d5f4b50e099e943751dff0b37c8b16f63373b))
- release triggers ([d08d5f4](https://github.com/Gateway-DAO/gateway-js-sdk/commit/d08d5f4b50e099e943751dff0b37c8b16f63373b))

# [1.1.0](https://github.com/Gateway-DAO/gateway-js-sdk/compare/v1.0.0...v1.1.0) (2024-02-23)

Expand Down
6 changes: 3 additions & 3 deletions CODE_BASE_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This section will give you an overview of the SDK codebase. We will also discuss

- 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
### Custom Script to generate sdk from graphql end point

- 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 don't use graphql mesh anymore instead we have a [custom in-house script](https://github.com/Gateway-DAO/gateway-js-sdk/blob/develop/scripts/generateSDK/generate.js)(heavily inspired from graphql mesh team) which generates a complete type-safe SDK using our graphql Schema.
- Using this script we are able to auto generate all of queries and mutations and also providing autocomplete feature for developing applications.

### Top Level Folder Structure

Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
- Every significant change is documented in the [changelog file](https://github.com/Gateway-DAO/javascript-sdk/blob/main/CHANGELOG.md).

### Branch Organization
- Make sure to fork the repository before contributing and create the new branch using develop as the base branch.

- Make sure to fork the repository before contributing and create the new branch using develop as the base branch.

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

Expand Down Expand Up @@ -41,7 +42,7 @@

### Contributing Guildeline

- You have Node.js installed at LTS with version 16+ and using pnpm as package manager.
- You have Node.js installed at LTS with version 18+ 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.

Expand All @@ -55,10 +56,10 @@
pnpm i
```

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

```sh
pnpm mesh build
pnpm generate:sdk
```

4. Run test command to test sdk using jest
Expand Down
6 changes: 2 additions & 4 deletions FRONTEND_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

This section will give you an overview of using SDK in frontend environment like Next.js.

- **Before starting it is not recommended to use SDK in a frontend environment because the dependencies which we use mainly graphql mesh generally have bundling problems with webpack**. So you might face unexpected problems while using it. Although we have some potential solutions which will discuss as well in the docs.
- **Please upgrade to latest version of sdk to avoid adding any extra configuration for frontend environments.If you are already using latest version of the sdk or upgraded to latest one there is no need to read this doc**. We have some potential solutions(if you are using v1) which will discuss as well in the docs.

- **It is still highly recommend to use SDK in a backend environments as there are no bundling problems and will work smoothly.**

### Bypassing graphql mesh using next.config.js
### Bypassing graphql mesh using next.config.js (Deperacted in v2 of sdk)

- You need to modify the next.config file in your nextjs application below is the code you paste to make sure you dont get any dependencies errors.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

A TypeScript SDK for the Gateway API. This library is built with TypeScript developers in mind, but it also works with JavaScript.

**Note: Make sure to [read our frontend docs](https://github.com/Gateway-DAO/gateway-js-sdk/blob/main/FRONTEND_DOCS.md) incase you are going to use SDK for frontend environemnts like Next.js**
**Note: Our latest version of sdk works without adding any extra configuration for frontend environments.**

### Features

- Full type information for methods and responses.
- Bearer Token Support
- Supports Node.js 18+.
- Works in frontend environments without adding any extra configuration.

## Installation

Expand Down
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

## Reporting a Vulnerability
Expand Down
4 changes: 4 additions & 0 deletions __mocks__/user.mock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { User } from '../src/user/user';
import { transactionStub } from '../test/stubs/transaction.stub';
import {
financialTransactionsStub,
userStub,
Expand Down Expand Up @@ -45,6 +46,9 @@ export const UserMockService = (user: User) => ({
.mockResolvedValue({
myFinancialTransactionsCount: 10,
}),
myTransactionsMock: jest
.spyOn(user.sdk, 'myTransactions_query')
.mockResolvedValue({ myTransactions: [transactionStub()] }),
mywalletMock: jest.spyOn(user.sdk, 'myWallet_query').mockResolvedValue({
myWallet: walletStub(),
}),
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [2, 'always', 200],
'footer-max-line-length': [2, 'always', 1000],
},
};
14 changes: 0 additions & 14 deletions custom-fetch.js

This file was deleted.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coveragePathIgnorePatterns: ['custom-fetch.js', '.mesh/*'],
coveragePathIgnorePatterns: ['.gatewaySdk/*'],
};
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"prepare": "husky install",
"build": "rm -rf dist && tsc && scripts/compress.sh && node scripts/compress.js"
"build": "rm -rf dist && tsc && scripts/compress.sh && node scripts/compress.js",
"generate:sdk": "node scripts/generateSDK/generate.js"
},
"engines": {
"node": ">=18.0.0"
Expand All @@ -31,26 +32,27 @@
],
"license": "MIT",
"dependencies": {
"@graphql-mesh/cli": "^0.87.16",
"@graphql-mesh/graphql": "^0.95.8",
"@graphql-mesh/runtime": "^0.96.11",
"@graphql-mesh/transform-filter-schema": "^0.96.3",
"@graphql-mesh/utils": "^0.96.3",
"@graphql-tools/url-loader": "^8.0.1",
"@graphql-typed-document-node/core": "^3.2.0",
"@solana/web3.js": "^1.87.6",
"@whatwg-node/fetch": "^0.9.13",
"encoding": "^0.1.13",
"ethers": "^5.7.2",
"fast-json-stringify": "^5.10.0",
"graphql": "^16.8.1",
"long": "^5.2.3",
"uglify-es": "^3.3.9"
"graphql-request": "^6.1.0"
},
"devDependencies": {
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@graphql-codegen/core": "^4.0.2",
"@graphql-codegen/typed-document-node": "^5.0.6",
"@graphql-codegen/typescript": "^4.0.6",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.2.0",
"@graphql-codegen/typescript-resolvers": "^4.0.6",
"@graphql-tools/utils": "^10.1.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"change-case": "^5.4.3",
"dts-minify": "^0.3.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -61,11 +63,12 @@
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"json5": "^2.2.3",
"lint-staged": "^15.2.0",
"minimatch": "^9.0.3",
"prettier": "^3.1.1",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3",
"uglify-js": "^3.17.4"
"typescript": "^5.3.3"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 2f48413

Please sign in to comment.