@settlemint/sdk-thegraph 2.5.1 → 2.5.2-main3b71dc68

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 CHANGED
@@ -52,7 +52,7 @@ The SDK offers a type-safe interface for all TheGraph operations, with comprehen
52
52
 
53
53
  > **createTheGraphClient**\<`Setup`\>(`options`, `clientOptions?`): `object`
54
54
 
55
- Defined in: [sdk/thegraph/src/thegraph.ts:91](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L91)
55
+ Defined in: [sdk/thegraph/src/thegraph.ts:91](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L91)
56
56
 
57
57
  Creates a TheGraph GraphQL client with proper type safety using gql.tada
58
58
 
@@ -83,8 +83,8 @@ An object containing:
83
83
 
84
84
  | Name | Type | Defined in |
85
85
  | ------ | ------ | ------ |
86
- | `client` | `GraphQLClient` | [sdk/thegraph/src/thegraph.ts:95](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L95) |
87
- | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/thegraph/src/thegraph.ts:96](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L96) |
86
+ | `client` | `GraphQLClient` | [sdk/thegraph/src/thegraph.ts:95](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L95) |
87
+ | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/thegraph/src/thegraph.ts:96](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L96) |
88
88
 
89
89
  ##### Throws
90
90
 
@@ -137,7 +137,7 @@ const result = await client.request(query);
137
137
 
138
138
  > **ClientOptions** = `object`
139
139
 
140
- Defined in: [sdk/thegraph/src/thegraph.ts:26](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L26)
140
+ Defined in: [sdk/thegraph/src/thegraph.ts:26](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L26)
141
141
 
142
142
  Type definition for client options derived from the ClientOptionsSchema
143
143
 
@@ -145,10 +145,10 @@ Type definition for client options derived from the ClientOptionsSchema
145
145
 
146
146
  | Name | Type | Defined in |
147
147
  | ------ | ------ | ------ |
148
- | <a id="accesstoken"></a> `accessToken?` | `string` | [sdk/thegraph/src/thegraph.ts:18](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L18) |
149
- | <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | [sdk/thegraph/src/thegraph.ts:20](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L20) |
150
- | <a id="instances"></a> `instances` | `string`[] | [sdk/thegraph/src/thegraph.ts:17](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L17) |
151
- | <a id="subgraphname"></a> `subgraphName` | `string` | [sdk/thegraph/src/thegraph.ts:19](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L19) |
148
+ | <a id="accesstoken"></a> `accessToken?` | `string` | [sdk/thegraph/src/thegraph.ts:18](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L18) |
149
+ | <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | [sdk/thegraph/src/thegraph.ts:20](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L20) |
150
+ | <a id="instances"></a> `instances` | `string`[] | [sdk/thegraph/src/thegraph.ts:17](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L17) |
151
+ | <a id="subgraphname"></a> `subgraphName` | `string` | [sdk/thegraph/src/thegraph.ts:19](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L19) |
152
152
 
153
153
  ***
154
154
 
@@ -156,7 +156,7 @@ Type definition for client options derived from the ClientOptionsSchema
156
156
 
157
157
  > **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
158
158
 
159
- Defined in: [sdk/thegraph/src/thegraph.ts:11](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L11)
159
+ Defined in: [sdk/thegraph/src/thegraph.ts:11](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L11)
160
160
 
161
161
  Type definition for GraphQL client configuration options
162
162
 
@@ -166,7 +166,7 @@ Type definition for GraphQL client configuration options
166
166
 
167
167
  > `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
168
168
 
169
- Defined in: [sdk/thegraph/src/thegraph.ts:16](https://github.com/settlemint/sdk/blob/v2.5.1/sdk/thegraph/src/thegraph.ts#L16)
169
+ Defined in: [sdk/thegraph/src/thegraph.ts:16](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/thegraph/src/thegraph.ts#L16)
170
170
 
171
171
  Schema for validating client options for the TheGraph client.
172
172
 
@@ -1,7 +1,7 @@
1
1
  /* SettleMint The Graph SDK - Indexing Protocol */
2
2
  import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
3
3
  import { GraphQLClient } from "graphql-request";
4
- import { z } from "zod/v4";
4
+ import { z } from "zod";
5
5
 
6
6
  //#region src/thegraph.d.ts
7
7
  /**
@@ -81,5 +81,5 @@ declare function createTheGraphClient<const Setup extends AbstractSetupSchema>(o
81
81
  graphql: initGraphQLTada<Setup>;
82
82
  };
83
83
  //#endregion
84
- export { ClientOptions, ClientOptionsSchema, FragmentOf, RequestConfig, ResultOf, VariablesOf, createTheGraphClient, readFragment };
84
+ export { ClientOptions, ClientOptionsSchema, type FragmentOf, RequestConfig, type ResultOf, type VariablesOf, createTheGraphClient, readFragment };
85
85
  //# sourceMappingURL=thegraph.d.ts.map
@@ -4,7 +4,7 @@ import { ensureServer } from "@settlemint/sdk-utils/runtime";
4
4
  import { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from "@settlemint/sdk-utils/validation";
5
5
  import { initGraphQLTada, readFragment } from "gql.tada";
6
6
  import { GraphQLClient } from "graphql-request";
7
- import { z } from "zod/v4";
7
+ import { z } from "zod";
8
8
 
9
9
  //#region src/thegraph.ts
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"thegraph.js","names":["options: ClientOptions","instance","clientOptions?: RequestConfig"],"sources":["../../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,WAAW,EAAE,MAAM,gBAAgB;CACnC,aAAa,6BAA6B,UAAU;CACpD,cAAc,EAAE,QAAQ;CACxB,OAAO,EAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWA,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,eAAc;CACd,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,iBAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAI,cAAc,SAAS;GACjC,GAAG;GACH,SAAS,cAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
1
+ {"version":3,"file":"thegraph.js","names":["options: ClientOptions","instance","clientOptions?: RequestConfig"],"sources":["../../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,WAAW,EAAE,MAAM,gBAAgB;CACnC,aAAa,6BAA6B,UAAU;CACpD,cAAc,EAAE,QAAQ;CACxB,OAAO,EAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWA,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,eAAc;CACd,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,iBAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAI,cAAc,SAAS;GACjC,GAAG;GACH,SAAS,cAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
package/dist/thegraph.cjs CHANGED
@@ -27,17 +27,17 @@ const __settlemint_sdk_utils_runtime = __toESM(require("@settlemint/sdk-utils/ru
27
27
  const __settlemint_sdk_utils_validation = __toESM(require("@settlemint/sdk-utils/validation"));
28
28
  const gql_tada = __toESM(require("gql.tada"));
29
29
  const graphql_request = __toESM(require("graphql-request"));
30
- const zod_v4 = __toESM(require("zod/v4"));
30
+ const zod = __toESM(require("zod"));
31
31
 
32
32
  //#region src/thegraph.ts
33
33
  /**
34
34
  * Schema for validating client options for the TheGraph client.
35
35
  */
36
- const ClientOptionsSchema = zod_v4.z.object({
37
- instances: zod_v4.z.array(__settlemint_sdk_utils_validation.UrlOrPathSchema),
36
+ const ClientOptionsSchema = zod.z.object({
37
+ instances: zod.z.array(__settlemint_sdk_utils_validation.UrlOrPathSchema),
38
38
  accessToken: __settlemint_sdk_utils_validation.ApplicationAccessTokenSchema.optional(),
39
- subgraphName: zod_v4.z.string(),
40
- cache: zod_v4.z.enum([
39
+ subgraphName: zod.z.string(),
40
+ cache: zod.z.enum([
41
41
  "default",
42
42
  "force-cache",
43
43
  "no-cache",
@@ -1 +1 @@
1
- {"version":3,"file":"thegraph.cjs","names":["UrlOrPathSchema","options: ClientOptions","instance","clientOptions?: RequestConfig","GraphQLClient"],"sources":["../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,sBAAsB,SAAE,OAAO;CAC1C,WAAW,SAAE,MAAMA,kDAAgB;CACnC,aAAa,+DAA6B,UAAU;CACpD,cAAc,SAAE,QAAQ;CACxB,OAAO,SAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWC,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,mDAAc;CACd,MAAM,mBAAmB,gDAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,+BAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAIC,8BAAc,SAAS;GACjC,GAAG;GACH,SAAS,+CAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
1
+ {"version":3,"file":"thegraph.cjs","names":["UrlOrPathSchema","options: ClientOptions","instance","clientOptions?: RequestConfig","GraphQLClient"],"sources":["../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,sBAAsB,MAAE,OAAO;CAC1C,WAAW,MAAE,MAAMA,kDAAgB;CACnC,aAAa,+DAA6B,UAAU;CACpD,cAAc,MAAE,QAAQ;CACxB,OAAO,MAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWC,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,mDAAc;CACd,MAAM,mBAAmB,gDAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,+BAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAIC,8BAAc,SAAS;GACjC,GAAG;GACH,SAAS,+CAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
@@ -1,7 +1,7 @@
1
1
  /* SettleMint The Graph SDK - Indexing Protocol */
2
2
  import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
3
3
  import { GraphQLClient } from "graphql-request";
4
- import { z } from "zod/v4";
4
+ import { z } from "zod";
5
5
 
6
6
  //#region src/thegraph.d.ts
7
7
  /**
@@ -81,5 +81,5 @@ declare function createTheGraphClient<const Setup extends AbstractSetupSchema>(o
81
81
  graphql: initGraphQLTada<Setup>;
82
82
  };
83
83
  //#endregion
84
- export { ClientOptions, ClientOptionsSchema, FragmentOf, RequestConfig, ResultOf, VariablesOf, createTheGraphClient, readFragment };
84
+ export { ClientOptions, ClientOptionsSchema, type FragmentOf, RequestConfig, type ResultOf, type VariablesOf, createTheGraphClient, readFragment };
85
85
  //# sourceMappingURL=thegraph.d.cts.map
@@ -1,7 +1,7 @@
1
1
  /* SettleMint The Graph SDK - Indexing Protocol */
2
2
  import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
3
3
  import { GraphQLClient } from "graphql-request";
4
- import { z } from "zod/v4";
4
+ import { z } from "zod";
5
5
 
6
6
  //#region src/thegraph.d.ts
7
7
  /**
@@ -81,5 +81,5 @@ declare function createTheGraphClient<const Setup extends AbstractSetupSchema>(o
81
81
  graphql: initGraphQLTada<Setup>;
82
82
  };
83
83
  //#endregion
84
- export { ClientOptions, ClientOptionsSchema, FragmentOf, RequestConfig, ResultOf, VariablesOf, createTheGraphClient, readFragment };
84
+ export { ClientOptions, ClientOptionsSchema, type FragmentOf, RequestConfig, type ResultOf, type VariablesOf, createTheGraphClient, readFragment };
85
85
  //# sourceMappingURL=thegraph.d.ts.map
package/dist/thegraph.js CHANGED
@@ -4,7 +4,7 @@ import { ensureServer } from "@settlemint/sdk-utils/runtime";
4
4
  import { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from "@settlemint/sdk-utils/validation";
5
5
  import { initGraphQLTada, readFragment } from "gql.tada";
6
6
  import { GraphQLClient } from "graphql-request";
7
- import { z } from "zod/v4";
7
+ import { z } from "zod";
8
8
 
9
9
  //#region src/thegraph.ts
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"thegraph.js","names":["options: ClientOptions","instance","clientOptions?: RequestConfig"],"sources":["../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,WAAW,EAAE,MAAM,gBAAgB;CACnC,aAAa,6BAA6B,UAAU;CACpD,cAAc,EAAE,QAAQ;CACxB,OAAO,EAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWA,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,eAAc;CACd,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,iBAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAI,cAAc,SAAS;GACjC,GAAG;GACH,SAAS,cAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
1
+ {"version":3,"file":"thegraph.js","names":["options: ClientOptions","instance","clientOptions?: RequestConfig"],"sources":["../src/thegraph.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\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\";\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 TheGraph client.\n */\nexport const ClientOptionsSchema = z.object({\n instances: z.array(UrlOrPathSchema),\n accessToken: ApplicationAccessTokenSchema.optional(),\n subgraphName: 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 * Constructs the full URL for TheGraph GraphQL API based on the provided options\n *\n * @param options - The client options for configuring TheGraph client\n * @returns The complete GraphQL API URL as a string\n * @throws Will throw an error if no matching instance is found for the specified subgraph\n */\nfunction getFullUrl(options: ClientOptions): string {\n const instance = options.instances.find((instance) => instance.endsWith(`/${options.subgraphName}`));\n if (!instance) {\n throw new Error(`Instance for subgraph ${options.subgraphName} not found`);\n }\n return new URL(instance).toString();\n}\n\n/**\n * Creates a TheGraph GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client including instance URLs,\n * access token and subgraph name\n * @param clientOptions - Optional GraphQL client configuration options\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 { createTheGraphClient } from '@settlemint/sdk-thegraph';\n * import type { introspection } from '@schemas/the-graph-env-kits';\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createTheGraphClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * Bytes: string;\n * Int8: string;\n * BigInt: string;\n * BigDecimal: string;\n * Timestamp: string;\n * };\n * }>({\n * instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * subgraphName: 'kits'\n * }, {\n * fetch: requestLogger(logger, \"the-graph-kits\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query SearchAssets {\n * assets {\n * id\n * name\n * symbol\n * }\n * }\n * `);\n *\n * const result = await client.request(query);\n */\nexport function createTheGraphClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\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 = getFullUrl(validatedOptions);\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\nexport { readFragment } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,WAAW,EAAE,MAAM,gBAAgB;CACnC,aAAa,6BAA6B,UAAU;CACpD,cAAc,EAAE,QAAQ;CACxB,OAAO,EAAE,KAAK;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAS,EAAC,CAAC,UAAU;AACzG,EAAC;;;;;;;;AAcF,SAAS,WAAWA,SAAgC;CAClD,MAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,eAAa,WAAS,UAAU,GAAG,QAAQ,aAAa,EAAE,CAAC;AACpG,MAAK,UAAU;AACb,QAAM,IAAI,OAAO,wBAAwB,QAAQ,aAAa;CAC/D;AACD,QAAO,IAAI,IAAI,UAAU,UAAU;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgB,qBACdD,SACAE,eAIA;AACA,eAAc;CACd,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,iBAAwB;CACxC,MAAM,UAAU,WAAW,iBAAiB;AAE5C,QAAO;EACL,QAAQ,IAAI,cAAc,SAAS;GACjC,GAAG;GACH,SAAS,cAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@settlemint/sdk-thegraph",
3
3
  "description": "TheGraph integration module for SettleMint SDK, enabling querying and indexing of blockchain data through subgraphs",
4
- "version": "2.5.1",
4
+ "version": "2.5.2-main3b71dc68",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -54,9 +54,9 @@
54
54
  "devDependencies": {},
55
55
  "dependencies": {
56
56
  "gql.tada": "^1",
57
- "@settlemint/sdk-utils": "2.5.1",
57
+ "@settlemint/sdk-utils": "2.5.2-main3b71dc68",
58
58
  "graphql-request": "^7",
59
- "zod": "^3.25.0"
59
+ "zod": "^4"
60
60
  },
61
61
  "peerDependencies": {},
62
62
  "engines": {