@settlemint/sdk-hasura 2.4.1-pre00912fe → 2.4.1-pre06b0612
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
- [API Reference](#api-reference)
|
|
31
31
|
- [Functions](#functions)
|
|
32
32
|
- [createHasuraClient()](#createhasuraclient)
|
|
33
|
+
- [createHasuraMetadataClient()](#createhasurametadataclient)
|
|
33
34
|
- [createPostgresPool()](#createpostgrespool)
|
|
35
|
+
- [trackAllTables()](#trackalltables)
|
|
34
36
|
- [Type Aliases](#type-aliases)
|
|
35
37
|
- [ClientOptions](#clientoptions)
|
|
36
38
|
- [RequestConfig](#requestconfig)
|
|
@@ -51,7 +53,7 @@ The SettleMint Hasura SDK provides a seamless way to interact with Hasura GraphQ
|
|
|
51
53
|
|
|
52
54
|
> **createHasuraClient**\<`Setup`\>(`options`, `clientOptions?`, `logger?`): `object`
|
|
53
55
|
|
|
54
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
56
|
+
Defined in: [sdk/hasura/src/hasura.ts:83](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L83)
|
|
55
57
|
|
|
56
58
|
Creates a Hasura GraphQL client with proper type safety using gql.tada
|
|
57
59
|
|
|
@@ -83,8 +85,8 @@ An object containing:
|
|
|
83
85
|
|
|
84
86
|
| Name | Type | Defined in |
|
|
85
87
|
| ------ | ------ | ------ |
|
|
86
|
-
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:
|
|
87
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:
|
|
88
|
+
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:88](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L88) |
|
|
89
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:89](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L89) |
|
|
88
90
|
|
|
89
91
|
##### Throws
|
|
90
92
|
|
|
@@ -138,6 +140,72 @@ const result = await client.request(query);
|
|
|
138
140
|
|
|
139
141
|
***
|
|
140
142
|
|
|
143
|
+
#### createHasuraMetadataClient()
|
|
144
|
+
|
|
145
|
+
> **createHasuraMetadataClient**(`options`, `logger?`): \<`T`\>(`query`) => `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\>
|
|
146
|
+
|
|
147
|
+
Defined in: [sdk/hasura/src/hasura.ts:132](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L132)
|
|
148
|
+
|
|
149
|
+
Creates a Hasura Metadata client
|
|
150
|
+
|
|
151
|
+
##### Parameters
|
|
152
|
+
|
|
153
|
+
| Parameter | Type | Description |
|
|
154
|
+
| ------ | ------ | ------ |
|
|
155
|
+
| `options` | \{ `accessToken?`: `string`; `adminSecret`: `string`; `cache?`: `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"`; `instance`: `string`; \} | Configuration options for the client |
|
|
156
|
+
| `options.accessToken?` | `string` | - |
|
|
157
|
+
| `options.adminSecret?` | `string` | - |
|
|
158
|
+
| `options.cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - |
|
|
159
|
+
| `options.instance?` | `string` | - |
|
|
160
|
+
| `logger?` | `Logger` | Optional logger to use for logging the requests |
|
|
161
|
+
|
|
162
|
+
##### Returns
|
|
163
|
+
|
|
164
|
+
A function that can be used to make requests to the Hasura Metadata API
|
|
165
|
+
|
|
166
|
+
> \<`T`\>(`query`): `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\>
|
|
167
|
+
|
|
168
|
+
###### Type Parameters
|
|
169
|
+
|
|
170
|
+
| Type Parameter |
|
|
171
|
+
| ------ |
|
|
172
|
+
| `T` |
|
|
173
|
+
|
|
174
|
+
###### Parameters
|
|
175
|
+
|
|
176
|
+
| Parameter | Type |
|
|
177
|
+
| ------ | ------ |
|
|
178
|
+
| `query` | `object` |
|
|
179
|
+
|
|
180
|
+
###### Returns
|
|
181
|
+
|
|
182
|
+
`Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\>
|
|
183
|
+
|
|
184
|
+
##### Throws
|
|
185
|
+
|
|
186
|
+
Will throw an error if the options fail validation against ClientOptionsSchema
|
|
187
|
+
|
|
188
|
+
##### Example
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { createHasuraMetadataClient } from '@settlemint/sdk-hasura';
|
|
192
|
+
|
|
193
|
+
const client = createHasuraMetadataClient({
|
|
194
|
+
instance: process.env.SETTLEMINT_HASURA_ENDPOINT,
|
|
195
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
|
196
|
+
adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const result = await client({
|
|
200
|
+
type: "pg_get_source_tables",
|
|
201
|
+
args: {
|
|
202
|
+
source: "default",
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
***
|
|
208
|
+
|
|
141
209
|
#### createPostgresPool()
|
|
142
210
|
|
|
143
211
|
> **createPostgresPool**(`databaseUrl`): `Pool`
|
|
@@ -179,13 +247,55 @@ try {
|
|
|
179
247
|
}
|
|
180
248
|
```
|
|
181
249
|
|
|
250
|
+
***
|
|
251
|
+
|
|
252
|
+
#### trackAllTables()
|
|
253
|
+
|
|
254
|
+
> **trackAllTables**(`databaseName`, `client`): `Promise`\<\{ `messages`: `string`[]; `result`: `"success"` \| `"no-tables"`; \}\>
|
|
255
|
+
|
|
256
|
+
Defined in: [sdk/hasura/src/utils/track-all-tables.ts:25](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/utils/track-all-tables.ts#L25)
|
|
257
|
+
|
|
258
|
+
Track all tables in a database
|
|
259
|
+
|
|
260
|
+
##### Parameters
|
|
261
|
+
|
|
262
|
+
| Parameter | Type | Description |
|
|
263
|
+
| ------ | ------ | ------ |
|
|
264
|
+
| `databaseName` | `string` | The name of the database to track tables for |
|
|
265
|
+
| `client` | \<`T`\>(`query`) => `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\> | - |
|
|
266
|
+
|
|
267
|
+
##### Returns
|
|
268
|
+
|
|
269
|
+
`Promise`\<\{ `messages`: `string`[]; `result`: `"success"` \| `"no-tables"`; \}\>
|
|
270
|
+
|
|
271
|
+
A promise that resolves to an object with a result property indicating success or failure
|
|
272
|
+
|
|
273
|
+
##### Example
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { trackAllTables } from "@settlemint/sdk-hasura/utils/track-all-tables";
|
|
277
|
+
|
|
278
|
+
const client = createHasuraMetadataClient({
|
|
279
|
+
instance: "http://localhost:8080",
|
|
280
|
+
accessToken: "test",
|
|
281
|
+
adminSecret: "test",
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const result = await trackAllTables("default", client);
|
|
285
|
+
if (result.result === "success") {
|
|
286
|
+
console.log("Tables tracked successfully");
|
|
287
|
+
} else {
|
|
288
|
+
console.error("Failed to track tables");
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
182
292
|
### Type Aliases
|
|
183
293
|
|
|
184
294
|
#### ClientOptions
|
|
185
295
|
|
|
186
296
|
> **ClientOptions** = `object`
|
|
187
297
|
|
|
188
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
298
|
+
Defined in: [sdk/hasura/src/hasura.ts:28](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L28)
|
|
189
299
|
|
|
190
300
|
Type definition for client options derived from the ClientOptionsSchema.
|
|
191
301
|
|
|
@@ -193,10 +303,10 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
193
303
|
|
|
194
304
|
| Name | Type | Default value | Defined in |
|
|
195
305
|
| ------ | ------ | ------ | ------ |
|
|
196
|
-
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:
|
|
197
|
-
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:
|
|
198
|
-
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/hasura/src/hasura.ts:
|
|
199
|
-
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:
|
|
306
|
+
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:20](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L20) |
|
|
307
|
+
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:21](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L21) |
|
|
308
|
+
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/hasura/src/hasura.ts:22](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L22) |
|
|
309
|
+
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:19](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L19) |
|
|
200
310
|
|
|
201
311
|
***
|
|
202
312
|
|
|
@@ -204,7 +314,7 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
204
314
|
|
|
205
315
|
> **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
|
|
206
316
|
|
|
207
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
317
|
+
Defined in: [sdk/hasura/src/hasura.ts:13](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L13)
|
|
208
318
|
|
|
209
319
|
Type definition for GraphQL client configuration options
|
|
210
320
|
|
|
@@ -214,7 +324,7 @@ Type definition for GraphQL client configuration options
|
|
|
214
324
|
|
|
215
325
|
> `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
|
|
216
326
|
|
|
217
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
327
|
+
Defined in: [sdk/hasura/src/hasura.ts:18](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L18)
|
|
218
328
|
|
|
219
329
|
Schema for validating client options for the Hasura client.
|
|
220
330
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@settlemint/sdk-hasura",
|
|
3
3
|
"description": "Hasura and PostgreSQL integration module for SettleMint SDK, enabling database operations and GraphQL queries",
|
|
4
|
-
"version": "2.4.1-
|
|
4
|
+
"version": "2.4.1-pre06b0612",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"gql.tada": "^1",
|
|
69
|
-
"@settlemint/sdk-utils": "2.4.1-
|
|
69
|
+
"@settlemint/sdk-utils": "2.4.1-pre06b0612",
|
|
70
70
|
"graphql-request": "^7",
|
|
71
71
|
"zod": "^3.25.0",
|
|
72
72
|
"drizzle-orm": "^0.44.0",
|