@settlemint/sdk-thegraph 2.3.1-prfcd3c3b5 → 2.3.2

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:90](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L90)
55
+ Defined in: [sdk/thegraph/src/thegraph.ts:90](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L90)
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:94](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L94) |
87
- | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/thegraph/src/thegraph.ts:95](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L95) |
86
+ | `client` | `GraphQLClient` | [sdk/thegraph/src/thegraph.ts:94](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L94) |
87
+ | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/thegraph/src/thegraph.ts:95](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L95) |
88
88
 
89
89
  ##### Throws
90
90
 
@@ -135,28 +135,19 @@ const result = await client.request(query);
135
135
 
136
136
  #### ClientOptions
137
137
 
138
- > **ClientOptions** = `object`
138
+ > **ClientOptions** = `z.infer`\<*typeof* [`ClientOptionsSchema`](#clientoptionsschema)\>
139
139
 
140
- Defined in: [sdk/thegraph/src/thegraph.ts:25](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L25)
140
+ Defined in: [sdk/thegraph/src/thegraph.ts:25](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L25)
141
141
 
142
142
  Type definition for client options derived from the ClientOptionsSchema
143
143
 
144
- ##### Type declaration
145
-
146
- | Name | Type | Default value | Defined in |
147
- | ------ | ------ | ------ | ------ |
148
- | <a id="accesstoken"></a> `accessToken` | `string` | `ApplicationAccessTokenSchema` | [sdk/thegraph/src/thegraph.ts:17](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L17) |
149
- | <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/thegraph/src/thegraph.ts:19](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L19) |
150
- | <a id="instances"></a> `instances` | `string`[] | - | [sdk/thegraph/src/thegraph.ts:16](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L16) |
151
- | <a id="subgraphname"></a> `subgraphName` | `string` | - | [sdk/thegraph/src/thegraph.ts:18](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L18) |
152
-
153
144
  ***
154
145
 
155
146
  #### RequestConfig
156
147
 
157
148
  > **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
158
149
 
159
- Defined in: [sdk/thegraph/src/thegraph.ts:10](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L10)
150
+ Defined in: [sdk/thegraph/src/thegraph.ts:10](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L10)
160
151
 
161
152
  Type definition for GraphQL client configuration options
162
153
 
@@ -164,9 +155,9 @@ Type definition for GraphQL client configuration options
164
155
 
165
156
  #### ClientOptionsSchema
166
157
 
167
- > `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
158
+ > `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodString`; `cache`: `ZodOptional`\<`ZodEnum`\<\{ `default`: `"default"`; `force-cache`: `"force-cache"`; `no-cache`: `"no-cache"`; `no-store`: `"no-store"`; `only-if-cached`: `"only-if-cached"`; `reload`: `"reload"`; \}\>\>; `instances`: `ZodArray`\<`ZodUnion`\<readonly \[`ZodString`, `ZodString`\]\>\>; `subgraphName`: `ZodString`; \}, `$strip`\>
168
159
 
169
- Defined in: [sdk/thegraph/src/thegraph.ts:15](https://github.com/settlemint/sdk/blob/v2.3.1/sdk/thegraph/src/thegraph.ts#L15)
160
+ Defined in: [sdk/thegraph/src/thegraph.ts:15](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/thegraph/src/thegraph.ts#L15)
170
161
 
171
162
  Schema for validating client options for the TheGraph client.
172
163
 
package/dist/thegraph.cjs CHANGED
@@ -29,13 +29,13 @@ var import_runtime = require("@settlemint/sdk-utils/runtime");
29
29
  var import_validation = require("@settlemint/sdk-utils/validation");
30
30
  var import_gql = require("gql.tada");
31
31
  var import_graphql_request = require("graphql-request");
32
- var import_zod = require("zod");
32
+ var import_v4 = require("zod/v4");
33
33
  var import_gql2 = require("gql.tada");
34
- var ClientOptionsSchema = import_zod.z.object({
35
- instances: import_zod.z.array(import_validation.UrlOrPathSchema),
34
+ var ClientOptionsSchema = import_v4.z.object({
35
+ instances: import_v4.z.array(import_validation.UrlOrPathSchema),
36
36
  accessToken: import_validation.ApplicationAccessTokenSchema,
37
- subgraphName: import_zod.z.string(),
38
- cache: import_zod.z.enum(["default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload"]).optional()
37
+ subgraphName: import_v4.z.string(),
38
+ cache: import_v4.z.enum(["default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload"]).optional()
39
39
  });
40
40
  function getFullUrl(options) {
41
41
  const instance = options.instances.find((instance2) => instance2.endsWith(`/${options.subgraphName}`));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/thegraph.ts"],"sourcesContent":["import { 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,\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: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,wBAAwE;AACxE,iBAA0D;AAC1D,6BAA8B;AAC9B,iBAAkB;AA6GlB,IAAAA,cAA6B;AAnGtB,IAAM,sBAAsB,aAAE,OAAO;AAAA,EAC1C,WAAW,aAAE,MAAM,iCAAe;AAAA,EAClC,aAAa;AAAA,EACb,cAAc,aAAE,OAAO;AAAA,EACvB,OAAO,aAAE,KAAK,CAAC,WAAW,eAAe,YAAY,YAAY,kBAAkB,QAAQ,CAAC,EAAE,SAAS;AACzG,CAAC;AAcD,SAAS,WAAW,SAAgC;AAClD,QAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,cAAaA,UAAS,SAAS,IAAI,QAAQ,YAAY,EAAE,CAAC;AACnG,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,yBAAyB,QAAQ,YAAY,YAAY;AAAA,EAC3E;AACA,SAAO,IAAI,IAAI,QAAQ,EAAE,SAAS;AACpC;AAkDO,SAAS,qBACd,SACA,eAIA;AACA,mCAAa;AACb,QAAM,uBAAmB,4BAAS,qBAAqB,OAAO;AAC9D,QAAM,cAAU,4BAAuB;AACvC,QAAM,UAAU,WAAW,gBAAgB;AAE3C,SAAO;AAAA,IACL,QAAQ,IAAI,qCAAc,SAAS;AAAA,MACjC,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,eAAe,WAAW,CAAC;AAAA,QAC/B,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["import_gql","instance"]}
1
+ {"version":3,"sources":["../src/thegraph.ts"],"sourcesContent":["import { 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,\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: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,wBAAwE;AACxE,iBAA0D;AAC1D,6BAA8B;AAC9B,gBAAkB;AA6GlB,IAAAA,cAA6B;AAnGtB,IAAM,sBAAsB,YAAE,OAAO;AAAA,EAC1C,WAAW,YAAE,MAAM,iCAAe;AAAA,EAClC,aAAa;AAAA,EACb,cAAc,YAAE,OAAO;AAAA,EACvB,OAAO,YAAE,KAAK,CAAC,WAAW,eAAe,YAAY,YAAY,kBAAkB,QAAQ,CAAC,EAAE,SAAS;AACzG,CAAC;AAcD,SAAS,WAAW,SAAgC;AAClD,QAAM,WAAW,QAAQ,UAAU,KAAK,CAACC,cAAaA,UAAS,SAAS,IAAI,QAAQ,YAAY,EAAE,CAAC;AACnG,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,yBAAyB,QAAQ,YAAY,YAAY;AAAA,EAC3E;AACA,SAAO,IAAI,IAAI,QAAQ,EAAE,SAAS;AACpC;AAkDO,SAAS,qBACd,SACA,eAIA;AACA,mCAAa;AACb,QAAM,uBAAmB,4BAAS,qBAAqB,OAAO;AAC9D,QAAM,cAAU,4BAAuB;AACvC,QAAM,UAAU,WAAW,gBAAgB;AAE3C,SAAO;AAAA,IACL,QAAQ,IAAI,qCAAc,SAAS;AAAA,MACjC,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,eAAe,WAAW,CAAC;AAAA,QAC/B,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["import_gql","instance"]}
@@ -1,7 +1,7 @@
1
1
  import { AbstractSetupSchema, initGraphQLTada } from 'gql.tada';
2
2
  export { FragmentOf, ResultOf, VariablesOf, readFragment } from 'gql.tada';
3
3
  import { GraphQLClient } from 'graphql-request';
4
- import { z } from 'zod';
4
+ import { z } from 'zod/v4';
5
5
 
6
6
  /**
7
7
  * Type definition for GraphQL client configuration options
@@ -11,21 +11,18 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
11
11
  * Schema for validating client options for the TheGraph client.
12
12
  */
13
13
  declare const ClientOptionsSchema: z.ZodObject<{
14
- instances: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>, "many">;
14
+ instances: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
15
15
  accessToken: z.ZodString;
16
16
  subgraphName: z.ZodString;
17
- cache: z.ZodOptional<z.ZodEnum<["default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload"]>>;
18
- }, "strip", z.ZodTypeAny, {
19
- instances: string[];
20
- accessToken: string;
21
- subgraphName: string;
22
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
23
- }, {
24
- instances: string[];
25
- accessToken: string;
26
- subgraphName: string;
27
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
28
- }>;
17
+ cache: z.ZodOptional<z.ZodEnum<{
18
+ default: "default";
19
+ "force-cache": "force-cache";
20
+ "no-cache": "no-cache";
21
+ "no-store": "no-store";
22
+ "only-if-cached": "only-if-cached";
23
+ reload: "reload";
24
+ }>>;
25
+ }, z.core.$strip>;
29
26
  /**
30
27
  * Type definition for client options derived from the ClientOptionsSchema
31
28
  */
@@ -1,7 +1,7 @@
1
1
  import { AbstractSetupSchema, initGraphQLTada } from 'gql.tada';
2
2
  export { FragmentOf, ResultOf, VariablesOf, readFragment } from 'gql.tada';
3
3
  import { GraphQLClient } from 'graphql-request';
4
- import { z } from 'zod';
4
+ import { z } from 'zod/v4';
5
5
 
6
6
  /**
7
7
  * Type definition for GraphQL client configuration options
@@ -11,21 +11,18 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
11
11
  * Schema for validating client options for the TheGraph client.
12
12
  */
13
13
  declare const ClientOptionsSchema: z.ZodObject<{
14
- instances: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>, "many">;
14
+ instances: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
15
15
  accessToken: z.ZodString;
16
16
  subgraphName: z.ZodString;
17
- cache: z.ZodOptional<z.ZodEnum<["default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload"]>>;
18
- }, "strip", z.ZodTypeAny, {
19
- instances: string[];
20
- accessToken: string;
21
- subgraphName: string;
22
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
23
- }, {
24
- instances: string[];
25
- accessToken: string;
26
- subgraphName: string;
27
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
28
- }>;
17
+ cache: z.ZodOptional<z.ZodEnum<{
18
+ default: "default";
19
+ "force-cache": "force-cache";
20
+ "no-cache": "no-cache";
21
+ "no-store": "no-store";
22
+ "only-if-cached": "only-if-cached";
23
+ reload: "reload";
24
+ }>>;
25
+ }, z.core.$strip>;
29
26
  /**
30
27
  * Type definition for client options derived from the ClientOptionsSchema
31
28
  */
package/dist/thegraph.mjs CHANGED
@@ -3,7 +3,7 @@ import { ensureServer } from "@settlemint/sdk-utils/runtime";
3
3
  import { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from "@settlemint/sdk-utils/validation";
4
4
  import { initGraphQLTada } from "gql.tada";
5
5
  import { GraphQLClient } from "graphql-request";
6
- import { z } from "zod";
6
+ import { z } from "zod/v4";
7
7
  import { readFragment } from "gql.tada";
8
8
  var ClientOptionsSchema = z.object({
9
9
  instances: z.array(UrlOrPathSchema),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/thegraph.ts"],"sourcesContent":["import { 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,\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: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B,iBAAiB,gBAAgB;AACxE,SAAmC,uBAAuB;AAC1D,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AA6GlB,SAAS,oBAAoB;AAnGtB,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,WAAW,EAAE,MAAM,eAAe;AAAA,EAClC,aAAa;AAAA,EACb,cAAc,EAAE,OAAO;AAAA,EACvB,OAAO,EAAE,KAAK,CAAC,WAAW,eAAe,YAAY,YAAY,kBAAkB,QAAQ,CAAC,EAAE,SAAS;AACzG,CAAC;AAcD,SAAS,WAAW,SAAgC;AAClD,QAAM,WAAW,QAAQ,UAAU,KAAK,CAACA,cAAaA,UAAS,SAAS,IAAI,QAAQ,YAAY,EAAE,CAAC;AACnG,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,yBAAyB,QAAQ,YAAY,YAAY;AAAA,EAC3E;AACA,SAAO,IAAI,IAAI,QAAQ,EAAE,SAAS;AACpC;AAkDO,SAAS,qBACd,SACA,eAIA;AACA,eAAa;AACb,QAAM,mBAAmB,SAAS,qBAAqB,OAAO;AAC9D,QAAM,UAAU,gBAAuB;AACvC,QAAM,UAAU,WAAW,gBAAgB;AAE3C,SAAO;AAAA,IACL,QAAQ,IAAI,cAAc,SAAS;AAAA,MACjC,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,eAAe,WAAW,CAAC;AAAA,QAC/B,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["instance"]}
1
+ {"version":3,"sources":["../src/thegraph.ts"],"sourcesContent":["import { 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,\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: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B,iBAAiB,gBAAgB;AACxE,SAAmC,uBAAuB;AAC1D,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AA6GlB,SAAS,oBAAoB;AAnGtB,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,WAAW,EAAE,MAAM,eAAe;AAAA,EAClC,aAAa;AAAA,EACb,cAAc,EAAE,OAAO;AAAA,EACvB,OAAO,EAAE,KAAK,CAAC,WAAW,eAAe,YAAY,YAAY,kBAAkB,QAAQ,CAAC,EAAE,SAAS;AACzG,CAAC;AAcD,SAAS,WAAW,SAAgC;AAClD,QAAM,WAAW,QAAQ,UAAU,KAAK,CAACA,cAAaA,UAAS,SAAS,IAAI,QAAQ,YAAY,EAAE,CAAC;AACnG,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,yBAAyB,QAAQ,YAAY,YAAY;AAAA,EAC3E;AACA,SAAO,IAAI,IAAI,QAAQ,EAAE,SAAS;AACpC;AAkDO,SAAS,qBACd,SACA,eAIA;AACA,eAAa;AACb,QAAM,mBAAmB,SAAS,qBAAqB,OAAO;AAC9D,QAAM,UAAU,gBAAuB;AACvC,QAAM,UAAU,WAAW,gBAAgB;AAE3C,SAAO;AAAA,IACL,QAAQ,IAAI,cAAc,SAAS;AAAA,MACjC,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,eAAe,WAAW,CAAC;AAAA,QAC/B,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["instance"]}
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.3.1-prfcd3c3b5",
4
+ "version": "2.3.2",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -52,9 +52,9 @@
52
52
  "devDependencies": {},
53
53
  "dependencies": {
54
54
  "gql.tada": "^1",
55
- "@settlemint/sdk-utils": "2.3.1-prfcd3c3b5",
55
+ "@settlemint/sdk-utils": "2.3.2",
56
56
  "graphql-request": "^7",
57
- "zod": "^3"
57
+ "zod": "^3.25.0"
58
58
  },
59
59
  "peerDependencies": {},
60
60
  "engines": {