@settlemint/sdk-hasura 2.4.1-prd60f54fc → 2.4.1-pre00912fe
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 +10 -120
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,9 +30,7 @@
|
|
|
30
30
|
- [API Reference](#api-reference)
|
|
31
31
|
- [Functions](#functions)
|
|
32
32
|
- [createHasuraClient()](#createhasuraclient)
|
|
33
|
-
- [createHasuraMetadataClient()](#createhasurametadataclient)
|
|
34
33
|
- [createPostgresPool()](#createpostgrespool)
|
|
35
|
-
- [trackAllTables()](#trackalltables)
|
|
36
34
|
- [Type Aliases](#type-aliases)
|
|
37
35
|
- [ClientOptions](#clientoptions)
|
|
38
36
|
- [RequestConfig](#requestconfig)
|
|
@@ -53,7 +51,7 @@ The SettleMint Hasura SDK provides a seamless way to interact with Hasura GraphQ
|
|
|
53
51
|
|
|
54
52
|
> **createHasuraClient**\<`Setup`\>(`options`, `clientOptions?`, `logger?`): `object`
|
|
55
53
|
|
|
56
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
54
|
+
Defined in: [sdk/hasura/src/hasura.ts:82](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L82)
|
|
57
55
|
|
|
58
56
|
Creates a Hasura GraphQL client with proper type safety using gql.tada
|
|
59
57
|
|
|
@@ -85,8 +83,8 @@ An object containing:
|
|
|
85
83
|
|
|
86
84
|
| Name | Type | Defined in |
|
|
87
85
|
| ------ | ------ | ------ |
|
|
88
|
-
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:
|
|
89
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:
|
|
86
|
+
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:87](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L87) |
|
|
87
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:88](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L88) |
|
|
90
88
|
|
|
91
89
|
##### Throws
|
|
92
90
|
|
|
@@ -140,72 +138,6 @@ const result = await client.request(query);
|
|
|
140
138
|
|
|
141
139
|
***
|
|
142
140
|
|
|
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
|
-
|
|
209
141
|
#### createPostgresPool()
|
|
210
142
|
|
|
211
143
|
> **createPostgresPool**(`databaseUrl`): `Pool`
|
|
@@ -247,55 +179,13 @@ try {
|
|
|
247
179
|
}
|
|
248
180
|
```
|
|
249
181
|
|
|
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
|
-
|
|
292
182
|
### Type Aliases
|
|
293
183
|
|
|
294
184
|
#### ClientOptions
|
|
295
185
|
|
|
296
186
|
> **ClientOptions** = `object`
|
|
297
187
|
|
|
298
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
188
|
+
Defined in: [sdk/hasura/src/hasura.ts:27](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L27)
|
|
299
189
|
|
|
300
190
|
Type definition for client options derived from the ClientOptionsSchema.
|
|
301
191
|
|
|
@@ -303,10 +193,10 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
303
193
|
|
|
304
194
|
| Name | Type | Default value | Defined in |
|
|
305
195
|
| ------ | ------ | ------ | ------ |
|
|
306
|
-
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:
|
|
307
|
-
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:
|
|
308
|
-
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/hasura/src/hasura.ts:
|
|
309
|
-
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:
|
|
196
|
+
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:19](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L19) |
|
|
197
|
+
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:20](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L20) |
|
|
198
|
+
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/hasura/src/hasura.ts:21](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L21) |
|
|
199
|
+
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:18](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L18) |
|
|
310
200
|
|
|
311
201
|
***
|
|
312
202
|
|
|
@@ -314,7 +204,7 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
314
204
|
|
|
315
205
|
> **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
|
|
316
206
|
|
|
317
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
207
|
+
Defined in: [sdk/hasura/src/hasura.ts:12](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L12)
|
|
318
208
|
|
|
319
209
|
Type definition for GraphQL client configuration options
|
|
320
210
|
|
|
@@ -324,7 +214,7 @@ Type definition for GraphQL client configuration options
|
|
|
324
214
|
|
|
325
215
|
> `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
|
|
326
216
|
|
|
327
|
-
Defined in: [sdk/hasura/src/hasura.ts:
|
|
217
|
+
Defined in: [sdk/hasura/src/hasura.ts:17](https://github.com/settlemint/sdk/blob/v2.4.1/sdk/hasura/src/hasura.ts#L17)
|
|
328
218
|
|
|
329
219
|
Schema for validating client options for the Hasura client.
|
|
330
220
|
|
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-pre00912fe",
|
|
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-pre00912fe",
|
|
70
70
|
"graphql-request": "^7",
|
|
71
71
|
"zod": "^3.25.0",
|
|
72
72
|
"drizzle-orm": "^0.44.0",
|