eth-graph-query 2.0.21 → 3.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phạm Hồng Phúc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,25 +1,26 @@
1
1
  # eth-graph-query
2
2
 
3
- A lightweight and flexible library for building [The Graph (GraphQL)](https://thegraph.com/) queries using simple JSON objects. Eliminate the need for complex string concatenation and maintain type-safe queries.
3
+ A lightweight GraphQL query builder and client with first-class support for The Graph. Build queries using JSON, avoid string concatenation, and keep strong TypeScript types.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/eth-graph-query.svg)](https://www.npmjs.com/package/eth-graph-query)
6
6
  [![license](https://img.shields.io/npm/l/eth-graph-query.svg)](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/LICENSE)
7
7
 
8
8
  ---
9
9
 
10
- ## 🚀 Features
10
+ ## Features
11
11
 
12
- - **JSON to GraphQL**: Convert nested JSON structures into valid GraphQL query strings.
13
- - **Multiple Collections**: Query multiple collections in a single HTTP request.
14
- - **Deep Nesting**: Support for nested collection queries and entity relationships.
15
- - **Advanced Filtering**: Full support for The Graph's operators (`_gt`, `_in`, `_contains`, etc.) via `$` prefix.
16
- - **Inline Fragments**: Support for GraphQL inline fragments (`... on Type`).
17
- - **TypeScript First**: Full type definitions for parameters, filters, and metadata.
18
- - **Metadata Support**: Easily fetch subgraph metadata (`_meta`).
12
+ - JSON to GraphQL: Convert nested JSON structures into valid GraphQL query strings.
13
+ - Multiple collections: Query multiple collections in a single HTTP request.
14
+ - Deep nesting: Support nested collection queries and entity relationships.
15
+ - Advanced filtering: The Graph operators via `$` prefix (e.g., `$gt`, `$in`, `$contains`).
16
+ - Inline fragments: Support GraphQL inline fragments (`... on Type`).
17
+ - Generic GraphQL args: Pass schema-agnostic arguments via `params.args`.
18
+ - TypeScript first: Full type definitions for parameters, filters, and metadata.
19
+ - Metadata support: Fetch subgraph metadata (`_meta`) when using The Graph.
19
20
 
20
21
  ---
21
22
 
22
- ## 📦 Installation
23
+ ## Installation
23
24
 
24
25
  ```shell
25
26
  # npm
@@ -29,23 +30,28 @@ npm install eth-graph-query
29
30
  yarn add eth-graph-query
30
31
 
31
32
  # bun
32
- bun install eth-graph-query
33
+ bun add eth-graph-query
33
34
  ```
34
35
 
35
36
  ---
36
37
 
37
- ## 💡 Usage
38
-
39
- ### 1. Initialize the Client
38
+ ## Quick Start
40
39
 
41
40
  ```typescript
42
41
  import { EthGraphQuery } from 'eth-graph-query';
43
42
 
44
43
  const rootUrl = 'https://api.thegraph.com/subgraphs/name/username/subgraph-name';
45
- const client = new EthGraphQuery(rootUrl);
44
+ const client = new EthGraphQuery(rootUrl, {
45
+ headers: { Authorization: 'Bearer <token>' },
46
+ timeoutMs: 10_000,
47
+ });
46
48
  ```
47
49
 
48
- ### 2. Single Collection Query
50
+ ---
51
+
52
+ ## Usage
53
+
54
+ ### 1. Single Collection Query (The Graph)
49
55
 
50
56
  ```typescript
51
57
  const result = await client.query({
@@ -60,9 +66,7 @@ const result = await client.query({
60
66
  });
61
67
  ```
62
68
 
63
- ### 3. Multiple Collections Query
64
-
65
- Fetch data from multiple collections in a single round-trip.
69
+ ### 2. Multiple Collections Query
66
70
 
67
71
  ```typescript
68
72
  const result = await client.multipleQuery([
@@ -77,9 +81,7 @@ const result = await client.multipleQuery([
77
81
  ]);
78
82
  ```
79
83
 
80
- ### 4. Advanced Nested Query & Filters
81
-
82
- Build complex queries with nested collections and operators.
84
+ ### 3. Advanced Nested Query & Filters (The Graph)
83
85
 
84
86
  ```typescript
85
87
  const result = await client.query({
@@ -107,15 +109,42 @@ const result = await client.query({
107
109
  });
108
110
  ```
109
111
 
112
+ ### 4. Generic GraphQL Arguments (Schema-Agnostic)
113
+
114
+ Use `params.args` to pass arbitrary GraphQL arguments for non-The-Graph schemas.
115
+
116
+ ```typescript
117
+ const result = await client.query({
118
+ collection: 'users',
119
+ params: {
120
+ args: {
121
+ first: 20,
122
+ orderBy: 'name',
123
+ filter: { active: true },
124
+ },
125
+ elements: ['id', 'name'],
126
+ },
127
+ });
128
+ ```
129
+
130
+ ---
131
+
132
+ ## API Reference
133
+
134
+ Documentation for all functions and types can be found in the API docs:
135
+
136
+ - [API Docs](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/documents/api.md)
137
+
110
138
  ---
111
139
 
112
- ## 📘 API Reference
140
+ ## Notes
113
141
 
114
- Documentation for all functions and types can be found in the [API Docs](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/documents/api.md).
142
+ - This library uses the native `fetch` API (Node 20+). No Axios dependency.
143
+ - The Graph-specific features (`where`, `_meta`, `block`) remain supported.
115
144
 
116
145
  ---
117
146
 
118
- ## 🛠 For Developers
147
+ ## For Developers
119
148
 
120
149
  ### Run Tests
121
150
 
@@ -125,11 +154,13 @@ npm run test
125
154
 
126
155
  ---
127
156
 
128
- ## 📜 License
157
+ ## License
158
+
159
+ This project is licensed under the MIT License. See [LICENSE](LICENSE).
129
160
 
130
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
161
+ ---
131
162
 
132
- ## 🔗 References
163
+ ## References
133
164
 
134
165
  - [The Graph Documentation](https://thegraph.com/docs/)
135
166
  - [GraphQL Specification](https://spec.graphql.org)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("axios"),f={Accept:"application/json","Content-Type":"application/json"};function d(h){return h.data}class b{root;config;constructor(t,e={}){this.root=t,this.config={...e,headers:{...f,...e.headers||{}}}}async request(t,e,r,s){const n=`${this.root}${e}`,i={...this.config,...s},c=await(t==="get"||t==="delete"?y[t](n,i):y[t](n,r,i));return d(c)}async get(t,e){return this.request("get",t,void 0,e)}async post(t,e,r){return this.request("post",t,e,r)}async put(t,e,r){return this.request("put",t,e,r)}async del(t,e){return this.request("delete",t,void 0,e)}}const p=["contains","contains_nocase","ends_with","end_with_nocase","starts_with","starts_with_nocase","not_contains","not_contains_nocase","not_ends_with","not_ends_with_nocase","not_starts_with","not_starts_with_nocase","gt","gte","lt","lte","not","in","not_in"],$=1e3,g=5e3;class a{static buildJsonQuery(t){const e=[];for(const r in t){const s=t[r];if(s!==void 0)if(s===null)e.push(`${r}: null`);else if(Array.isArray(s)){const n=s;e.push(`${r}: [${n.map(i=>typeof i=="string"?`"${i}"`:i).join(", ")}]`)}else if(typeof s=="string")e.push(`${r}: "${s}"`);else if(typeof s=="object"){const n={},i={},c=s;for(const l in c){const u=c[l];if(l.startsWith("$")){const o=l.slice(1);p.includes(o)?i[`${r}_${o}`]=u:n[l]=u}else n[l]=u}Object.keys(n).length>0&&e.push(`${r}: {${this.buildJsonQuery(n)}}`),Object.keys(i).length>0&&e.push(this.buildJsonQuery(i))}else e.push(`${r}: ${s}`)}return e.join(", ")}static buildElements(t){return t.map(e=>{if(typeof e=="string")return e;const r=e;return this.buildQuery({collection:r.collection,params:r.params})})}static buildMetadata(t){let e="";const r=[];t.blockQuery&&(t.blockQuery.hash&&r.push(`hash: "${t.blockQuery.hash}"`),t.blockQuery.number!==void 0&&r.push(`number: ${t.blockQuery.number}`),t.blockQuery.number_gte!==void 0&&r.push(`number_gte: ${t.blockQuery.number_gte}`));const s=r.join(", ");s.length>0&&(e+=`(block: {${s}})`);const n=[],i=[];if(t.elements){for(const u of t.elements)u==="deployment"||u==="hasIndexingErrors"?n.includes(u)||n.push(u):i.includes(u)||i.push(u);const c=i.join(" ");c.length>0&&n.push(`block{${c}}`);const l=n.join(" ");l.length>0&&(e+=`{${l}}`)}return e.length>0?`_meta${e}`:""}static _buildInlineFragment(t){const e=t.params?.elements?.length?this.buildElements(t.params.elements):["id"];return`... on ${t.collection}{${e.join(" ")}}`}static buildInlineFragments(t){return t.map(e=>this._buildInlineFragment(e)).join(" ")}static buildQuery(t,e){const{collection:r,params:s}=t,n=[];if(s?.id!==void 0&&n.push(`id: ${s.id}`),s?.orderBy&&n.push(`orderBy: ${s.orderBy}`),s?.orderDirection&&n.push(`orderDirection: ${s.orderDirection}`),s?.first!==void 0){const o=Math.max(0,Math.min(s.first,$));n.push(`first: ${o}`)}if(s?.skip!==void 0){const o=Math.max(0,Math.min(s.skip,g));n.push(`skip: ${o}`)}if(s?.where){const o=this.buildJsonQuery(s.where);o.length>0&&n.push(`where: {${o}}`)}if(s?.block){const o=this.buildJsonQuery(s.block);o.length>0&&n.push(`block: {${o}}`)}const i=n.length>0?`(${n.join(", ")})`:"";let c=["id"];s?.elements&&s.elements.length>0&&(c=this.buildElements(s.elements));let l="";s?.inlineFragments&&s.inlineFragments.length>0&&(l=` ${this.buildInlineFragments(s.inlineFragments)}`);const u=`${r}${i} {${c.join(" ")}${l}}`;if(e){const o=this.buildMetadata(e);return o?`${o} ${u}`:u}return u}static buildMultipleQuery(t,e){const s=t.map(n=>this.buildQuery({collection:n.collection,params:n.params})).join(" ");if(e){const n=this.buildMetadata(e);return n?`${n} ${s}`:s}return s}static makeFullQuery(t,e="query"){return`query ${e} {${t}}`}}class Q extends b{queryName;constructor(t,e){super(t,e),this.queryName="query"}async stringQuery(t){const e=await this.post("",{query:t});if(e&&typeof e=="object"&&"errors"in e){const s=e.errors.map(n=>n.message).join("; ");throw new Error(`GraphQL Error: ${s}`)}return e.data}async query(t,e){const r=a.buildQuery(t,e);return this.stringQuery(a.makeFullQuery(r,this.queryName))}async multipleQuery(t,e){const r=a.buildMultipleQuery(t,e);return this.stringQuery(a.makeFullQuery(r,this.queryName))}}exports.EthGraphQuery=Q;exports.OptionKeys=p;exports.QueryBuilder=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y={Accept:"application/json","Content-Type":"application/json"};class f{root;config;constructor(e,t={}){this.root=e,this.config={...t,headers:{...y,...t.headers||{}}}}async request(e,t,s,r){const i=`${this.root}${t}`,o={...this.config,...r,headers:{...this.config.headers||{},...r?.headers||{}}},c=new AbortController,l=o.timeoutMs,u=typeof l=="number"&&l>0?setTimeout(()=>c.abort(),l):void 0;try{const n=await fetch(i,{method:e.toUpperCase(),headers:o.headers,body:e==="get"||e==="delete"?void 0:JSON.stringify(s??{}),signal:o.signal??c.signal});if(!n.ok)throw new Error(`HTTP Error: ${n.status} ${n.statusText}`);return await n.json()}finally{u&&clearTimeout(u)}}async get(e,t){return this.request("get",e,void 0,t)}async post(e,t,s){return this.request("post",e,t,s)}async put(e,t,s){return this.request("put",e,t,s)}async del(e,t){return this.request("delete",e,void 0,t)}}const p=["contains","contains_nocase","ends_with","ends_with_nocase","end_with_nocase","starts_with","starts_with_nocase","not_contains","not_contains_nocase","not_ends_with","not_ends_with_nocase","not_starts_with","not_starts_with_nocase","gt","gte","lt","lte","not","in","not_in"],d=1e3,b=5e3,g=new Set(p);class a{static escapeGraphqlString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}static serializeValue(e){return e===null?"null":typeof e=="string"?`"${this.escapeGraphqlString(e)}"`:`${e}`}static serializeArgValue(e){return e===null||e===void 0?"null":typeof e=="string"?this.serializeValue(e):typeof e=="number"||typeof e=="boolean"?`${e}`:Array.isArray(e)?`[${e.map(s=>this.serializeArgValue(s)).join(", ")}]`:`{${this.buildArgs(e).join(", ")}}`}static buildArgs(e){const t=[];for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const r=e[s];r!==void 0&&t.push(`${s}: ${this.serializeArgValue(r)}`)}return t}static buildJsonQuery(e){const t=[];for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const r=e[s];if(r!==void 0)if(r===null)t.push(`${s}: null`);else if(Array.isArray(r)){const i=r;t.push(`${s}: [${i.map(o=>typeof o=="string"?this.serializeValue(o):o).join(", ")}]`)}else if(typeof r=="string")t.push(`${s}: ${this.serializeValue(r)}`);else if(typeof r=="object"){const i={},o={},c=r;for(const l in c){if(!Object.prototype.hasOwnProperty.call(c,l))continue;const u=c[l];if(l.startsWith("$")){let n=l.slice(1);n==="end_with_nocase"&&(n="ends_with_nocase"),g.has(n)?o[`${s}_${n}`]=u:i[l]=u}else i[l]=u}Object.keys(i).length>0&&t.push(`${s}: {${this.buildJsonQuery(i)}}`),Object.keys(o).length>0&&t.push(this.buildJsonQuery(o))}else t.push(`${s}: ${r}`)}return t.join(", ")}static buildElements(e){return e.map(t=>{if(typeof t=="string")return t;const s=t;return this.buildQuery({collection:s.collection,params:s.params})})}static buildMetadata(e){let t="";const s=[];e.blockQuery&&(e.blockQuery.hash&&s.push(`hash: "${e.blockQuery.hash}"`),e.blockQuery.number!==void 0&&s.push(`number: ${e.blockQuery.number}`),e.blockQuery.number_gte!==void 0&&s.push(`number_gte: ${e.blockQuery.number_gte}`));const r=s.join(", ");r.length>0&&(t+=`(block: {${r}})`);const i=new Set,o=new Set;if(e.elements){for(const u of e.elements)u==="deployment"||u==="hasIndexingErrors"?i.add(u):o.add(u);const c=Array.from(o).join(" ");c.length>0&&i.add(`block{${c}}`);const l=Array.from(i).join(" ");l.length>0&&(t+=`{${l}}`)}return t.length>0?`_meta${t}`:""}static _buildInlineFragment(e){const t=e.params?.elements?.length?this.buildElements(e.params.elements):["id"];return`... on ${e.collection}{${t.join(" ")}}`}static buildInlineFragments(e){return e.map(t=>this._buildInlineFragment(t)).join(" ")}static buildQuery(e,t){const{collection:s,params:r}=e,i=[];if(r?.id!==void 0&&i.push(`id: ${this.serializeValue(r.id)}`),r?.orderBy&&i.push(`orderBy: ${r.orderBy}`),r?.orderDirection&&i.push(`orderDirection: ${r.orderDirection}`),r?.subgraphError&&i.push(`subgraphError: ${r.subgraphError}`),r?.args){const n=this.buildArgs(r.args);n.length>0&&i.push(...n)}if(r?.first!==void 0){const n=Math.max(0,Math.min(r.first,d));i.push(`first: ${n}`)}if(r?.skip!==void 0){const n=Math.max(0,Math.min(r.skip,b));i.push(`skip: ${n}`)}if(r?.where){const n=this.buildJsonQuery(r.where);n.length>0&&i.push(`where: {${n}}`)}if(r?.block){const n=this.buildJsonQuery(r.block);n.length>0&&i.push(`block: {${n}}`)}const o=i.length>0?`(${i.join(", ")})`:"";let c=["id"];r?.elements&&r.elements.length>0&&(c=this.buildElements(r.elements));let l="";r?.inlineFragments&&r.inlineFragments.length>0&&(l=` ${this.buildInlineFragments(r.inlineFragments)}`);const u=`${s}${o} {${c.join(" ")}${l}}`;if(t){const n=this.buildMetadata(t);return n?`${n} ${u}`:u}return u}static buildMultipleQuery(e,t){const r=e.map(i=>this.buildQuery({collection:i.collection,params:i.params})).join(" ");if(t){const i=this.buildMetadata(t);return i?`${i} ${r}`:r}return r}static makeFullQuery(e,t="query"){return`query ${t} {${e}}`}}class $ extends f{queryName;constructor(e,t){super(e,t),this.queryName="query"}async stringQuery(e){const t=await this.post("",{query:e});if(t&&typeof t=="object"&&"errors"in t){const r=t.errors.map(i=>i.message).join("; ");throw new Error(`GraphQL Error: ${r}`)}return t.data}async query(e,t){const s=a.buildQuery(e,t);return this.stringQuery(a.makeFullQuery(s,this.queryName))}async multipleQuery(e,t){const s=a.buildMultipleQuery(e,t);return this.stringQuery(a.makeFullQuery(s,this.queryName))}}exports.EthGraphQuery=$;exports.OptionKeys=p;exports.QueryBuilder=a;
package/dist/index.d.ts CHANGED
@@ -1,27 +1,25 @@
1
- import { AxiosRequestConfig } from 'axios';
2
-
3
1
  /**
4
- * Base class for handling API requests using axios.
2
+ * Base class for handling API requests using fetch.
5
3
  * Provides protected methods for common HTTP verbs.
6
4
  */
7
5
  declare class ApiQuery {
8
6
  /** The root URL for all API requests. */
9
7
  root: string;
10
- /** Axios configuration used for all requests. */
11
- config: AxiosRequestConfig;
8
+ /** Request options used for all requests. */
9
+ config: RequestOptions;
12
10
  /**
13
11
  * Initializes a new instance of the ApiQuery class.
14
12
  * @param rootUrl - The base URL for the API.
15
- * @param config - Optional axios configuration.
13
+ * @param config - Optional request configuration.
16
14
  */
17
- constructor(rootUrl: string, config?: AxiosRequestConfig);
15
+ constructor(rootUrl: string, config?: RequestOptions);
18
16
  /**
19
17
  * Performs an API request.
20
18
  * @template T - The expected response type.
21
19
  * @param method - The HTTP method to use.
22
20
  * @param url - The relative URL for the request.
23
21
  * @param data - The request payload (for POST, PUT).
24
- * @param config - Optional axios configuration to override defaults.
22
+ * @param config - Optional request configuration to override defaults.
25
23
  * @returns A promise that resolves to the response data.
26
24
  */
27
25
  private request;
@@ -29,38 +27,38 @@ declare class ApiQuery {
29
27
  * Performs a GET request.
30
28
  * @template T - The expected response type.
31
29
  * @param url - The relative URL for the request.
32
- * @param config - Optional axios configuration to override defaults.
30
+ * @param config - Optional request configuration to override defaults.
33
31
  * @returns A promise that resolves to the response data.
34
32
  */
35
- protected get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
33
+ protected get<T = any>(url: string, config?: RequestOptions): Promise<T>;
36
34
  /**
37
35
  * Performs a POST request.
38
36
  * @template B - The request body type.
39
37
  * @template T - The expected response type.
40
38
  * @param url - The relative URL for the request.
41
39
  * @param data - The request payload.
42
- * @param config - Optional axios configuration to override defaults.
40
+ * @param config - Optional request configuration to override defaults.
43
41
  * @returns A promise that resolves to the response data.
44
42
  */
45
- protected post<B = any, T = any>(url: string, data?: B, config?: AxiosRequestConfig): Promise<T>;
43
+ protected post<B = any, T = any>(url: string, data?: B, config?: RequestOptions): Promise<T>;
46
44
  /**
47
45
  * Performs a PUT request.
48
46
  * @template B - The request body type.
49
47
  * @template T - The expected response type.
50
48
  * @param url - The relative URL for the request.
51
49
  * @param data - The request payload.
52
- * @param config - Optional axios configuration to override defaults.
50
+ * @param config - Optional request configuration to override defaults.
53
51
  * @returns A promise that resolves to the response data.
54
52
  */
55
- protected put<B = any, T = any>(url: string, data?: B, config?: AxiosRequestConfig): Promise<T>;
53
+ protected put<B = any, T = any>(url: string, data?: B, config?: RequestOptions): Promise<T>;
56
54
  /**
57
55
  * Performs a DELETE request.
58
56
  * @template T - The expected response type.
59
57
  * @param url - The relative URL for the request.
60
- * @param config - Optional axios configuration to override defaults.
58
+ * @param config - Optional request configuration to override defaults.
61
59
  * @returns A promise that resolves to the response data.
62
60
  */
63
- protected del<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
61
+ protected del<T = any>(url: string, config?: RequestOptions): Promise<T>;
64
62
  }
65
63
 
66
64
  /**
@@ -76,8 +74,6 @@ export declare type BlockQuery = {
76
74
  hash?: string;
77
75
  /** Filter by exact block number. */
78
76
  number?: number;
79
- /** Filter by blocks with number greater than or equal to. */
80
- number_gte?: number;
81
77
  };
82
78
 
83
79
  /**
@@ -127,9 +123,9 @@ export declare class EthGraphQuery extends ApiQuery {
127
123
  /**
128
124
  * Initializes a new EthGraphQuery instance.
129
125
  * @param rootUrl - The endpoint URL of the subgraph.
130
- * @param config - Optional axios configuration for custom headers or timeouts.
126
+ * @param config - Optional request configuration for custom headers or timeouts.
131
127
  */
132
- constructor(rootUrl: string, config?: AxiosRequestConfig);
128
+ constructor(rootUrl: string, config?: RequestOptions);
133
129
  /**
134
130
  * Executes a raw GraphQL query string.
135
131
  * @template T - The expected return type of the data.
@@ -174,24 +170,35 @@ export declare interface GraphParams {
174
170
  elements?: Array<ElementType>;
175
171
  /** Inline fragments for selecting fields on specific types. */
176
172
  inlineFragments?: Array<InlineFragmentType>;
177
- /** Filter conditions for the query. */
173
+ /** Generic GraphQL arguments (schema-agnostic). */
174
+ args?: {
175
+ [key: string]: GraphQLArgValue;
176
+ };
177
+ /** The Graph-specific 'where' filter conditions. */
178
178
  where?: QueryJson;
179
179
  /** Filter by specific entity ID (shortcut for where: { id: ... }). */
180
180
  id?: string;
181
- /** Number of items to return (max 1000). */
181
+ /** Number of items to return. */
182
182
  first?: number;
183
183
  /** Field to sort the results by. */
184
184
  orderBy?: string;
185
185
  /** Direction of the sort (asc or desc). */
186
186
  orderDirection?: 'asc' | 'desc';
187
- /** Number of items to skip (max 5000). */
187
+ /** Number of items to skip. */
188
188
  skip?: number;
189
189
  /** Re-run the query even if the subgraph has indexing errors. */
190
190
  subgraphError?: 'allow' | 'deny';
191
- /** Query the collection state at a specific block. */
191
+ /** Query the collection state at a specific block (The Graph). */
192
192
  block?: BlockQuery;
193
193
  }
194
194
 
195
+ /**
196
+ * Generic GraphQL argument value for schema-agnostic queries.
197
+ */
198
+ export declare type GraphQLArgValue = string | number | boolean | null | undefined | Array<GraphQLArgValue> | {
199
+ [key: string]: GraphQLArgValue;
200
+ };
201
+
195
202
  /**
196
203
  * Represents an inline fragment for polymorphic types.
197
204
  */
@@ -199,7 +206,9 @@ export declare type InlineFragmentType = {
199
206
  /** The collection name for the fragment (e.g., 'User'). */
200
207
  collection: string;
201
208
  /** Fields to select within the fragment. */
202
- params?: Pick<GraphParams, 'elements'>;
209
+ params?: {
210
+ elements?: Array<ElementType>;
211
+ };
203
212
  };
204
213
 
205
214
  /**
@@ -209,7 +218,19 @@ export declare type Metadata = {
209
218
  /** Specific metadata elements to fetch. */
210
219
  elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
211
220
  /** Query metadata for a specific block. */
212
- blockQuery?: BlockQuery;
221
+ blockQuery?: MetadataBlockQuery;
222
+ };
223
+
224
+ /**
225
+ * Metadata block query supports number_gte in The Graph _meta.
226
+ */
227
+ export declare type MetadataBlockQuery = {
228
+ /** Filter by block hash. */
229
+ hash?: string;
230
+ /** Filter by exact block number. */
231
+ number?: number;
232
+ /** Filter by blocks with number greater than or equal to. */
233
+ number_gte?: number;
213
234
  };
214
235
 
215
236
  /**
@@ -220,9 +241,13 @@ export declare type OptionKey = (typeof OptionKeys)[number];
220
241
  /**
221
242
  * Valid operator suffixes for The Graph queries (e.g., _gt, _in, _contains).
222
243
  */
223
- export declare const OptionKeys: readonly ["contains", "contains_nocase", "ends_with", "end_with_nocase", "starts_with", "starts_with_nocase", "not_contains", "not_contains_nocase", "not_ends_with", "not_ends_with_nocase", "not_starts_with", "not_starts_with_nocase", "gt", "gte", "lt", "lte", "not", "in", "not_in"];
244
+ export declare const OptionKeys: readonly ["contains", "contains_nocase", "ends_with", "ends_with_nocase", "end_with_nocase", "starts_with", "starts_with_nocase", "not_contains", "not_contains_nocase", "not_ends_with", "not_ends_with_nocase", "not_starts_with", "not_starts_with_nocase", "gt", "gte", "lt", "lte", "not", "in", "not_in"];
224
245
 
225
246
  export declare class QueryBuilder {
247
+ private static escapeGraphqlString;
248
+ static serializeValue(value: string | number | boolean | null): string;
249
+ private static serializeArgValue;
250
+ private static buildArgs;
226
251
  /**
227
252
  * Converts a JSON query object into a GraphQL-compatible string.
228
253
  * Handles nested objects and operator mapping (e.g., $gt -> _gt).
@@ -286,6 +311,12 @@ export declare type QueryJson = {
286
311
  [key: string]: QueryJson | WhereOptions | BaseQueryType;
287
312
  };
288
313
 
314
+ declare type RequestOptions = {
315
+ headers?: Record<string, string>;
316
+ timeoutMs?: number;
317
+ signal?: AbortSignal;
318
+ };
319
+
289
320
  /**
290
321
  * Filter options for text-based fields.
291
322
  */
package/dist/index.js CHANGED
@@ -1,25 +1,18 @@
1
- import y from "axios";
2
1
  const p = { Accept: "application/json", "Content-Type": "application/json" };
3
- function f(a) {
4
- return a.data;
5
- }
6
- class d {
2
+ class y {
7
3
  /** The root URL for all API requests. */
8
4
  root;
9
- /** Axios configuration used for all requests. */
5
+ /** Request options used for all requests. */
10
6
  config;
11
7
  /**
12
8
  * Initializes a new instance of the ApiQuery class.
13
9
  * @param rootUrl - The base URL for the API.
14
- * @param config - Optional axios configuration.
10
+ * @param config - Optional request configuration.
15
11
  */
16
- constructor(t, e = {}) {
17
- this.root = t, this.config = {
18
- ...e,
19
- headers: {
20
- ...p,
21
- ...e.headers || {}
22
- }
12
+ constructor(e, t = {}) {
13
+ this.root = e, this.config = {
14
+ ...t,
15
+ headers: { ...p, ...t.headers || {} }
23
16
  };
24
17
  }
25
18
  /**
@@ -28,22 +21,38 @@ class d {
28
21
  * @param method - The HTTP method to use.
29
22
  * @param url - The relative URL for the request.
30
23
  * @param data - The request payload (for POST, PUT).
31
- * @param config - Optional axios configuration to override defaults.
24
+ * @param config - Optional request configuration to override defaults.
32
25
  * @returns A promise that resolves to the response data.
33
26
  */
34
- async request(t, e, r, s) {
35
- const n = `${this.root}${e}`, i = { ...this.config, ...s }, c = await (t === "get" || t === "delete" ? y[t](n, i) : y[t](n, r, i));
36
- return f(c);
27
+ async request(e, t, s, r) {
28
+ const i = `${this.root}${t}`, o = {
29
+ ...this.config,
30
+ ...r,
31
+ headers: { ...this.config.headers || {}, ...r?.headers || {} }
32
+ }, c = new AbortController(), l = o.timeoutMs, u = typeof l == "number" && l > 0 ? setTimeout(() => c.abort(), l) : void 0;
33
+ try {
34
+ const n = await fetch(i, {
35
+ method: e.toUpperCase(),
36
+ headers: o.headers,
37
+ body: e === "get" || e === "delete" ? void 0 : JSON.stringify(s ?? {}),
38
+ signal: o.signal ?? c.signal
39
+ });
40
+ if (!n.ok)
41
+ throw new Error(`HTTP Error: ${n.status} ${n.statusText}`);
42
+ return await n.json();
43
+ } finally {
44
+ u && clearTimeout(u);
45
+ }
37
46
  }
38
47
  /**
39
48
  * Performs a GET request.
40
49
  * @template T - The expected response type.
41
50
  * @param url - The relative URL for the request.
42
- * @param config - Optional axios configuration to override defaults.
51
+ * @param config - Optional request configuration to override defaults.
43
52
  * @returns A promise that resolves to the response data.
44
53
  */
45
- async get(t, e) {
46
- return this.request("get", t, void 0, e);
54
+ async get(e, t) {
55
+ return this.request("get", e, void 0, t);
47
56
  }
48
57
  /**
49
58
  * Performs a POST request.
@@ -51,11 +60,11 @@ class d {
51
60
  * @template T - The expected response type.
52
61
  * @param url - The relative URL for the request.
53
62
  * @param data - The request payload.
54
- * @param config - Optional axios configuration to override defaults.
63
+ * @param config - Optional request configuration to override defaults.
55
64
  * @returns A promise that resolves to the response data.
56
65
  */
57
- async post(t, e, r) {
58
- return this.request("post", t, e, r);
66
+ async post(e, t, s) {
67
+ return this.request("post", e, t, s);
59
68
  }
60
69
  /**
61
70
  * Performs a PUT request.
@@ -63,27 +72,28 @@ class d {
63
72
  * @template T - The expected response type.
64
73
  * @param url - The relative URL for the request.
65
74
  * @param data - The request payload.
66
- * @param config - Optional axios configuration to override defaults.
75
+ * @param config - Optional request configuration to override defaults.
67
76
  * @returns A promise that resolves to the response data.
68
77
  */
69
- async put(t, e, r) {
70
- return this.request("put", t, e, r);
78
+ async put(e, t, s) {
79
+ return this.request("put", e, t, s);
71
80
  }
72
81
  /**
73
82
  * Performs a DELETE request.
74
83
  * @template T - The expected response type.
75
84
  * @param url - The relative URL for the request.
76
- * @param config - Optional axios configuration to override defaults.
85
+ * @param config - Optional request configuration to override defaults.
77
86
  * @returns A promise that resolves to the response data.
78
87
  */
79
- async del(t, e) {
80
- return this.request("delete", t, void 0, e);
88
+ async del(e, t) {
89
+ return this.request("delete", e, void 0, t);
81
90
  }
82
91
  }
83
- const b = [
92
+ const f = [
84
93
  "contains",
85
94
  "contains_nocase",
86
95
  "ends_with",
96
+ "ends_with_nocase",
87
97
  "end_with_nocase",
88
98
  "starts_with",
89
99
  "starts_with_nocase",
@@ -100,54 +110,70 @@ const b = [
100
110
  "not",
101
111
  "in",
102
112
  "not_in"
103
- ], $ = 1e3, g = 5e3;
104
- class h {
113
+ ], d = 1e3, b = 5e3, g = new Set(f);
114
+ class a {
115
+ static escapeGraphqlString(e) {
116
+ return e.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
117
+ }
118
+ static serializeValue(e) {
119
+ return e === null ? "null" : typeof e == "string" ? `"${this.escapeGraphqlString(e)}"` : `${e}`;
120
+ }
121
+ static serializeArgValue(e) {
122
+ return e === null || e === void 0 ? "null" : typeof e == "string" ? this.serializeValue(e) : typeof e == "number" || typeof e == "boolean" ? `${e}` : Array.isArray(e) ? `[${e.map((s) => this.serializeArgValue(s)).join(", ")}]` : `{${this.buildArgs(e).join(", ")}}`;
123
+ }
124
+ static buildArgs(e) {
125
+ const t = [];
126
+ for (const s in e) {
127
+ if (!Object.prototype.hasOwnProperty.call(e, s)) continue;
128
+ const r = e[s];
129
+ r !== void 0 && t.push(`${s}: ${this.serializeArgValue(r)}`);
130
+ }
131
+ return t;
132
+ }
105
133
  /**
106
134
  * Converts a JSON query object into a GraphQL-compatible string.
107
135
  * Handles nested objects and operator mapping (e.g., $gt -> _gt).
108
136
  * @param query - The JSON filter object to build.
109
137
  * @returns A string representing the GraphQL 'where' or 'block' filter.
110
138
  */
111
- static buildJsonQuery(t) {
112
- const e = [];
113
- for (const r in t) {
114
- const s = t[r];
115
- if (s !== void 0)
116
- if (s === null)
117
- e.push(`${r}: null`);
118
- else if (Array.isArray(s)) {
119
- const n = s;
120
- e.push(
121
- `${r}: [${n.map((i) => typeof i == "string" ? `"${i}"` : i).join(", ")}]`
139
+ static buildJsonQuery(e) {
140
+ const t = [];
141
+ for (const s in e) {
142
+ if (!Object.prototype.hasOwnProperty.call(e, s)) continue;
143
+ const r = e[s];
144
+ if (r !== void 0)
145
+ if (r === null) t.push(`${s}: null`);
146
+ else if (Array.isArray(r)) {
147
+ const i = r;
148
+ t.push(
149
+ `${s}: [${i.map((o) => typeof o == "string" ? this.serializeValue(o) : o).join(", ")}]`
122
150
  );
123
- } else if (typeof s == "string")
124
- e.push(`${r}: "${s}"`);
125
- else if (typeof s == "object") {
126
- const n = {}, i = {}, c = s;
151
+ } else if (typeof r == "string") t.push(`${s}: ${this.serializeValue(r)}`);
152
+ else if (typeof r == "object") {
153
+ const i = {}, o = {}, c = r;
127
154
  for (const l in c) {
155
+ if (!Object.prototype.hasOwnProperty.call(c, l)) continue;
128
156
  const u = c[l];
129
157
  if (l.startsWith("$")) {
130
- const o = l.slice(1);
131
- b.includes(o) ? i[`${r}_${o}`] = u : n[l] = u;
132
- } else
133
- n[l] = u;
158
+ let n = l.slice(1);
159
+ n === "end_with_nocase" && (n = "ends_with_nocase"), g.has(n) ? o[`${s}_${n}`] = u : i[l] = u;
160
+ } else i[l] = u;
134
161
  }
135
- Object.keys(n).length > 0 && e.push(`${r}: {${this.buildJsonQuery(n)}}`), Object.keys(i).length > 0 && e.push(this.buildJsonQuery(i));
136
- } else
137
- e.push(`${r}: ${s}`);
162
+ Object.keys(i).length > 0 && t.push(`${s}: {${this.buildJsonQuery(i)}}`), Object.keys(o).length > 0 && t.push(this.buildJsonQuery(o));
163
+ } else t.push(`${s}: ${r}`);
138
164
  }
139
- return e.join(", ");
165
+ return t.join(", ");
140
166
  }
141
167
  /**
142
168
  * Builds the fields/elements part of a GraphQL query from an array of strings or objects.
143
169
  * @param elements - An array of fields to query. Can include nested collections as GraphObject.
144
170
  * @returns An array of strings representing the selected fields.
145
171
  */
146
- static buildElements(t) {
147
- return t.map((e) => {
148
- if (typeof e == "string") return e;
149
- const r = e;
150
- return this.buildQuery({ collection: r.collection, params: r.params });
172
+ static buildElements(e) {
173
+ return e.map((t) => {
174
+ if (typeof t == "string") return t;
175
+ const s = t;
176
+ return this.buildQuery({ collection: s.collection, params: s.params });
151
177
  });
152
178
  }
153
179
  /**
@@ -155,22 +181,22 @@ class h {
155
181
  * @param metadata - The metadata configuration.
156
182
  * @returns A string representing the _meta query fragment.
157
183
  */
158
- static buildMetadata(t) {
159
- let e = "";
160
- const r = [];
161
- t.blockQuery && (t.blockQuery.hash && r.push(`hash: "${t.blockQuery.hash}"`), t.blockQuery.number !== void 0 && r.push(`number: ${t.blockQuery.number}`), t.blockQuery.number_gte !== void 0 && r.push(`number_gte: ${t.blockQuery.number_gte}`));
162
- const s = r.join(", ");
163
- s.length > 0 && (e += `(block: {${s}})`);
164
- const n = [], i = [];
165
- if (t.elements) {
166
- for (const u of t.elements)
167
- u === "deployment" || u === "hasIndexingErrors" ? n.includes(u) || n.push(u) : i.includes(u) || i.push(u);
168
- const c = i.join(" ");
169
- c.length > 0 && n.push(`block{${c}}`);
170
- const l = n.join(" ");
171
- l.length > 0 && (e += `{${l}}`);
184
+ static buildMetadata(e) {
185
+ let t = "";
186
+ const s = [];
187
+ e.blockQuery && (e.blockQuery.hash && s.push(`hash: "${e.blockQuery.hash}"`), e.blockQuery.number !== void 0 && s.push(`number: ${e.blockQuery.number}`), e.blockQuery.number_gte !== void 0 && s.push(`number_gte: ${e.blockQuery.number_gte}`));
188
+ const r = s.join(", ");
189
+ r.length > 0 && (t += `(block: {${r}})`);
190
+ const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
191
+ if (e.elements) {
192
+ for (const u of e.elements)
193
+ u === "deployment" || u === "hasIndexingErrors" ? i.add(u) : o.add(u);
194
+ const c = Array.from(o).join(" ");
195
+ c.length > 0 && i.add(`block{${c}}`);
196
+ const l = Array.from(i).join(" ");
197
+ l.length > 0 && (t += `{${l}}`);
172
198
  }
173
- return e.length > 0 ? `_meta${e}` : "";
199
+ return t.length > 0 ? `_meta${t}` : "";
174
200
  }
175
201
  /**
176
202
  * Builds an inline fragment (... on Collection { ... }) for a query.
@@ -178,17 +204,17 @@ class h {
178
204
  * @returns A string representing the inline fragment.
179
205
  * @private
180
206
  */
181
- static _buildInlineFragment(t) {
182
- const e = t.params?.elements?.length ? this.buildElements(t.params.elements) : ["id"];
183
- return `... on ${t.collection}{${e.join(" ")}}`;
207
+ static _buildInlineFragment(e) {
208
+ const t = e.params?.elements?.length ? this.buildElements(e.params.elements) : ["id"];
209
+ return `... on ${e.collection}{${t.join(" ")}}`;
184
210
  }
185
211
  /**
186
212
  * Builds multiple inline fragments from an array of fragment configurations.
187
213
  * @param fragments - An array of inline fragments.
188
214
  * @returns A string containing all built inline fragments.
189
215
  */
190
- static buildInlineFragments(t) {
191
- return t.map((e) => this._buildInlineFragment(e)).join(" ");
216
+ static buildInlineFragments(e) {
217
+ return e.map((t) => this._buildInlineFragment(t)).join(" ");
192
218
  }
193
219
  /**
194
220
  * Builds a complete GraphQL query for a single collection.
@@ -196,33 +222,37 @@ class h {
196
222
  * @param metadata - Optional metadata configuration.
197
223
  * @returns A string containing the GraphQL query for the collection.
198
224
  */
199
- static buildQuery(t, e) {
200
- const { collection: r, params: s } = t, n = [];
201
- if (s?.id !== void 0 && n.push(`id: ${s.id}`), s?.orderBy && n.push(`orderBy: ${s.orderBy}`), s?.orderDirection && n.push(`orderDirection: ${s.orderDirection}`), s?.first !== void 0) {
202
- const o = Math.max(0, Math.min(s.first, $));
203
- n.push(`first: ${o}`);
225
+ static buildQuery(e, t) {
226
+ const { collection: s, params: r } = e, i = [];
227
+ if (r?.id !== void 0 && i.push(`id: ${this.serializeValue(r.id)}`), r?.orderBy && i.push(`orderBy: ${r.orderBy}`), r?.orderDirection && i.push(`orderDirection: ${r.orderDirection}`), r?.subgraphError && i.push(`subgraphError: ${r.subgraphError}`), r?.args) {
228
+ const n = this.buildArgs(r.args);
229
+ n.length > 0 && i.push(...n);
230
+ }
231
+ if (r?.first !== void 0) {
232
+ const n = Math.max(0, Math.min(r.first, d));
233
+ i.push(`first: ${n}`);
204
234
  }
205
- if (s?.skip !== void 0) {
206
- const o = Math.max(0, Math.min(s.skip, g));
207
- n.push(`skip: ${o}`);
235
+ if (r?.skip !== void 0) {
236
+ const n = Math.max(0, Math.min(r.skip, b));
237
+ i.push(`skip: ${n}`);
208
238
  }
209
- if (s?.where) {
210
- const o = this.buildJsonQuery(s.where);
211
- o.length > 0 && n.push(`where: {${o}}`);
239
+ if (r?.where) {
240
+ const n = this.buildJsonQuery(r.where);
241
+ n.length > 0 && i.push(`where: {${n}}`);
212
242
  }
213
- if (s?.block) {
214
- const o = this.buildJsonQuery(s.block);
215
- o.length > 0 && n.push(`block: {${o}}`);
243
+ if (r?.block) {
244
+ const n = this.buildJsonQuery(r.block);
245
+ n.length > 0 && i.push(`block: {${n}}`);
216
246
  }
217
- const i = n.length > 0 ? `(${n.join(", ")})` : "";
247
+ const o = i.length > 0 ? `(${i.join(", ")})` : "";
218
248
  let c = ["id"];
219
- s?.elements && s.elements.length > 0 && (c = this.buildElements(s.elements));
249
+ r?.elements && r.elements.length > 0 && (c = this.buildElements(r.elements));
220
250
  let l = "";
221
- s?.inlineFragments && s.inlineFragments.length > 0 && (l = ` ${this.buildInlineFragments(s.inlineFragments)}`);
222
- const u = `${r}${i} {${c.join(" ")}${l}}`;
223
- if (e) {
224
- const o = this.buildMetadata(e);
225
- return o ? `${o} ${u}` : u;
251
+ r?.inlineFragments && r.inlineFragments.length > 0 && (l = ` ${this.buildInlineFragments(r.inlineFragments)}`);
252
+ const u = `${s}${o} {${c.join(" ")}${l}}`;
253
+ if (t) {
254
+ const n = this.buildMetadata(t);
255
+ return n ? `${n} ${u}` : u;
226
256
  }
227
257
  return u;
228
258
  }
@@ -232,15 +262,15 @@ class h {
232
262
  * @param metadata - Optional metadata configuration that applies to the entire query.
233
263
  * @returns A string containing the merged GraphQL query for multiple collections.
234
264
  */
235
- static buildMultipleQuery(t, e) {
236
- const s = t.map(
237
- (n) => this.buildQuery({ collection: n.collection, params: n.params })
265
+ static buildMultipleQuery(e, t) {
266
+ const r = e.map(
267
+ (i) => this.buildQuery({ collection: i.collection, params: i.params })
238
268
  ).join(" ");
239
- if (e) {
240
- const n = this.buildMetadata(e);
241
- return n ? `${n} ${s}` : s;
269
+ if (t) {
270
+ const i = this.buildMetadata(t);
271
+ return i ? `${i} ${r}` : r;
242
272
  }
243
- return s;
273
+ return r;
244
274
  }
245
275
  /**
246
276
  * Wraps a query fragment into a full GraphQL 'query' block.
@@ -248,20 +278,20 @@ class h {
248
278
  * @param queryName - An optional name for the GraphQL query (defaults to 'query').
249
279
  * @returns The full GraphQL query string.
250
280
  */
251
- static makeFullQuery(t, e = "query") {
252
- return `query ${e} {${t}}`;
281
+ static makeFullQuery(e, t = "query") {
282
+ return `query ${t} {${e}}`;
253
283
  }
254
284
  }
255
- class Q extends d {
285
+ class $ extends y {
256
286
  /** The name of the GraphQL query, used in makeFullQuery. */
257
287
  queryName;
258
288
  /**
259
289
  * Initializes a new EthGraphQuery instance.
260
290
  * @param rootUrl - The endpoint URL of the subgraph.
261
- * @param config - Optional axios configuration for custom headers or timeouts.
291
+ * @param config - Optional request configuration for custom headers or timeouts.
262
292
  */
263
- constructor(t, e) {
264
- super(t, e), this.queryName = "query";
293
+ constructor(e, t) {
294
+ super(e, t), this.queryName = "query";
265
295
  }
266
296
  /**
267
297
  * Executes a raw GraphQL query string.
@@ -270,13 +300,13 @@ class Q extends d {
270
300
  * @returns A promise resolving to the query result.
271
301
  * @throws Error if the response contains any GraphQL errors.
272
302
  */
273
- async stringQuery(t) {
274
- const e = await this.post("", { query: t });
275
- if (e && typeof e == "object" && "errors" in e) {
276
- const s = e.errors.map((n) => n.message).join("; ");
277
- throw new Error(`GraphQL Error: ${s}`);
303
+ async stringQuery(e) {
304
+ const t = await this.post("", { query: e });
305
+ if (t && typeof t == "object" && "errors" in t) {
306
+ const r = t.errors.map((i) => i.message).join("; ");
307
+ throw new Error(`GraphQL Error: ${r}`);
278
308
  }
279
- return e.data;
309
+ return t.data;
280
310
  }
281
311
  /**
282
312
  * Executes a single collection query using a JSON configuration.
@@ -285,9 +315,9 @@ class Q extends d {
285
315
  * @param metadata - Optional metadata fields to include in the query.
286
316
  * @returns A promise resolving to the fetched data.
287
317
  */
288
- async query(t, e) {
289
- const r = h.buildQuery(t, e);
290
- return this.stringQuery(h.makeFullQuery(r, this.queryName));
318
+ async query(e, t) {
319
+ const s = a.buildQuery(e, t);
320
+ return this.stringQuery(a.makeFullQuery(s, this.queryName));
291
321
  }
292
322
  /**
293
323
  * Executes multiple collection queries in a single request using JSON configurations.
@@ -296,13 +326,13 @@ class Q extends d {
296
326
  * @param metadata - Optional metadata fields to include in the query.
297
327
  * @returns A promise resolving to the merged results of all queries.
298
328
  */
299
- async multipleQuery(t, e) {
300
- const r = h.buildMultipleQuery(t, e);
301
- return this.stringQuery(h.makeFullQuery(r, this.queryName));
329
+ async multipleQuery(e, t) {
330
+ const s = a.buildMultipleQuery(e, t);
331
+ return this.stringQuery(a.makeFullQuery(s, this.queryName));
302
332
  }
303
333
  }
304
334
  export {
305
- Q as EthGraphQuery,
306
- b as OptionKeys,
307
- h as QueryBuilder
335
+ $ as EthGraphQuery,
336
+ f as OptionKeys,
337
+ a as QueryBuilder
308
338
  };
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "eth-graph-query",
3
- "version": "2.0.21",
4
- "description": "A lightweight and flexible library for building The Graph queries using simple JSON objects. Eliminate the need for complex string concatenation and maintain type-safe queries.",
3
+ "version": "3.0.0",
4
+ "description": "A lightweight GraphQL query builder and client with first-class support for The Graph. Build queries using JSON, avoid string concatenation, and keep strong TypeScript types.",
5
5
  "type": "module",
6
- "main": "dist/index.cjs",
7
- "module": "dist/index.js",
8
- "typings": "dist/index.d.ts",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "sideEffects": false,
9
17
  "files": [
10
18
  "dist"
11
19
  ],
12
- "sideEffects": false,
13
20
  "scripts": {
14
21
  "build": "bun run clear && tsc && vite build",
15
22
  "preview": "vite preview",
@@ -34,19 +41,16 @@
34
41
  "url": "https://github.com/phamhongphuc1999/eth-graph-query/issues"
35
42
  },
36
43
  "homepage": "https://github.com/phamhongphuc1999/eth-graph-query#readme",
37
- "peerDependencies": {
38
- "axios": "^1.13.2"
39
- },
40
44
  "devDependencies": {
41
45
  "@commitlint/cli": "^19.4.0",
42
46
  "@commitlint/config-conventional": "^19.2.2",
43
47
  "@eslint/js": "^9.29.0",
44
48
  "@types/node": "^20.12.2",
45
- "axios": "^1.13.2",
46
49
  "eslint": "^9.29.0",
47
50
  "eslint-import-resolver-typescript": "^4.4.4",
48
51
  "eslint-plugin-import": "^2.32.0",
49
52
  "eslint-plugin-prettier": "^5.5.1",
53
+ "eslint-plugin-react": "^7.37.5",
50
54
  "eslint-plugin-react-hooks": "^5.2.0",
51
55
  "eslint-plugin-react-refresh": "^0.4.20",
52
56
  "husky": "^9.1.6",
@@ -1,8 +0,0 @@
1
- {
2
- "src/index.ts": {
3
- "file": "index.cjs",
4
- "name": "index",
5
- "src": "src/index.ts",
6
- "isEntry": true
7
- }
8
- }