@settlemint/sdk-hasura 2.5.0 → 2.5.1-pra786220d
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 +21 -16
- package/dist/hasura.cjs +24 -6
- package/dist/hasura.cjs.map +1 -1
- package/dist/hasura.d.cts +11 -3
- package/dist/hasura.d.ts +11 -3
- package/dist/hasura.js +24 -6
- package/dist/hasura.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ The SettleMint Hasura SDK provides a seamless way to interact with Hasura GraphQ
|
|
|
53
53
|
|
|
54
54
|
> **createHasuraClient**\<`Setup`\>(`options`, `clientOptions?`, `logger?`): `object`
|
|
55
55
|
|
|
56
|
-
Defined in: [sdk/hasura/src/hasura.ts:83](https://github.com/settlemint/sdk/blob/v2.5.
|
|
56
|
+
Defined in: [sdk/hasura/src/hasura.ts:83](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L83)
|
|
57
57
|
|
|
58
58
|
Creates a Hasura GraphQL client with proper type safety using gql.tada
|
|
59
59
|
|
|
@@ -85,8 +85,8 @@ An object containing:
|
|
|
85
85
|
|
|
86
86
|
| Name | Type | Defined in |
|
|
87
87
|
| ------ | ------ | ------ |
|
|
88
|
-
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:88](https://github.com/settlemint/sdk/blob/v2.5.
|
|
89
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:89](https://github.com/settlemint/sdk/blob/v2.5.
|
|
88
|
+
| `client` | `GraphQLClient` | [sdk/hasura/src/hasura.ts:88](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L88) |
|
|
89
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/hasura/src/hasura.ts:89](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L89) |
|
|
90
90
|
|
|
91
91
|
##### Throws
|
|
92
92
|
|
|
@@ -144,7 +144,7 @@ const result = await client.request(query);
|
|
|
144
144
|
|
|
145
145
|
> **createHasuraMetadataClient**(`options`, `logger?`): \<`T`\>(`query`) => `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\>
|
|
146
146
|
|
|
147
|
-
Defined in: [sdk/hasura/src/hasura.ts:132](https://github.com/settlemint/sdk/blob/v2.5.
|
|
147
|
+
Defined in: [sdk/hasura/src/hasura.ts:132](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L132)
|
|
148
148
|
|
|
149
149
|
Creates a Hasura Metadata client
|
|
150
150
|
|
|
@@ -210,7 +210,7 @@ const result = await client({
|
|
|
210
210
|
|
|
211
211
|
> **createPostgresPool**(`databaseUrl`): `Pool`
|
|
212
212
|
|
|
213
|
-
Defined in: [sdk/hasura/src/postgres.ts:107](https://github.com/settlemint/sdk/blob/v2.5.
|
|
213
|
+
Defined in: [sdk/hasura/src/postgres.ts:107](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/postgres.ts#L107)
|
|
214
214
|
|
|
215
215
|
Creates a PostgreSQL connection pool with error handling and retry mechanisms
|
|
216
216
|
|
|
@@ -251,9 +251,9 @@ try {
|
|
|
251
251
|
|
|
252
252
|
#### trackAllTables()
|
|
253
253
|
|
|
254
|
-
> **trackAllTables**(`databaseName`, `client`): `Promise`\<\{ `messages`: `string`[]; `result`: `"success"` \| `"no-tables"`; \}\>
|
|
254
|
+
> **trackAllTables**(`databaseName`, `client`, `tableOptions`): `Promise`\<\{ `messages`: `string`[]; `result`: `"success"` \| `"no-tables"`; \}\>
|
|
255
255
|
|
|
256
|
-
Defined in: [sdk/hasura/src/utils/track-all-tables.ts:
|
|
256
|
+
Defined in: [sdk/hasura/src/utils/track-all-tables.ts:30](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/utils/track-all-tables.ts#L30)
|
|
257
257
|
|
|
258
258
|
Track all tables in a database
|
|
259
259
|
|
|
@@ -262,7 +262,10 @@ Track all tables in a database
|
|
|
262
262
|
| Parameter | Type | Description |
|
|
263
263
|
| ------ | ------ | ------ |
|
|
264
264
|
| `databaseName` | `string` | The name of the database to track tables for |
|
|
265
|
-
| `client` | \<`T`\>(`query`) => `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\> |
|
|
265
|
+
| `client` | \<`T`\>(`query`) => `Promise`\<\{ `data`: `T`; `ok`: `boolean`; \}\> | The client options to use for the Hasura client |
|
|
266
|
+
| `tableOptions` | \{ `excludeSchemas?`: `string`[]; `includeSchemas?`: `string`[]; \} | The options to use for the table tracking |
|
|
267
|
+
| `tableOptions.excludeSchemas?` | `string`[] | The schemas to exclude from the tracking |
|
|
268
|
+
| `tableOptions.includeSchemas?` | `string`[] | The schemas to include in the tracking |
|
|
266
269
|
|
|
267
270
|
##### Returns
|
|
268
271
|
|
|
@@ -281,7 +284,9 @@ const client = createHasuraMetadataClient({
|
|
|
281
284
|
adminSecret: "test",
|
|
282
285
|
});
|
|
283
286
|
|
|
284
|
-
const result = await trackAllTables("default", client
|
|
287
|
+
const result = await trackAllTables("default", client, {
|
|
288
|
+
excludeSchemas: ["drizzle"],
|
|
289
|
+
});
|
|
285
290
|
if (result.result === "success") {
|
|
286
291
|
console.log("Tables tracked successfully");
|
|
287
292
|
} else {
|
|
@@ -295,7 +300,7 @@ if (result.result === "success") {
|
|
|
295
300
|
|
|
296
301
|
> **ClientOptions** = `object`
|
|
297
302
|
|
|
298
|
-
Defined in: [sdk/hasura/src/hasura.ts:28](https://github.com/settlemint/sdk/blob/v2.5.
|
|
303
|
+
Defined in: [sdk/hasura/src/hasura.ts:28](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L28)
|
|
299
304
|
|
|
300
305
|
Type definition for client options derived from the ClientOptionsSchema.
|
|
301
306
|
|
|
@@ -303,10 +308,10 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
303
308
|
|
|
304
309
|
| Name | Type | Default value | Defined in |
|
|
305
310
|
| ------ | ------ | ------ | ------ |
|
|
306
|
-
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:20](https://github.com/settlemint/sdk/blob/v2.5.
|
|
307
|
-
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:21](https://github.com/settlemint/sdk/blob/v2.5.
|
|
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.5.
|
|
309
|
-
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:19](https://github.com/settlemint/sdk/blob/v2.5.
|
|
311
|
+
| <a id="accesstoken"></a> `accessToken?` | `string` | - | [sdk/hasura/src/hasura.ts:20](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L20) |
|
|
312
|
+
| <a id="adminsecret"></a> `adminSecret` | `string` | - | [sdk/hasura/src/hasura.ts:21](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L21) |
|
|
313
|
+
| <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.5.1/sdk/hasura/src/hasura.ts#L22) |
|
|
314
|
+
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/hasura/src/hasura.ts:19](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L19) |
|
|
310
315
|
|
|
311
316
|
***
|
|
312
317
|
|
|
@@ -314,7 +319,7 @@ Type definition for client options derived from the ClientOptionsSchema.
|
|
|
314
319
|
|
|
315
320
|
> **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
|
|
316
321
|
|
|
317
|
-
Defined in: [sdk/hasura/src/hasura.ts:13](https://github.com/settlemint/sdk/blob/v2.5.
|
|
322
|
+
Defined in: [sdk/hasura/src/hasura.ts:13](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L13)
|
|
318
323
|
|
|
319
324
|
Type definition for GraphQL client configuration options
|
|
320
325
|
|
|
@@ -324,7 +329,7 @@ Type definition for GraphQL client configuration options
|
|
|
324
329
|
|
|
325
330
|
> `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
|
|
326
331
|
|
|
327
|
-
Defined in: [sdk/hasura/src/hasura.ts:18](https://github.com/settlemint/sdk/blob/v2.5.
|
|
332
|
+
Defined in: [sdk/hasura/src/hasura.ts:18](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/hasura/src/hasura.ts#L18)
|
|
328
333
|
|
|
329
334
|
Schema for validating client options for the Hasura client.
|
|
330
335
|
|
package/dist/hasura.cjs
CHANGED
|
@@ -36,7 +36,10 @@ const zod_v4 = __toESM(require("zod/v4"));
|
|
|
36
36
|
* Track all tables in a database
|
|
37
37
|
*
|
|
38
38
|
* @param databaseName - The name of the database to track tables for
|
|
39
|
-
* @param
|
|
39
|
+
* @param client - The client options to use for the Hasura client
|
|
40
|
+
* @param tableOptions - The options to use for the table tracking
|
|
41
|
+
* @param tableOptions.includeSchemas - The schemas to include in the tracking
|
|
42
|
+
* @param tableOptions.excludeSchemas - The schemas to exclude from the tracking
|
|
40
43
|
* @returns A promise that resolves to an object with a result property indicating success or failure
|
|
41
44
|
* @example
|
|
42
45
|
* import { trackAllTables } from "@settlemint/sdk-hasura/utils/track-all-tables";
|
|
@@ -47,15 +50,21 @@ const zod_v4 = __toESM(require("zod/v4"));
|
|
|
47
50
|
* adminSecret: "test",
|
|
48
51
|
* });
|
|
49
52
|
*
|
|
50
|
-
* const result = await trackAllTables("default", client
|
|
53
|
+
* const result = await trackAllTables("default", client, {
|
|
54
|
+
* excludeSchemas: ["drizzle"],
|
|
55
|
+
* });
|
|
51
56
|
* if (result.result === "success") {
|
|
52
57
|
* console.log("Tables tracked successfully");
|
|
53
58
|
* } else {
|
|
54
59
|
* console.error("Failed to track tables");
|
|
55
60
|
* }
|
|
56
61
|
*/
|
|
57
|
-
async function trackAllTables(databaseName, client
|
|
62
|
+
async function trackAllTables(databaseName, client, tableOptions = {
|
|
63
|
+
includeSchemas: undefined,
|
|
64
|
+
excludeSchemas: undefined
|
|
65
|
+
}) {
|
|
58
66
|
const messages = [];
|
|
67
|
+
const { includeSchemas, excludeSchemas } = tableOptions;
|
|
59
68
|
const getTablesResult = await client({
|
|
60
69
|
type: "pg_get_source_tables",
|
|
61
70
|
args: { source: databaseName }
|
|
@@ -74,21 +83,30 @@ async function trackAllTables(databaseName, client) {
|
|
|
74
83
|
await client({
|
|
75
84
|
type: "pg_untrack_tables",
|
|
76
85
|
args: {
|
|
77
|
-
tables: tables.map((table) => ({ table
|
|
86
|
+
tables: tables.map((table) => ({ table })),
|
|
78
87
|
allow_warnings: true
|
|
79
88
|
}
|
|
80
89
|
});
|
|
90
|
+
const tablesToTrack = tables.filter((table) => {
|
|
91
|
+
if (Array.isArray(includeSchemas)) {
|
|
92
|
+
return includeSchemas.includes(table.schema);
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(excludeSchemas)) {
|
|
95
|
+
return !excludeSchemas.includes(table.schema);
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
});
|
|
81
99
|
const trackResult = await client({
|
|
82
100
|
type: "pg_track_tables",
|
|
83
101
|
args: {
|
|
84
|
-
tables:
|
|
102
|
+
tables: tablesToTrack.map((table) => ({ table })),
|
|
85
103
|
allow_warnings: true
|
|
86
104
|
}
|
|
87
105
|
});
|
|
88
106
|
if (!trackResult.ok) {
|
|
89
107
|
throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
|
|
90
108
|
}
|
|
91
|
-
messages.push(`Successfully tracked ${
|
|
109
|
+
messages.push(`Successfully tracked ${tablesToTrack.length} tables`);
|
|
92
110
|
return {
|
|
93
111
|
result: "success",
|
|
94
112
|
messages
|
package/dist/hasura.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasura.cjs","names":["databaseName: string","client: ReturnType<typeof createHasuraMetadataClient>","messages: string[]","UrlOrPathSchema","options: ClientOptions","clientOptions?: RequestConfig","logger?: Logger","GraphQLClient","query: object"],"sources":["../src/utils/track-all-tables.ts","../src/hasura.ts"],"sourcesContent":["import type { createHasuraMetadataClient } from \"../hasura.js\";\n\n/**\n * Track all tables in a database\n *\n * @param databaseName - The name of the database to track tables for\n * @param options - The client options to use for the Hasura client\n * @returns A promise that resolves to an object with a result property indicating success or failure\n * @example\n * import { trackAllTables } from \"@settlemint/sdk-hasura/utils/track-all-tables\";\n *\n * const client = createHasuraMetadataClient({\n * instance: \"http://localhost:8080\",\n * accessToken: \"test\",\n * adminSecret: \"test\",\n * });\n *\n * const result = await trackAllTables(\"default\", client);\n * if (result.result === \"success\") {\n * console.log(\"Tables tracked successfully\");\n * } else {\n * console.error(\"Failed to track tables\");\n * }\n */\nexport async function trackAllTables(\n databaseName: string,\n client: ReturnType<typeof createHasuraMetadataClient>,\n): Promise<{ result: \"success\" | \"no-tables\"; messages: string[] }> {\n const messages: string[] = [];\n\n // Get all tables using pg_get_source_tables\n const getTablesResult = await client<\n Array<{\n name: string;\n schema: string;\n }>\n >({\n type: \"pg_get_source_tables\",\n args: {\n source: databaseName,\n },\n });\n\n if (!getTablesResult.ok) {\n throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);\n }\n\n const tables = getTablesResult.data;\n\n if (tables.length === 0) {\n return { result: \"no-tables\" as const, messages };\n }\n\n messages.push(`Found ${tables.length} tables in database \"${databaseName}\"`);\n\n // Incase a table is already tracked, untrack it first\n await client<{ code?: string }>({\n type: \"pg_untrack_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table.name,\n })),\n allow_warnings: true,\n },\n });\n\n // Track all tables\n const trackResult = await client<{ code?: string }>({\n type: \"pg_track_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table.name,\n })),\n allow_warnings: true,\n },\n });\n\n if (!trackResult.ok) {\n throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);\n }\n\n messages.push(`Successfully tracked ${tables.length} tables`);\n\n return { result: \"success\" as const, messages };\n}\n","import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils\";\nimport { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { type Logger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Hasura client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n adminSecret: z.string(),\n cache: z.enum([\"default\", \"force-cache\", \"no-cache\", \"no-store\", \"only-if-cached\", \"reload\"]).optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Hasura GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @param logger - Optional logger to use for logging the requests\n * @returns An object containing:\n * - client: The configured GraphQL client instance\n * - graphql: The initialized gql.tada function for type-safe queries\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraClient } from '@settlemint/sdk-hasura';\n * import type { introspection } from \"@schemas/hasura-env\";\n * import { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createHasuraClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * timestamp: string;\n * timestampz: string;\n * uuid: string;\n * date: string;\n * time: string;\n * jsonb: string;\n * numeric: string;\n * interval: string;\n * geometry: string;\n * geography: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * }, {\n * fetch: requestLogger(logger, \"hasura\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetUsers {\n * users {\n * id\n * name\n * email\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createHasuraClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n logger?: Logger,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n }),\n fetch: (logger ? requestLogger(logger, \"hasura\", fetch) : fetch) as typeof fetch,\n }),\n graphql,\n };\n}\n\n/**\n * Creates a Hasura Metadata client\n *\n * @param options - Configuration options for the client\n * @param logger - Optional logger to use for logging the requests\n * @returns A function that can be used to make requests to the Hasura Metadata API\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraMetadataClient } from '@settlemint/sdk-hasura';\n *\n * const client = createHasuraMetadataClient({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * });\n *\n * const result = await client({\n * type: \"pg_get_source_tables\",\n * args: {\n * source: \"default\",\n * },\n * });\n */\nexport function createHasuraMetadataClient(options: ClientOptions, logger?: Logger) {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const baseUrl = extractBaseUrlBeforeSegment(options.instance, \"/v1/graphql\");\n const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();\n const fetchInstance = logger ? requestLogger(logger, \"hasura\", fetch) : fetch;\n\n return async <T>(query: object): Promise<{ ok: boolean; data: T }> => {\n const response = await fetchInstance(queryEndpoint, {\n method: \"POST\",\n headers: appendHeaders(\n { \"Content-Type\": \"application/json\" },\n {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n },\n ),\n body: JSON.stringify(query),\n });\n\n if (!response.ok) {\n return { ok: false, data: (await response.json()) as T };\n }\n\n return { ok: true, data: (await response.json()) as T };\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\nexport { trackAllTables } from \"./utils/track-all-tables.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,eACpBA,cACAC,QACkE;CAClE,MAAMC,WAAqB,CAAE;CAG7B,MAAM,kBAAkB,MAAM,OAK5B;EACA,MAAM;EACN,MAAM,EACJ,QAAQ,aACT;CACF,EAAC;AAEF,MAAK,gBAAgB,IAAI;AACvB,QAAM,IAAI,OAAO,wBAAwB,KAAK,UAAU,gBAAgB,KAAK,CAAC;CAC/E;CAED,MAAM,SAAS,gBAAgB;AAE/B,KAAI,OAAO,WAAW,GAAG;AACvB,SAAO;GAAE,QAAQ;GAAsB;EAAU;CAClD;AAED,UAAS,MAAM,QAAQ,OAAO,O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,mDAAc;CACd,MAAM,mBAAmB,gDAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,wDAA4B,QAAQ,UAAU,cAAc;CAC5E,MAAM,gBAAgB,IAAI,KAAK,EAAE,QAAQ,eAAe,UAAU;CAClE,MAAM,gBAAgB,SAAS,kDAAc,QAAQ,UAAU,MAAM,GAAG;AAExE,QAAO,OAAUE,UAAqD;EACpE,MAAM,WAAW,MAAM,cAAc,eAAe;GAClD,QAAQ;GACR,SAAS,+CACP,EAAE,gBAAgB,mBAAoB,GACtC;IACE,gBAAgB,iBAAiB;IACjC,yBAAyB,iBAAiB;GAC3C,EACF;GACD,MAAM,KAAK,UAAU,MAAM;EAC5B,EAAC;AAEF,OAAK,SAAS,IAAI;AAChB,UAAO;IAAE,IAAI;IAAO,MAAO,MAAM,SAAS,MAAM;GAAQ;EACzD;AAED,SAAO;GAAE,IAAI;GAAM,MAAO,MAAM,SAAS,MAAM;EAAQ;CACxD;AACF"}
|
|
1
|
+
{"version":3,"file":"hasura.cjs","names":["databaseName: string","client: ReturnType<typeof createHasuraMetadataClient>","tableOptions: {\n includeSchemas?: string[];\n excludeSchemas?: string[];\n }","messages: string[]","UrlOrPathSchema","options: ClientOptions","clientOptions?: RequestConfig","logger?: Logger","GraphQLClient","query: object"],"sources":["../src/utils/track-all-tables.ts","../src/hasura.ts"],"sourcesContent":["import type { createHasuraMetadataClient } from \"../hasura.js\";\n\n/**\n * Track all tables in a database\n *\n * @param databaseName - The name of the database to track tables for\n * @param client - The client options to use for the Hasura client\n * @param tableOptions - The options to use for the table tracking\n * @param tableOptions.includeSchemas - The schemas to include in the tracking\n * @param tableOptions.excludeSchemas - The schemas to exclude from the tracking\n * @returns A promise that resolves to an object with a result property indicating success or failure\n * @example\n * import { trackAllTables } from \"@settlemint/sdk-hasura/utils/track-all-tables\";\n *\n * const client = createHasuraMetadataClient({\n * instance: \"http://localhost:8080\",\n * accessToken: \"test\",\n * adminSecret: \"test\",\n * });\n *\n * const result = await trackAllTables(\"default\", client, {\n * excludeSchemas: [\"drizzle\"],\n * });\n * if (result.result === \"success\") {\n * console.log(\"Tables tracked successfully\");\n * } else {\n * console.error(\"Failed to track tables\");\n * }\n */\nexport async function trackAllTables(\n databaseName: string,\n client: ReturnType<typeof createHasuraMetadataClient>,\n tableOptions: {\n includeSchemas?: string[];\n excludeSchemas?: string[];\n } = {\n includeSchemas: undefined,\n excludeSchemas: undefined,\n },\n): Promise<{ result: \"success\" | \"no-tables\"; messages: string[] }> {\n const messages: string[] = [];\n\n const { includeSchemas, excludeSchemas } = tableOptions;\n\n // Get all tables using pg_get_source_tables\n const getTablesResult = await client<\n Array<{\n name: string;\n schema: string;\n }>\n >({\n type: \"pg_get_source_tables\",\n args: {\n source: databaseName,\n },\n });\n\n if (!getTablesResult.ok) {\n throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);\n }\n\n const tables = getTablesResult.data;\n\n if (tables.length === 0) {\n return { result: \"no-tables\" as const, messages };\n }\n\n messages.push(`Found ${tables.length} tables in database \"${databaseName}\"`);\n\n // Incase a table is already tracked, untrack it first\n await client<{ code?: string }>({\n type: \"pg_untrack_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table,\n })),\n allow_warnings: true,\n },\n });\n\n const tablesToTrack = tables.filter((table) => {\n if (Array.isArray(includeSchemas)) {\n return includeSchemas.includes(table.schema);\n }\n if (Array.isArray(excludeSchemas)) {\n return !excludeSchemas.includes(table.schema);\n }\n return true;\n });\n\n // Track all tables\n const trackResult = await client<{ code?: string }>({\n type: \"pg_track_tables\",\n args: {\n tables: tablesToTrack.map((table) => ({\n table: table,\n })),\n allow_warnings: true,\n },\n });\n\n if (!trackResult.ok) {\n throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);\n }\n\n messages.push(`Successfully tracked ${tablesToTrack.length} tables`);\n\n return { result: \"success\" as const, messages };\n}\n","import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils\";\nimport { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { type Logger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Hasura client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n adminSecret: z.string(),\n cache: z.enum([\"default\", \"force-cache\", \"no-cache\", \"no-store\", \"only-if-cached\", \"reload\"]).optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Hasura GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @param logger - Optional logger to use for logging the requests\n * @returns An object containing:\n * - client: The configured GraphQL client instance\n * - graphql: The initialized gql.tada function for type-safe queries\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraClient } from '@settlemint/sdk-hasura';\n * import type { introspection } from \"@schemas/hasura-env\";\n * import { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createHasuraClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * timestamp: string;\n * timestampz: string;\n * uuid: string;\n * date: string;\n * time: string;\n * jsonb: string;\n * numeric: string;\n * interval: string;\n * geometry: string;\n * geography: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * }, {\n * fetch: requestLogger(logger, \"hasura\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetUsers {\n * users {\n * id\n * name\n * email\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createHasuraClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n logger?: Logger,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n }),\n fetch: (logger ? requestLogger(logger, \"hasura\", fetch) : fetch) as typeof fetch,\n }),\n graphql,\n };\n}\n\n/**\n * Creates a Hasura Metadata client\n *\n * @param options - Configuration options for the client\n * @param logger - Optional logger to use for logging the requests\n * @returns A function that can be used to make requests to the Hasura Metadata API\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraMetadataClient } from '@settlemint/sdk-hasura';\n *\n * const client = createHasuraMetadataClient({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * });\n *\n * const result = await client({\n * type: \"pg_get_source_tables\",\n * args: {\n * source: \"default\",\n * },\n * });\n */\nexport function createHasuraMetadataClient(options: ClientOptions, logger?: Logger) {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const baseUrl = extractBaseUrlBeforeSegment(options.instance, \"/v1/graphql\");\n const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();\n const fetchInstance = logger ? requestLogger(logger, \"hasura\", fetch) : fetch;\n\n return async <T>(query: object): Promise<{ ok: boolean; data: T }> => {\n const response = await fetchInstance(queryEndpoint, {\n method: \"POST\",\n headers: appendHeaders(\n { \"Content-Type\": \"application/json\" },\n {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n },\n ),\n body: JSON.stringify(query),\n });\n\n if (!response.ok) {\n return { ok: false, data: (await response.json()) as T };\n }\n\n return { ok: true, data: (await response.json()) as T };\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\nexport { trackAllTables } from \"./utils/track-all-tables.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,eACpBA,cACAC,QACAC,eAGI;CACF,gBAAgB;CAChB,gBAAgB;AACjB,GACiE;CAClE,MAAMC,WAAqB,CAAE;CAE7B,MAAM,EAAE,gBAAgB,gBAAgB,GAAG;CAG3C,MAAM,kBAAkB,MAAM,OAK5B;EACA,MAAM;EACN,MAAM,EACJ,QAAQ,aACT;CACF,EAAC;AAEF,MAAK,gBAAgB,IAAI;AACvB,QAAM,IAAI,OAAO,wBAAwB,KAAK,UAAU,gBAAgB,KAAK,CAAC;CAC/E;CAED,MAAM,SAAS,gBAAgB;AAE/B,KAAI,OAAO,WAAW,GAAG;AACvB,SAAO;GAAE,QAAQ;GAAsB;EAAU;CAClD;AAED,UAAS,MAAM,QAAQ,OAAO,OAAO,uBAAuB,aAAa,GAAG;AAG5E,OAAM,OAA0B;EAC9B,MAAM;EACN,MAAM;GACJ,QAAQ,OAAO,IAAI,CAAC,WAAW,EACtB,MACR,GAAE;GACH,gBAAgB;EACjB;CACF,EAAC;CAEF,MAAM,gBAAgB,OAAO,OAAO,CAAC,UAAU;AAC7C,MAAI,MAAM,QAAQ,eAAe,EAAE;AACjC,UAAO,eAAe,S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AC/D,MAAM,UAAU,wDAA4B,QAAQ,UAAU,cAAc;CAC5E,MAAM,gBAAgB,IAAI,KAAK,EAAE,QAAQ,eAAe,UAAU;CAClE,MAAM,gBAAgB,SAAS,kDAAc,QAAQ,UAAU,MAAM,GAAG;AAExE,QAAO,OAAUE,UAAqD;EACpE,MAAM,WAAW,MAAM,cAAc,eAAe;GAClD,QAAQ;GACR,SAAS,+CACP,EAAE,gBAAgB,mBAAoB,GACtC;IACE,gBAAgB,iBAAiB;IACjC,yBAAyB,iBAAiB;GAC3C,EACF;GACD,MAAM,KAAK,UAAU,MAAM;EAC5B,EAAC;AAEF,OAAK,SAAS,IAAI;AAChB,UAAO;IAAE,IAAI;IAAO,MAAO,MAAM,SAAS,MAAM;GAAQ;EACzD;AAED,SAAO;GAAE,IAAI;GAAM,MAAO,MAAM,SAAS,MAAM;EAAQ;CACxD;AACF"}
|
package/dist/hasura.d.cts
CHANGED
|
@@ -10,7 +10,10 @@ import { z } from "zod/v4";
|
|
|
10
10
|
* Track all tables in a database
|
|
11
11
|
*
|
|
12
12
|
* @param databaseName - The name of the database to track tables for
|
|
13
|
-
* @param
|
|
13
|
+
* @param client - The client options to use for the Hasura client
|
|
14
|
+
* @param tableOptions - The options to use for the table tracking
|
|
15
|
+
* @param tableOptions.includeSchemas - The schemas to include in the tracking
|
|
16
|
+
* @param tableOptions.excludeSchemas - The schemas to exclude from the tracking
|
|
14
17
|
* @returns A promise that resolves to an object with a result property indicating success or failure
|
|
15
18
|
* @example
|
|
16
19
|
* import { trackAllTables } from "@settlemint/sdk-hasura/utils/track-all-tables";
|
|
@@ -21,14 +24,19 @@ import { z } from "zod/v4";
|
|
|
21
24
|
* adminSecret: "test",
|
|
22
25
|
* });
|
|
23
26
|
*
|
|
24
|
-
* const result = await trackAllTables("default", client
|
|
27
|
+
* const result = await trackAllTables("default", client, {
|
|
28
|
+
* excludeSchemas: ["drizzle"],
|
|
29
|
+
* });
|
|
25
30
|
* if (result.result === "success") {
|
|
26
31
|
* console.log("Tables tracked successfully");
|
|
27
32
|
* } else {
|
|
28
33
|
* console.error("Failed to track tables");
|
|
29
34
|
* }
|
|
30
35
|
*/
|
|
31
|
-
declare function trackAllTables(databaseName: string, client: ReturnType<typeof createHasuraMetadataClient
|
|
36
|
+
declare function trackAllTables(databaseName: string, client: ReturnType<typeof createHasuraMetadataClient>, tableOptions?: {
|
|
37
|
+
includeSchemas?: string[];
|
|
38
|
+
excludeSchemas?: string[];
|
|
39
|
+
}): Promise<{
|
|
32
40
|
result: "success" | "no-tables";
|
|
33
41
|
messages: string[];
|
|
34
42
|
}>;
|
package/dist/hasura.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ import { z } from "zod/v4";
|
|
|
10
10
|
* Track all tables in a database
|
|
11
11
|
*
|
|
12
12
|
* @param databaseName - The name of the database to track tables for
|
|
13
|
-
* @param
|
|
13
|
+
* @param client - The client options to use for the Hasura client
|
|
14
|
+
* @param tableOptions - The options to use for the table tracking
|
|
15
|
+
* @param tableOptions.includeSchemas - The schemas to include in the tracking
|
|
16
|
+
* @param tableOptions.excludeSchemas - The schemas to exclude from the tracking
|
|
14
17
|
* @returns A promise that resolves to an object with a result property indicating success or failure
|
|
15
18
|
* @example
|
|
16
19
|
* import { trackAllTables } from "@settlemint/sdk-hasura/utils/track-all-tables";
|
|
@@ -21,14 +24,19 @@ import { z } from "zod/v4";
|
|
|
21
24
|
* adminSecret: "test",
|
|
22
25
|
* });
|
|
23
26
|
*
|
|
24
|
-
* const result = await trackAllTables("default", client
|
|
27
|
+
* const result = await trackAllTables("default", client, {
|
|
28
|
+
* excludeSchemas: ["drizzle"],
|
|
29
|
+
* });
|
|
25
30
|
* if (result.result === "success") {
|
|
26
31
|
* console.log("Tables tracked successfully");
|
|
27
32
|
* } else {
|
|
28
33
|
* console.error("Failed to track tables");
|
|
29
34
|
* }
|
|
30
35
|
*/
|
|
31
|
-
declare function trackAllTables(databaseName: string, client: ReturnType<typeof createHasuraMetadataClient
|
|
36
|
+
declare function trackAllTables(databaseName: string, client: ReturnType<typeof createHasuraMetadataClient>, tableOptions?: {
|
|
37
|
+
includeSchemas?: string[];
|
|
38
|
+
excludeSchemas?: string[];
|
|
39
|
+
}): Promise<{
|
|
32
40
|
result: "success" | "no-tables";
|
|
33
41
|
messages: string[];
|
|
34
42
|
}>;
|
package/dist/hasura.js
CHANGED
|
@@ -13,7 +13,10 @@ import { z } from "zod/v4";
|
|
|
13
13
|
* Track all tables in a database
|
|
14
14
|
*
|
|
15
15
|
* @param databaseName - The name of the database to track tables for
|
|
16
|
-
* @param
|
|
16
|
+
* @param client - The client options to use for the Hasura client
|
|
17
|
+
* @param tableOptions - The options to use for the table tracking
|
|
18
|
+
* @param tableOptions.includeSchemas - The schemas to include in the tracking
|
|
19
|
+
* @param tableOptions.excludeSchemas - The schemas to exclude from the tracking
|
|
17
20
|
* @returns A promise that resolves to an object with a result property indicating success or failure
|
|
18
21
|
* @example
|
|
19
22
|
* import { trackAllTables } from "@settlemint/sdk-hasura/utils/track-all-tables";
|
|
@@ -24,15 +27,21 @@ import { z } from "zod/v4";
|
|
|
24
27
|
* adminSecret: "test",
|
|
25
28
|
* });
|
|
26
29
|
*
|
|
27
|
-
* const result = await trackAllTables("default", client
|
|
30
|
+
* const result = await trackAllTables("default", client, {
|
|
31
|
+
* excludeSchemas: ["drizzle"],
|
|
32
|
+
* });
|
|
28
33
|
* if (result.result === "success") {
|
|
29
34
|
* console.log("Tables tracked successfully");
|
|
30
35
|
* } else {
|
|
31
36
|
* console.error("Failed to track tables");
|
|
32
37
|
* }
|
|
33
38
|
*/
|
|
34
|
-
async function trackAllTables(databaseName, client
|
|
39
|
+
async function trackAllTables(databaseName, client, tableOptions = {
|
|
40
|
+
includeSchemas: undefined,
|
|
41
|
+
excludeSchemas: undefined
|
|
42
|
+
}) {
|
|
35
43
|
const messages = [];
|
|
44
|
+
const { includeSchemas, excludeSchemas } = tableOptions;
|
|
36
45
|
const getTablesResult = await client({
|
|
37
46
|
type: "pg_get_source_tables",
|
|
38
47
|
args: { source: databaseName }
|
|
@@ -51,21 +60,30 @@ async function trackAllTables(databaseName, client) {
|
|
|
51
60
|
await client({
|
|
52
61
|
type: "pg_untrack_tables",
|
|
53
62
|
args: {
|
|
54
|
-
tables: tables.map((table) => ({ table
|
|
63
|
+
tables: tables.map((table) => ({ table })),
|
|
55
64
|
allow_warnings: true
|
|
56
65
|
}
|
|
57
66
|
});
|
|
67
|
+
const tablesToTrack = tables.filter((table) => {
|
|
68
|
+
if (Array.isArray(includeSchemas)) {
|
|
69
|
+
return includeSchemas.includes(table.schema);
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(excludeSchemas)) {
|
|
72
|
+
return !excludeSchemas.includes(table.schema);
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
58
76
|
const trackResult = await client({
|
|
59
77
|
type: "pg_track_tables",
|
|
60
78
|
args: {
|
|
61
|
-
tables:
|
|
79
|
+
tables: tablesToTrack.map((table) => ({ table })),
|
|
62
80
|
allow_warnings: true
|
|
63
81
|
}
|
|
64
82
|
});
|
|
65
83
|
if (!trackResult.ok) {
|
|
66
84
|
throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);
|
|
67
85
|
}
|
|
68
|
-
messages.push(`Successfully tracked ${
|
|
86
|
+
messages.push(`Successfully tracked ${tablesToTrack.length} tables`);
|
|
69
87
|
return {
|
|
70
88
|
result: "success",
|
|
71
89
|
messages
|
package/dist/hasura.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasura.js","names":["databaseName: string","client: ReturnType<typeof createHasuraMetadataClient>","messages: string[]","options: ClientOptions","clientOptions?: RequestConfig","logger?: Logger","query: object"],"sources":["../src/utils/track-all-tables.ts","../src/hasura.ts"],"sourcesContent":["import type { createHasuraMetadataClient } from \"../hasura.js\";\n\n/**\n * Track all tables in a database\n *\n * @param databaseName - The name of the database to track tables for\n * @param options - The client options to use for the Hasura client\n * @returns A promise that resolves to an object with a result property indicating success or failure\n * @example\n * import { trackAllTables } from \"@settlemint/sdk-hasura/utils/track-all-tables\";\n *\n * const client = createHasuraMetadataClient({\n * instance: \"http://localhost:8080\",\n * accessToken: \"test\",\n * adminSecret: \"test\",\n * });\n *\n * const result = await trackAllTables(\"default\", client);\n * if (result.result === \"success\") {\n * console.log(\"Tables tracked successfully\");\n * } else {\n * console.error(\"Failed to track tables\");\n * }\n */\nexport async function trackAllTables(\n databaseName: string,\n client: ReturnType<typeof createHasuraMetadataClient>,\n): Promise<{ result: \"success\" | \"no-tables\"; messages: string[] }> {\n const messages: string[] = [];\n\n // Get all tables using pg_get_source_tables\n const getTablesResult = await client<\n Array<{\n name: string;\n schema: string;\n }>\n >({\n type: \"pg_get_source_tables\",\n args: {\n source: databaseName,\n },\n });\n\n if (!getTablesResult.ok) {\n throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);\n }\n\n const tables = getTablesResult.data;\n\n if (tables.length === 0) {\n return { result: \"no-tables\" as const, messages };\n }\n\n messages.push(`Found ${tables.length} tables in database \"${databaseName}\"`);\n\n // Incase a table is already tracked, untrack it first\n await client<{ code?: string }>({\n type: \"pg_untrack_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table.name,\n })),\n allow_warnings: true,\n },\n });\n\n // Track all tables\n const trackResult = await client<{ code?: string }>({\n type: \"pg_track_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table.name,\n })),\n allow_warnings: true,\n },\n });\n\n if (!trackResult.ok) {\n throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);\n }\n\n messages.push(`Successfully tracked ${tables.length} tables`);\n\n return { result: \"success\" as const, messages };\n}\n","import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils\";\nimport { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { type Logger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Hasura client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n adminSecret: z.string(),\n cache: z.enum([\"default\", \"force-cache\", \"no-cache\", \"no-store\", \"only-if-cached\", \"reload\"]).optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Hasura GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @param logger - Optional logger to use for logging the requests\n * @returns An object containing:\n * - client: The configured GraphQL client instance\n * - graphql: The initialized gql.tada function for type-safe queries\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraClient } from '@settlemint/sdk-hasura';\n * import type { introspection } from \"@schemas/hasura-env\";\n * import { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createHasuraClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * timestamp: string;\n * timestampz: string;\n * uuid: string;\n * date: string;\n * time: string;\n * jsonb: string;\n * numeric: string;\n * interval: string;\n * geometry: string;\n * geography: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * }, {\n * fetch: requestLogger(logger, \"hasura\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetUsers {\n * users {\n * id\n * name\n * email\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createHasuraClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n logger?: Logger,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n }),\n fetch: (logger ? requestLogger(logger, \"hasura\", fetch) : fetch) as typeof fetch,\n }),\n graphql,\n };\n}\n\n/**\n * Creates a Hasura Metadata client\n *\n * @param options - Configuration options for the client\n * @param logger - Optional logger to use for logging the requests\n * @returns A function that can be used to make requests to the Hasura Metadata API\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraMetadataClient } from '@settlemint/sdk-hasura';\n *\n * const client = createHasuraMetadataClient({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * });\n *\n * const result = await client({\n * type: \"pg_get_source_tables\",\n * args: {\n * source: \"default\",\n * },\n * });\n */\nexport function createHasuraMetadataClient(options: ClientOptions, logger?: Logger) {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const baseUrl = extractBaseUrlBeforeSegment(options.instance, \"/v1/graphql\");\n const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();\n const fetchInstance = logger ? requestLogger(logger, \"hasura\", fetch) : fetch;\n\n return async <T>(query: object): Promise<{ ok: boolean; data: T }> => {\n const response = await fetchInstance(queryEndpoint, {\n method: \"POST\",\n headers: appendHeaders(\n { \"Content-Type\": \"application/json\" },\n {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n },\n ),\n body: JSON.stringify(query),\n });\n\n if (!response.ok) {\n return { ok: false, data: (await response.json()) as T };\n }\n\n return { ok: true, data: (await response.json()) as T };\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\nexport { trackAllTables } from \"./utils/track-all-tables.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,eACpBA,cACAC,QACkE;CAClE,MAAMC,WAAqB,CAAE;CAG7B,MAAM,kBAAkB,MAAM,OAK5B;EACA,MAAM;EACN,MAAM,EACJ,QAAQ,aACT;CACF,EAAC;AAEF,MAAK,gBAAgB,IAAI;AACvB,QAAM,IAAI,OAAO,wBAAwB,KAAK,UAAU,gBAAgB,KAAK,CAAC;CAC/E;CAED,MAAM,SAAS,gBAAgB;AAE/B,KAAI,OAAO,WAAW,GAAG;AACvB,SAAO;GAAE,QAAQ;GAAsB;EAAU;CAClD;AAED,UAAS,MAAM,QAAQ,OAAO,OAAO,uBAAuB,aAAa,GAAG;AAG5E,OAAM,OAA0B;EAC9B,MAAM;EACN,MAAM;GACJ,QAAQ,OAAO,IAAI,CAAC,WAAW,EAC7B,OAAO,MAAM,KACd,GAAE;GACH,gBAAgB;EACjB;CACF,EAAC;CAGF,MAAM,cAAc,MAAM,OAA0B;EAClD,MAAM;EACN,MAAM;GACJ,QAAQ,OAAO,IAAI,CAAC,WAAW,EAC7B,OAAO,MAAM,KACd,GAAE;GACH,gBAAgB;EACjB;CACF,EAAC;AAEF,MAAK,YAAY,IAAI;AACnB,QAAM,IAAI,OAAO,0BAA0B,KAAK,UAAU,YAAY,KAAK,CAAC;CAC7E;AAED,UAAS,MAAM,uBAAuB,OAAO,OAAO,SAAS;AAE7D,QAAO;EAAE,QAAQ;EAAoB;CAAU;AA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M;GAAQ;EACzD;AAED,SAAO;GAAE,IAAI;GAAM,MAAO,MAAM,SAAS,MAAM;EAAQ;CACxD;AACF"}
|
|
1
|
+
{"version":3,"file":"hasura.js","names":["databaseName: string","client: ReturnType<typeof createHasuraMetadataClient>","tableOptions: {\n includeSchemas?: string[];\n excludeSchemas?: string[];\n }","messages: string[]","options: ClientOptions","clientOptions?: RequestConfig","logger?: Logger","query: object"],"sources":["../src/utils/track-all-tables.ts","../src/hasura.ts"],"sourcesContent":["import type { createHasuraMetadataClient } from \"../hasura.js\";\n\n/**\n * Track all tables in a database\n *\n * @param databaseName - The name of the database to track tables for\n * @param client - The client options to use for the Hasura client\n * @param tableOptions - The options to use for the table tracking\n * @param tableOptions.includeSchemas - The schemas to include in the tracking\n * @param tableOptions.excludeSchemas - The schemas to exclude from the tracking\n * @returns A promise that resolves to an object with a result property indicating success or failure\n * @example\n * import { trackAllTables } from \"@settlemint/sdk-hasura/utils/track-all-tables\";\n *\n * const client = createHasuraMetadataClient({\n * instance: \"http://localhost:8080\",\n * accessToken: \"test\",\n * adminSecret: \"test\",\n * });\n *\n * const result = await trackAllTables(\"default\", client, {\n * excludeSchemas: [\"drizzle\"],\n * });\n * if (result.result === \"success\") {\n * console.log(\"Tables tracked successfully\");\n * } else {\n * console.error(\"Failed to track tables\");\n * }\n */\nexport async function trackAllTables(\n databaseName: string,\n client: ReturnType<typeof createHasuraMetadataClient>,\n tableOptions: {\n includeSchemas?: string[];\n excludeSchemas?: string[];\n } = {\n includeSchemas: undefined,\n excludeSchemas: undefined,\n },\n): Promise<{ result: \"success\" | \"no-tables\"; messages: string[] }> {\n const messages: string[] = [];\n\n const { includeSchemas, excludeSchemas } = tableOptions;\n\n // Get all tables using pg_get_source_tables\n const getTablesResult = await client<\n Array<{\n name: string;\n schema: string;\n }>\n >({\n type: \"pg_get_source_tables\",\n args: {\n source: databaseName,\n },\n });\n\n if (!getTablesResult.ok) {\n throw new Error(`Failed to get tables: ${JSON.stringify(getTablesResult.data)}`);\n }\n\n const tables = getTablesResult.data;\n\n if (tables.length === 0) {\n return { result: \"no-tables\" as const, messages };\n }\n\n messages.push(`Found ${tables.length} tables in database \"${databaseName}\"`);\n\n // Incase a table is already tracked, untrack it first\n await client<{ code?: string }>({\n type: \"pg_untrack_tables\",\n args: {\n tables: tables.map((table) => ({\n table: table,\n })),\n allow_warnings: true,\n },\n });\n\n const tablesToTrack = tables.filter((table) => {\n if (Array.isArray(includeSchemas)) {\n return includeSchemas.includes(table.schema);\n }\n if (Array.isArray(excludeSchemas)) {\n return !excludeSchemas.includes(table.schema);\n }\n return true;\n });\n\n // Track all tables\n const trackResult = await client<{ code?: string }>({\n type: \"pg_track_tables\",\n args: {\n tables: tablesToTrack.map((table) => ({\n table: table,\n })),\n allow_warnings: true,\n },\n });\n\n if (!trackResult.ok) {\n throw new Error(`Failed to track tables: ${JSON.stringify(trackResult.data)}`);\n }\n\n messages.push(`Successfully tracked ${tablesToTrack.length} tables`);\n\n return { result: \"success\" as const, messages };\n}\n","import { extractBaseUrlBeforeSegment } from \"@settlemint/sdk-utils\";\nimport { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { type Logger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Hasura client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n adminSecret: z.string(),\n cache: z.enum([\"default\", \"force-cache\", \"no-cache\", \"no-store\", \"only-if-cached\", \"reload\"]).optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Hasura GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @param logger - Optional logger to use for logging the requests\n * @returns An object containing:\n * - client: The configured GraphQL client instance\n * - graphql: The initialized gql.tada function for type-safe queries\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraClient } from '@settlemint/sdk-hasura';\n * import type { introspection } from \"@schemas/hasura-env\";\n * import { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createHasuraClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * timestamp: string;\n * timestampz: string;\n * uuid: string;\n * date: string;\n * time: string;\n * jsonb: string;\n * numeric: string;\n * interval: string;\n * geometry: string;\n * geography: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * }, {\n * fetch: requestLogger(logger, \"hasura\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetUsers {\n * users {\n * id\n * name\n * email\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createHasuraClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n logger?: Logger,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n }),\n fetch: (logger ? requestLogger(logger, \"hasura\", fetch) : fetch) as typeof fetch,\n }),\n graphql,\n };\n}\n\n/**\n * Creates a Hasura Metadata client\n *\n * @param options - Configuration options for the client\n * @param logger - Optional logger to use for logging the requests\n * @returns A function that can be used to make requests to the Hasura Metadata API\n * @throws Will throw an error if the options fail validation against ClientOptionsSchema\n * @example\n * import { createHasuraMetadataClient } from '@settlemint/sdk-hasura';\n *\n * const client = createHasuraMetadataClient({\n * instance: process.env.SETTLEMINT_HASURA_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,\n * });\n *\n * const result = await client({\n * type: \"pg_get_source_tables\",\n * args: {\n * source: \"default\",\n * },\n * });\n */\nexport function createHasuraMetadataClient(options: ClientOptions, logger?: Logger) {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const baseUrl = extractBaseUrlBeforeSegment(options.instance, \"/v1/graphql\");\n const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();\n const fetchInstance = logger ? requestLogger(logger, \"hasura\", fetch) : fetch;\n\n return async <T>(query: object): Promise<{ ok: boolean; data: T }> => {\n const response = await fetchInstance(queryEndpoint, {\n method: \"POST\",\n headers: appendHeaders(\n { \"Content-Type\": \"application/json\" },\n {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-hasura-admin-secret\": validatedOptions.adminSecret,\n },\n ),\n body: JSON.stringify(query),\n });\n\n if (!response.ok) {\n return { ok: false, data: (await response.json()) as T };\n }\n\n return { ok: true, data: (await response.json()) as T };\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\nexport { trackAllTables } from \"./utils/track-all-tables.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,eACpBA,cACAC,QACAC,eAGI;CACF,gBAAgB;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+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.5.
|
|
4
|
+
"version": "2.5.1-pra786220d",
|
|
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.5.
|
|
69
|
+
"@settlemint/sdk-utils": "2.5.1-pra786220d",
|
|
70
70
|
"graphql-request": "^7",
|
|
71
71
|
"zod": "^3.25.0",
|
|
72
72
|
"drizzle-orm": "^0.44.0",
|