Skip to content

Commit bfec4b2

Browse files
authored
feat: hasura and the graph clients (#206)
## Summary by Sourcery Add new Hasura and The Graph clients to the SDK, along with supporting packages and documentation. Update build and CI configurations to accommodate new packages and ensure proper environment setup for GraphQL endpoints. New Features: - Introduce Hasura and The Graph clients for both client-side and server-side use, allowing integration with respective GraphQL APIs. - Add new packages for Hasura, The Graph, and Utils, each with their own configuration and setup files. Enhancements: - Refactor existing code to use a unified ClientOptions type across different modules, improving consistency and maintainability. - Update the build configuration to include new packages and ensure proper environment variable handling for GraphQL endpoints. Build: - Modify the build workflow to publish new SDK packages for Hasura, The Graph, and Utils, ensuring they are available for public access. CI: - Update CI workflow to include environment variables for GraphQL endpoints and adjust file patterns for version updates. Documentation: - Add comprehensive README files for the new Hasura, The Graph, and Utils packages, detailing installation, usage, API reference, and contribution guidelines.
1 parent f8507b2 commit bfec4b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+23589
-191
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ jobs:
7777
if [[ $GITHUB_REF_SLUG =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
7878
VERSION=$(echo $GITHUB_REF_SLUG | sed 's/^v//')
7979
echo "TAG=latest" >> $GITHUB_ENV
80+
echo "CONSOLE_GRAPHQL=https://console.settlemint.com/api/graphql" >> $GITHUB_ENV
8081
elif [[ $GITHUB_REF_NAME == "main" ]]; then
8182
VERSION="${OLD_VERSION}-main$(echo $GITHUB_SHA_SHORT | sed 's/^v//')"
8283
echo "TAG=main" >> $GITHUB_ENV
84+
echo "CONSOLE_GRAPHQL=https://console-release.settlemint.com/api/graphql" >> $GITHUB_ENV
8385
else
8486
VERSION="${OLD_VERSION}-pr$(echo $GITHUB_SHA_SHORT | sed 's/^v//')"
8587
echo "TAG=pr" >> $GITHUB_ENV
88+
echo "CONSOLE_GRAPHQL=https://console-release.settlemint.com/api/graphql" >> $GITHUB_ENV
8689
fi
8790
echo "VERSION=$VERSION" >> $GITHUB_ENV
8891
echo "Updating version to $VERSION"
@@ -127,6 +130,7 @@ jobs:
127130
run: bunx turbo format lint build attw publint test:coverage --concurrency=100% --summarize --env-mode=loose
128131
env:
129132
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
133+
CONSOLE_GRAPHQL: ${{ env.CONSOLE_GRAPHQL }}
130134

131135
- name: Publish SDK JS package
132136
uses: JS-DevTools/npm-publish@v3
@@ -138,6 +142,36 @@ jobs:
138142
strategy: all
139143
tag: ${{ env.TAG }}
140144

145+
- name: Publish SDK Utils package
146+
uses: JS-DevTools/npm-publish@v3
147+
with:
148+
token: ${{ secrets.NPM_TOKEN }}
149+
package: ./packages/utils/package.json
150+
access: public
151+
provenance: false
152+
strategy: all
153+
tag: ${{ env.TAG }}
154+
155+
- name: Publish SDK Hasura package
156+
uses: JS-DevTools/npm-publish@v3
157+
with:
158+
token: ${{ secrets.NPM_TOKEN }}
159+
package: ./packages/hasura/package.json
160+
access: public
161+
provenance: false
162+
strategy: all
163+
tag: ${{ env.TAG }}
164+
165+
- name: Publish SDK The Graph package
166+
uses: JS-DevTools/npm-publish@v3
167+
with:
168+
token: ${{ secrets.NPM_TOKEN }}
169+
package: ./packages/thegraph/package.json
170+
access: public
171+
provenance: false
172+
strategy: all
173+
tag: ${{ env.TAG }}
174+
141175
- name: Publish SDK Next package
142176
uses: JS-DevTools/npm-publish@v3
143177
with:
@@ -180,12 +214,16 @@ jobs:
180214
| SDK Cli | `@settlemint/sdk-cli@${{ env.VERSION }}` |
181215
| SDK Config | `@settlemint/sdk-config@${{ env.VERSION }}` |
182216
| SDK Next | `@settlemint/sdk-next@${{ env.VERSION }}` |
217+
| SDK The Graph | `@settlemint/sdk-thegraph@${{ env.VERSION }}` |
218+
| SDK Hasura | `@settlemint/sdk-hasura@${{ env.VERSION }}` |
219+
| SDK JS | `@settlemint/sdk-js@${{ env.VERSION }}` |
220+
| SDK Utils | `@settlemint/sdk-utils@${{ env.VERSION }}` |
183221
184222
- name: Auto-commit updated package versions
185223
uses: stefanzweifel/git-auto-commit-action@v5
186224
if: ${{ env.TAG == 'latest' }}
187225
with:
188226
commit_message: "chore: update package versions [skip ci]"
189227
branch: main
190-
file_pattern: 'package.json'
228+
file_pattern: 'package.json schema.graphql'
191229

bun.lockb

2 KB
Binary file not shown.

packages/hasura/.gitignore

Whitespace-only changes.

packages/hasura/LICENSE

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Functional Source License, Version 1.1, MIT Future License
2+
3+
## Abbreviation
4+
5+
FSL-1.1-MIT
6+
7+
## Notice
8+
9+
Copyright 2024 SettleMint
10+
11+
## Terms and Conditions
12+
13+
### Licensor ("We")
14+
15+
The party offering the Software under these Terms and Conditions.
16+
17+
### The Software
18+
19+
The "Software" is each version of the software that we make available under
20+
these Terms and Conditions, as indicated by our inclusion of these Terms and
21+
Conditions with the Software.
22+
23+
### License Grant
24+
25+
Subject to your compliance with this License Grant and the Patents,
26+
Redistribution and Trademark clauses below, we hereby grant you the right to
27+
use, copy, modify, create derivative works, publicly perform, publicly display
28+
and redistribute the Software for any Permitted Purpose identified below.
29+
30+
### Permitted Purpose
31+
32+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33+
means making the Software available to others in a commercial product or
34+
service that:
35+
36+
1. substitutes for the Software;
37+
38+
2. substitutes for any other product or service we offer using the Software
39+
that exists as of the date we make the Software available; or
40+
41+
3. offers the same or substantially similar functionality as the Software.
42+
43+
Permitted Purposes specifically include using the Software:
44+
45+
1. for your internal use and access;
46+
47+
2. for non-commercial education;
48+
49+
3. for non-commercial research; and
50+
51+
4. in connection with professional services that you provide to a licensee
52+
using the Software in accordance with these Terms and Conditions.
53+
54+
### Patents
55+
56+
To the extent your use for a Permitted Purpose would necessarily infringe our
57+
patents, the license grant above includes a license under our patents. If you
58+
make a claim against any party that the Software infringes or contributes to
59+
the infringement of any patent, then your patent license to the Software ends
60+
immediately.
61+
62+
### Redistribution
63+
64+
The Terms and Conditions apply to all copies, modifications and derivatives of
65+
the Software.
66+
67+
If you redistribute any copies, modifications or derivatives of the Software,
68+
you must include a copy of or a link to these Terms and Conditions and not
69+
remove any copyright notices provided in or with the Software.
70+
71+
### Disclaimer
72+
73+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76+
77+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80+
81+
### Trademarks
82+
83+
Except for displaying the License Details and identifying us as the origin of
84+
the Software, you have no right under these Terms and Conditions to use our
85+
trademarks, trade names, service marks or product names.
86+
87+
## Grant of Future License
88+
89+
We hereby irrevocably grant you an additional license to use the Software under
90+
the MIT license that is effective on the second anniversary of the date we make
91+
the Software available. On or after that date, you may use the Software under
92+
the MIT license, in which case the following will apply:
93+
94+
Permission is hereby granted, free of charge, to any person obtaining a copy of
95+
this software and associated documentation files (the "Software"), to deal in
96+
the Software without restriction, including without limitation the rights to
97+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98+
of the Software, and to permit persons to whom the Software is furnished to do
99+
so, subject to the following conditions:
100+
101+
The above copyright notice and this permission notice shall be included in all
102+
copies or substantial portions of the Software.
103+
104+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110+
SOFTWARE.

packages/hasura/README.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<p align="center">
2+
<img src="https://github.com/settlemint/sdk/blob/main/logo.svg" width="200px" align="center" alt="SettleMint logo" />
3+
<h1 align="center">SettleMint SDK</h1>
4+
<p align="center">
5+
✨ <a href="https://settlemint.com">https://settlemint.com</a> ✨
6+
<br/>
7+
Integrate SettleMint into your application with ease.
8+
</p>
9+
</p>
10+
11+
<p align="center">
12+
<a href="https://github.com/settlemint/sdk/actions?query=branch%3Amain"><img src="https://github.com/settlemint/sdk/actions/workflows/build.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
13+
<a href="https://fsl.software" rel="nofollow"><img src="https://img.shields.io/npm/l/@settlemint/sdk-js" alt="License"></a>
14+
<a href="https://www.npmjs.com/package/@settlemint/sdk-js" rel="nofollow"><img src="https://img.shields.io/npm/dw/@settlemint/sdk-js" alt="npm"></a>
15+
<a href="https://github.com/settlemint/sdk" rel="nofollow"><img src="https://img.shields.io/github/stars/settlemint/sdk" alt="stars"></a>
16+
</p>
17+
18+
<div align="center">
19+
<a href="https://console.settlemint.com/documentation/">Documentation</a>
20+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
21+
<a href="https://discord.com/invite/Mt5yqFrey9">Discord</a>
22+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
23+
<a href="https://www.npmjs.com/package/@settlemint/sdk-js">NPM</a>
24+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
25+
<a href="https://github.com/settlemint/sdk/issues">Issues</a>
26+
<br />
27+
</div>
28+
29+
## Table of Contents
30+
31+
- [Installation](#installation)
32+
- [Usage](#usage)
33+
- [API Reference](#api-reference)
34+
- [Examples](#examples)
35+
- [Contributing](#contributing)
36+
- [License](#license)
37+
38+
## Installation
39+
40+
To install the SettleMint SDK, you can use one of the following package managers:
41+
42+
```bash
43+
# Using npm
44+
npm install @settlemint/sdk
45+
46+
# Using yarn
47+
yarn add @settlemint/sdk
48+
49+
# Using pnpm
50+
pnpm add @settlemint/sdk
51+
52+
# Using Bun
53+
bun add @settlemint/sdk
54+
```
55+
56+
We recommend using Bun for faster installation and better performance.
57+
58+
## Usage
59+
60+
To use the SettleMint SDK in your Node.js application, follow these steps:
61+
62+
1. Import the SDK:
63+
64+
```javascript
65+
import { createSettleMintClient } from '@settlemint/sdk';
66+
```
67+
68+
2. Create a client instance:
69+
70+
```javascript
71+
const client = createSettleMintClient({
72+
accessToken: 'your_access_token',
73+
instance: 'https://console.settlemint.com'
74+
});
75+
```
76+
77+
3. Use the client to interact with SettleMint resources:
78+
79+
```javascript
80+
// Example: List workspaces
81+
const workspaces = await client.workspace.list();
82+
console.log(workspaces);
83+
```
84+
85+
## API Reference
86+
87+
The SettleMint SDK provides access to various resources. Here's an overview of the available methods:
88+
89+
### Workspace
90+
91+
- `workspace.list()`: List all workspaces and their applications
92+
- `workspace.read(workspaceId)`: Read a specific workspace and its applications
93+
94+
### Blockchain Network
95+
96+
- `blockchainNetwork.list(applicationId)`: List blockchain networks for a given application
97+
- `blockchainNetwork.read(blockchainNetworkId)`: Read a specific blockchain network
98+
99+
### Blockchain Node
100+
101+
- `blockchainNode.list(applicationId)`: List blockchain nodes for a given application
102+
- `blockchainNode.read(blockchainNodeId)`: Read a specific blockchain node
103+
104+
### Middleware
105+
106+
- `middleware.list(applicationId)`: List middlewares for a given application
107+
- `middleware.read(middlewareId)`: Read a specific middleware
108+
109+
### Integration Tool
110+
111+
- `integrationTool.list(applicationId)`: List integration tools for a given application
112+
- `integrationTool.read(integrationId)`: Read a specific integration tool
113+
114+
### Storage
115+
116+
- `storage.list(applicationId)`: List storage items for a given application
117+
- `storage.read(storageId)`: Read a specific storage item
118+
119+
### Private Key
120+
121+
- `privateKey.list(applicationId)`: List private keys for a given application
122+
- `privateKey.read(privateKeyId)`: Read a specific private key
123+
124+
### Insights
125+
126+
- `insights.list(applicationId)`: List insights for a given application
127+
- `insights.read(insightsId)`: Read a specific insight
128+
129+
## Examples
130+
131+
Here are some examples of how to use the SettleMint SDK:
132+
133+
### List Workspaces
134+
135+
```javascript
136+
const client = createSettleMintClient({
137+
accessToken: 'your_access_token',
138+
instance: 'https://console.settlemint.com'
139+
});
140+
141+
const workspaces = await client.workspace.list();
142+
console.log(workspaces);
143+
```
144+
145+
### Read a Specific Blockchain Network
146+
147+
```javascript
148+
const client = createSettleMintClient({
149+
accessToken: 'your_access_token',
150+
instance: 'https://console.settlemint.com'
151+
});
152+
153+
const networkId = 'your_network_id';
154+
const network = await client.blockchainNetwork.read(networkId);
155+
console.log(network);
156+
```
157+
158+
## Contributing
159+
160+
We welcome contributions to the SettleMint SDK! If you'd like to contribute, please follow these steps:
161+
162+
1. Fork the repository
163+
2. Create a new branch for your feature or bug fix
164+
3. Make your changes and commit them with a clear commit message
165+
4. Push your changes to your fork
166+
5. Create a pull request to the main repository
167+
168+
Please ensure that your code follows the existing style and includes appropriate tests and documentation.
169+
170+
## License
171+
172+
The SettleMint SDK is released under the [FSL Software License](https://fsl.software). See the [LICENSE](LICENSE) file for more details.

packages/hasura/knip.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"ignoreDependencies": [],
4+
"ignore": ["dist/**"],
5+
"entry": ["src/settlemint.ts"]
6+
}

0 commit comments

Comments
 (0)