eth-graph-query 2.0.20 → 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 +21 -0
- package/README.md +59 -28
- package/dist/index.cjs +1 -6
- package/dist/index.d.ts +355 -3
- package/dist/index.js +158 -1892
- package/package.json +18 -14
- package/dist/.vite/manifest.json +0 -8
- package/dist/api-query.d.ts +0 -67
- package/dist/eth-graph-query.d.ts +0 -41
- package/dist/query-builder.d.ts +0 -56
- package/dist/type.d.ts +0 -149
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
|
|
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
|
[](https://www.npmjs.com/package/eth-graph-query)
|
|
6
6
|
[](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/LICENSE)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Features
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
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
|
-
##
|
|
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
|
|
33
|
+
bun add eth-graph-query
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
---
|
|
36
37
|
|
|
37
|
-
##
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
##
|
|
140
|
+
## Notes
|
|
113
141
|
|
|
114
|
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
This project is licensed under the MIT License. See [LICENSE](LICENSE).
|
|
129
160
|
|
|
130
|
-
|
|
161
|
+
---
|
|
131
162
|
|
|
132
|
-
##
|
|
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,6 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Je(t,e){return function(){return t.apply(e,arguments)}}const{toString:yt}=Object.prototype,{getPrototypeOf:we}=Object,{iterator:se,toStringTag:ze}=Symbol,oe=(t=>e=>{const n=yt.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),F=t=>(t=t.toLowerCase(),e=>oe(e)===t),ie=t=>e=>typeof e===t,{isArray:I}=Array,M=ie("undefined");function v(t){return t!==null&&!M(t)&&t.constructor!==null&&!M(t.constructor)&&A(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const ve=F("ArrayBuffer");function bt(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ve(t.buffer),e}const wt=ie("string"),A=ie("function"),Ve=ie("number"),V=t=>t!==null&&typeof t=="object",gt=t=>t===!0||t===!1,ee=t=>{if(oe(t)!=="object")return!1;const e=we(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ze in t)&&!(se in t)},Et=t=>{if(!V(t)||v(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},St=F("Date"),Rt=F("File"),Ot=F("Blob"),At=F("FileList"),Tt=t=>V(t)&&A(t.pipe),xt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||A(t.append)&&((e=oe(t))==="formdata"||e==="object"&&A(t.toString)&&t.toString()==="[object FormData]"))},_t=F("URLSearchParams"),[Ct,Ft,Nt,kt]=["ReadableStream","Request","Response","Headers"].map(F),Pt=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),I(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(v(t))return;const o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let c;for(r=0;r<i;r++)c=o[r],e.call(null,t[c],c,t)}}function We(t,e){if(v(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}const L=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ke=t=>!M(t)&&t!==L;function pe(){const{caseless:t,skipUndefined:e}=Ke(this)&&this||{},n={},r=(s,o)=>{const i=t&&We(n,o)||o;ee(n[i])&&ee(s)?n[i]=pe(n[i],s):ee(s)?n[i]=pe({},s):I(s)?n[i]=s.slice():(!e||!M(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&W(arguments[s],r);return n}const Ut=(t,e,n,{allOwnKeys:r}={})=>(W(e,(s,o)=>{n&&A(s)?t[o]=Je(s,n):t[o]=s},{allOwnKeys:r}),t),jt=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Bt=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},Lt=(t,e,n,r)=>{let s,o,i;const c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!c[i]&&(e[i]=t[i],c[i]=!0);t=n!==!1&&we(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},$t=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},Dt=t=>{if(!t)return null;if(I(t))return t;let e=t.length;if(!Ve(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},qt=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&we(Uint8Array)),Mt=(t,e)=>{const r=(t&&t[se]).call(t);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},It=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},Ht=F("HTMLFormElement"),Qt=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ce=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Jt=F("RegExp"),Xe=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};W(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},zt=t=>{Xe(t,(e,n)=>{if(A(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(A(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},vt=(t,e)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return I(t)?r(t):r(String(t).split(e)),n},Vt=()=>{},Wt=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Kt(t){return!!(t&&A(t.append)&&t[ze]==="FormData"&&t[se])}const Xt=t=>{const e=new Array(10),n=(r,s)=>{if(V(r)){if(e.indexOf(r)>=0)return;if(v(r))return r;if(!("toJSON"in r)){e[s]=r;const o=I(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!M(d)&&(o[c]=d)}),e[s]=void 0,o}}return r};return n(t,0)},Gt=F("AsyncFunction"),Zt=t=>t&&(V(t)||A(t))&&A(t.then)&&A(t.catch),Ge=((t,e)=>t?setImmediate:e?((n,r)=>(L.addEventListener("message",({source:s,data:o})=>{s===L&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),L.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",A(L.postMessage)),Yt=typeof queueMicrotask<"u"?queueMicrotask.bind(L):typeof process<"u"&&process.nextTick||Ge,en=t=>t!=null&&A(t[se]),a={isArray:I,isArrayBuffer:ve,isBuffer:v,isFormData:xt,isArrayBufferView:bt,isString:wt,isNumber:Ve,isBoolean:gt,isObject:V,isPlainObject:ee,isEmptyObject:Et,isReadableStream:Ct,isRequest:Ft,isResponse:Nt,isHeaders:kt,isUndefined:M,isDate:St,isFile:Rt,isBlob:Ot,isRegExp:Jt,isFunction:A,isStream:Tt,isURLSearchParams:_t,isTypedArray:qt,isFileList:At,forEach:W,merge:pe,extend:Ut,trim:Pt,stripBOM:jt,inherits:Bt,toFlatObject:Lt,kindOf:oe,kindOfTest:F,endsWith:$t,toArray:Dt,forEachEntry:Mt,matchAll:It,isHTMLForm:Ht,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Xe,freezeMethods:zt,toObjectSet:vt,toCamelCase:Qt,noop:Vt,toFiniteNumber:Wt,findKey:We,global:L,isContextDefined:Ke,isSpecCompliantForm:Kt,toJSONObject:Xt,isAsyncFn:Gt,isThenable:Zt,setImmediate:Ge,asap:Yt,isIterable:en};function y(t,e,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Ze=y.prototype,Ye={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Ye[t]={value:t}});Object.defineProperties(y,Ye);Object.defineProperty(Ze,"isAxiosError",{value:!0});y.from=(t,e,n,r,s,o)=>{const i=Object.create(Ze);a.toFlatObject(t,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=t&&t.message?t.message:"Error",d=e==null&&t?t.code:e;return y.call(i,c,d,n,r,s),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",o&&Object.assign(i,o),i};const tn=null;function me(t){return a.isPlainObject(t)||a.isArray(t)}function et(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function Fe(t,e,n){return t?t.concat(e).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function nn(t){return a.isArray(t)&&!t.some(me)}const rn=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function ae(t,e,n){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,h){return!a.isUndefined(h[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,h){let g=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&nn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(g=a.toArray(f)))return m=et(m),g.forEach(function(E,O){!(a.isUndefined(E)||E===null)&&e.append(i===!0?Fe([m],O,o):i===null?m:m+"[]",u(E))}),!1}return me(f)?!0:(e.append(Fe(h,m,o),u(f)),!1)}const p=[],b=Object.assign(rn,{defaultVisitor:l,convertValue:u,isVisitable:me});function S(f,m){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));p.push(f),a.forEach(f,function(g,x){(!(a.isUndefined(g)||g===null)&&s.call(e,g,a.isString(x)?x.trim():x,m,b))===!0&&S(g,m?m.concat(x):[x])}),p.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return S(t),e}function Ne(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ge(t,e){this._pairs=[],t&&ae(t,this,e)}const tt=ge.prototype;tt.append=function(e,n){this._pairs.push([e,n])};tt.toString=function(e){const n=e?function(r){return e.call(this,r,Ne)}:Ne;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function sn(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function nt(t,e,n){if(!e)return t;const r=n&&n.encode||sn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(e,n):o=a.isURLSearchParams(e)?e.toString():new ge(e,n).toString(r),o){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class ke{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(r){r!==null&&e(r)})}}const rt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},on=typeof URLSearchParams<"u"?URLSearchParams:ge,an=typeof FormData<"u"?FormData:null,cn=typeof Blob<"u"?Blob:null,ln={isBrowser:!0,classes:{URLSearchParams:on,FormData:an,Blob:cn},protocols:["http","https","file","blob","url","data"]},Ee=typeof window<"u"&&typeof document<"u",ye=typeof navigator=="object"&&navigator||void 0,un=Ee&&(!ye||["ReactNative","NativeScript","NS"].indexOf(ye.product)<0),fn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dn=Ee&&window.location.href||"http://localhost",hn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ee,hasStandardBrowserEnv:un,hasStandardBrowserWebWorkerEnv:fn,navigator:ye,origin:dn},Symbol.toStringTag,{value:"Module"})),R={...hn,...ln};function pn(t,e){return ae(t,new R.classes.URLSearchParams,{visitor:function(n,r,s,o){return R.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function mn(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function yn(t){const e={},n=Object.keys(t);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function st(t){function e(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=yn(s[i])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const n={};return a.forEachEntry(t,(r,s)=>{e(mn(r),s,n,0)}),n}return null}function bn(t,e,n){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const K={transitional:rt,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(st(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return pn(e,this.formSerializer).toString();if((c=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ae(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(e)):e}],transformResponse:[function(e){const n=this.transitional||K.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{K.headers[t]={}});const wn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gn=t=>{const e={};let n,r,s;return t&&t.split(`
|
|
2
|
-
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||e[n]&&wn[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},Pe=Symbol("internals");function J(t){return t&&String(t).trim().toLowerCase()}function te(t){return t===!1||t==null?t:a.isArray(t)?t.map(te):String(t)}function En(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const Sn=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function fe(t,e,n,r,s){if(a.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!a.isString(e)){if(a.isString(r))return e.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(e)}}function Rn(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function On(t,e){const n=a.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let T=class{constructor(e){e&&this.set(e)}set(e,n,r){const s=this;function o(c,d,u){const l=J(d);if(!l)throw new Error("header name must be a non-empty string");const p=a.findKey(s,l);(!p||s[p]===void 0||u===!0||u===void 0&&s[p]!==!1)&&(s[p||d]=te(c))}const i=(c,d)=>a.forEach(c,(u,l)=>o(u,l,d));if(a.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(a.isString(e)&&(e=e.trim())&&!Sn(e))i(gn(e),n);else if(a.isObject(e)&&a.isIterable(e)){let c={},d,u;for(const l of e){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(c,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=J(e),e){const r=a.findKey(this,e);if(r){const s=this[r];if(!n)return s;if(n===!0)return En(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=J(e),e){const r=a.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||fe(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let s=!1;function o(i){if(i=J(i),i){const c=a.findKey(r,i);c&&(!n||fe(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(e)?e.forEach(o):o(e),s}clear(e){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!e||fe(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=te(s),delete n[o];return}const c=e?Rn(o):String(o).trim();c!==o&&delete n[o],n[c]=te(s),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[Pe]=this[Pe]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=J(i);r[c]||(On(s,i),r[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};T.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(T.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});a.freezeMethods(T);function de(t,e){const n=this||K,r=e||n,s=T.from(r.headers);let o=r.data;return a.forEach(t,function(c){o=c.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function ot(t){return!!(t&&t.__CANCEL__)}function H(t,e,n){y.call(this,t??"canceled",y.ERR_CANCELED,e,n),this.name="CanceledError"}a.inherits(H,y,{__CANCEL__:!0});function it(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function An(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Tn(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let p=o,b=0;for(;p!==s;)b+=n[p++],p=p%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),u-i<e)return;const S=l&&u-l;return S?Math.round(b*1e3/S):void 0}}function xn(t,e){let n=0,r=1e3/e,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),t(...u)};return[(...u)=>{const l=Date.now(),p=l-n;p>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s)]}const re=(t,e,n=3)=>{let r=0;const s=Tn(50,250);return xn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const p={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(p)},n)},Ue=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},je=t=>(...e)=>a.asap(()=>t(...e)),_n=R.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,R.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(R.origin),R.navigator&&/(msie|trident)/i.test(R.navigator.userAgent)):()=>!0,Cn=R.hasStandardBrowserEnv?{write(t,e,n,r,s,o,i){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(e)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Fn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Nn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function at(t,e,n){let r=!Fn(e);return t&&(r||n==!1)?Nn(t,e):e}const Be=t=>t instanceof T?{...t}:t;function D(t,e){e=e||{};const n={};function r(u,l,p,b){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:b},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,p,b){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,p,b)}else return r(u,l,p,b)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,p){if(p in e)return r(u,l);if(p in t)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,p)=>s(Be(u),Be(l),p,!0)};return a.forEach(Object.keys({...t,...e}),function(l){const p=d[l]||s,b=p(t[l],e[l],l);a.isUndefined(b)&&p!==c||(n[l]=b)}),n}const ct=t=>{const e=D({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;if(e.headers=i=T.from(i),e.url=nt(at(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(R.hasStandardBrowserEnv||R.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,p])=>{u.includes(l.toLowerCase())&&i.set(l,p)})}}if(R.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(e)),r||r!==!1&&_n(e.url))){const d=s&&o&&Cn.read(o);d&&i.set(s,d)}return e},kn=typeof XMLHttpRequest<"u",Pn=kn&&function(t){return new Promise(function(n,r){const s=ct(t);let o=s.data;const i=T.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,p,b,S,f;function m(){S&&S(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function g(){if(!h)return;const E=T.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:E,config:t,request:h};it(function(_){n(_),m()},function(_){r(_),m()},C),h=null}"onloadend"in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(g)},h.onabort=function(){h&&(r(new y("Request aborted",y.ECONNABORTED,t,h)),h=null)},h.onerror=function(O){const C=O&&O.message?O.message:"Network Error",j=new y(C,y.ERR_NETWORK,t,h);j.event=O||null,r(j),h=null},h.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const C=s.transitional||rt;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new y(O,C.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,t,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(O,C){h.setRequestHeader(C,O)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),u&&([b,f]=re(u,!0),h.addEventListener("progress",b)),d&&h.upload&&([p,S]=re(d),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(l=E=>{h&&(r(!E||E.type?new H(null,t,h):E),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const x=An(s.url);if(x&&R.protocols.indexOf(x)===-1){r(new y("Unsupported protocol "+x+":",y.ERR_BAD_REQUEST,t));return}h.send(o||null)})},Un=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof y?l:new H(l instanceof Error?l.message:l))}};let i=e&&setTimeout(()=>{i=null,o(new y(`timeout ${e} of ms exceeded`,y.ETIMEDOUT))},e);const c=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),t=null)};t.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},jn=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},Bn=async function*(t,e){for await(const n of Ln(t))yield*jn(n,e)},Ln=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},Le=(t,e,n,r)=>{const s=Bn(t,e);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let p=l.byteLength;if(n){let b=o+=p;n(b)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},$e=64*1024,{isFunction:Y}=a,$n=(({Request:t,Response:e})=>({Request:t,Response:e}))(a.global),{ReadableStream:De,TextEncoder:qe}=a.global,Me=(t,...e)=>{try{return!!t(...e)}catch{return!1}},Dn=t=>{t=a.merge.call({skipUndefined:!0},$n,t);const{fetch:e,Request:n,Response:r}=t,s=e?Y(e):typeof fetch=="function",o=Y(n),i=Y(r);if(!s)return!1;const c=s&&Y(De),d=s&&(typeof qe=="function"?(f=>m=>f.encode(m))(new qe):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&Me(()=>{let f=!1;const m=new n(R.origin,{body:new De,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&Me(()=>a.isReadableStream(new r("").body)),p={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!p[f]&&(p[f]=(m,h)=>{let g=m&&m[f];if(g)return g.call(m);throw new y(`Response type '${f}' is not supported`,y.ERR_NOT_SUPPORT,h)})});const b=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(R.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},S=async(f,m)=>{const h=a.toFiniteNumber(f.getContentLength());return h??b(m)};return async f=>{let{url:m,method:h,data:g,signal:x,cancelToken:E,timeout:O,onDownloadProgress:C,onUploadProgress:j,responseType:_,headers:le,withCredentials:X="same-origin",fetchOptions:Re}=ct(f),Oe=e||fetch;_=_?(_+"").toLowerCase():"text";let G=Un([x,E&&E.toAbortSignal()],O),Q=null;const B=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let Ae;try{if(j&&u&&h!=="get"&&h!=="head"&&(Ae=await S(le,g))!==0){let U=new n(m,{method:"POST",body:g,duplex:"half"}),q;if(a.isFormData(g)&&(q=U.headers.get("content-type"))&&le.setContentType(q),U.body){const[ue,Z]=Ue(Ae,re(je(j)));g=Le(U.body,$e,ue,Z)}}a.isString(X)||(X=X?"include":"omit");const N=o&&"credentials"in n.prototype,Te={...Re,signal:G,method:h.toUpperCase(),headers:le.normalize().toJSON(),body:g,duplex:"half",credentials:N?X:void 0};Q=o&&new n(m,Te);let P=await(o?Oe(Q,Re):Oe(m,Te));const xe=l&&(_==="stream"||_==="response");if(l&&(C||xe&&B)){const U={};["status","statusText","headers"].forEach(_e=>{U[_e]=P[_e]});const q=a.toFiniteNumber(P.headers.get("content-length")),[ue,Z]=C&&Ue(q,re(je(C),!0))||[];P=new r(Le(P.body,$e,ue,()=>{Z&&Z(),B&&B()}),U)}_=_||"text";let mt=await p[a.findKey(p,_)||"text"](P,f);return!xe&&B&&B(),await new Promise((U,q)=>{it(U,q,{data:mt,headers:T.from(P.headers),status:P.status,statusText:P.statusText,config:f,request:Q})})}catch(N){throw B&&B(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,f,Q),{cause:N.cause||N}):y.from(N,N&&N.code,f,Q)}}},qn=new Map,lt=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:s}=e,o=[r,s,n];let i=o.length,c=i,d,u,l=qn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Dn(e)),l=u;return u};lt();const Se={http:tn,xhr:Pn,fetch:{get:lt}};a.forEach(Se,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ie=t=>`- ${t}`,Mn=t=>a.isFunction(t)||t===null||t===!1;function In(t,e){t=a.isArray(t)?t:[t];const{length:n}=t;let r,s;const o={};for(let i=0;i<n;i++){r=t[i];let c;if(s=r,!Mn(r)&&(s=Se[(c=String(r)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
|
|
4
|
-
`+i.map(Ie).join(`
|
|
5
|
-
`):" "+Ie(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const ut={getAdapter:In,adapters:Se};function he(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new H(null,t)}function He(t){return he(t),t.headers=T.from(t.headers),t.data=de.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),ut.getAdapter(t.adapter||K.adapter,t)(t).then(function(r){return he(t),r.data=de.call(t,t.transformResponse,r),r.headers=T.from(r.headers),r},function(r){return ot(r)||(he(t),r&&r.response&&(r.response.data=de.call(t,t.transformResponse,r.response),r.response.headers=T.from(r.response.headers))),Promise.reject(r)})}const ft="1.13.2",ce={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{ce[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const Qe={};ce.transitional=function(e,n,r){function s(o,i){return"[Axios v"+ft+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(e===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!Qe[i]&&(Qe[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,i,c):!0}};ce.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Hn(t,e,n){if(typeof t!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let s=r.length;for(;s-- >0;){const o=r[s],i=e[o];if(i){const c=t[o],d=c===void 0||i(c,o,t);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const ne={assertOptions:Hn,validators:ce},k=ne.validators;let $=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ke,response:new ke}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
6
|
-
`+o):r.stack=o}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=D(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ne.assertOptions(r,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ne.assertOptions(s,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ne.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=T.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,p=0,b;if(!d){const f=[He.bind(this),void 0];for(f.unshift(...c),f.push(...u),b=f.length,l=Promise.resolve(n);p<b;)l=l.then(f[p++],f[p++]);return l}b=c.length;let S=n;for(;p<b;){const f=c[p++],m=c[p++];try{S=f(S)}catch(h){m.call(this,h);break}}try{l=He.call(this,S)}catch(f){return Promise.reject(f)}for(p=0,b=u.length;p<b;)l=l.then(u[p++],u[p++]);return l}getUri(e){e=D(this.defaults,e);const n=at(e.baseURL,e.url,e.allowAbsoluteUrls);return nt(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){$.prototype[e]=function(n,r){return this.request(D(r||{},{method:e,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(e){function n(r){return function(o,i,c){return this.request(D(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}$.prototype[e]=n(),$.prototype[e+"Form"]=n(!0)});let Qn=class dt{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,c){r.reason||(r.reason=new H(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new dt(function(s){e=s}),cancel:e}}};function Jn(t){return function(n){return t.apply(null,n)}}function zn(t){return a.isObject(t)&&t.isAxiosError===!0}const be={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(be).forEach(([t,e])=>{be[e]=t});function ht(t){const e=new $(t),n=Je($.prototype.request,e);return a.extend(n,$.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return ht(D(t,s))},n}const w=ht(K);w.Axios=$;w.CanceledError=H;w.CancelToken=Qn;w.isCancel=ot;w.VERSION=ft;w.toFormData=ae;w.AxiosError=y;w.Cancel=w.CanceledError;w.all=function(e){return Promise.all(e)};w.spread=Jn;w.isAxiosError=zn;w.mergeConfig=D;w.AxiosHeaders=T;w.formToJSON=t=>st(a.isHTMLForm(t)?new FormData(t):t);w.getAdapter=ut.getAdapter;w.HttpStatusCode=be;w.default=w;const{Axios:er,AxiosError:tr,CanceledError:nr,isCancel:rr,CancelToken:sr,VERSION:or,all:ir,Cancel:ar,isAxiosError:cr,spread:lr,toFormData:ur,AxiosHeaders:fr,HttpStatusCode:dr,formToJSON:hr,getAdapter:pr,mergeConfig:mr}=w,vn={Accept:"application/json","Content-Type":"application/json"};function Vn(t){return t.data}class Wn{root;config;constructor(e,n={}){this.root=e,this.config={...n,headers:{...vn,...n.headers||{}}}}async request(e,n,r,s){const o=`${this.root}${n}`,i={...this.config,...s},c=await(e==="get"||e==="delete"?w[e](o,i):w[e](o,r,i));return Vn(c)}async get(e,n){return this.request("get",e,void 0,n)}async post(e,n,r){return this.request("post",e,n,r)}async put(e,n,r){return this.request("put",e,n,r)}async del(e,n){return this.request("delete",e,void 0,n)}}const pt=["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"],Kn=1e3,Xn=5e3;class z{static buildJsonQuery(e){const n=[];for(const r in e){const s=e[r];if(s!==void 0)if(s===null)n.push(`${r}: null`);else if(Array.isArray(s)){const o=s;n.push(`${r}: [${o.map(i=>typeof i=="string"?`"${i}"`:i).join(", ")}]`)}else if(typeof s=="string")n.push(`${r}: "${s}"`);else if(typeof s=="object"){const o={},i={},c=s;for(const d in c){const u=c[d];if(d.startsWith("$")){const l=d.slice(1);pt.includes(l)?i[`${r}_${l}`]=u:o[d]=u}else o[d]=u}Object.keys(o).length>0&&n.push(`${r}: {${this.buildJsonQuery(o)}}`),Object.keys(i).length>0&&n.push(this.buildJsonQuery(i))}else n.push(`${r}: ${s}`)}return n.join(", ")}static buildElements(e){return e.map(n=>{if(typeof n=="string")return n;const r=n;return this.buildQuery({collection:r.collection,params:r.params})})}static buildMetadata(e){let n="";const r=[];e.blockQuery&&(e.blockQuery.hash&&r.push(`hash: "${e.blockQuery.hash}"`),e.blockQuery.number!==void 0&&r.push(`number: ${e.blockQuery.number}`),e.blockQuery.number_gte!==void 0&&r.push(`number_gte: ${e.blockQuery.number_gte}`));const s=r.join(", ");s.length>0&&(n+=`(block: {${s}})`);const o=[],i=[];if(e.elements){for(const u of e.elements)u==="deployment"||u==="hasIndexingErrors"?o.includes(u)||o.push(u):i.includes(u)||i.push(u);const c=i.join(" ");c.length>0&&o.push(`block{${c}}`);const d=o.join(" ");d.length>0&&(n+=`{${d}}`)}return n.length>0?`_meta${n}`:""}static _buildInlineFragment(e){const n=e.params?.elements?.length?this.buildElements(e.params.elements):["id"];return`... on ${e.collection}{${n.join(" ")}}`}static buildInlineFragments(e){return e.map(n=>this._buildInlineFragment(n)).join(" ")}static buildQuery(e,n){const{collection:r,params:s}=e,o=[];if(s?.id!==void 0&&o.push(`id: ${s.id}`),s?.orderBy&&o.push(`orderBy: ${s.orderBy}`),s?.orderDirection&&o.push(`orderDirection: ${s.orderDirection}`),s?.first!==void 0){const l=Math.max(0,Math.min(s.first,Kn));o.push(`first: ${l}`)}if(s?.skip!==void 0){const l=Math.max(0,Math.min(s.skip,Xn));o.push(`skip: ${l}`)}if(s?.where){const l=this.buildJsonQuery(s.where);l.length>0&&o.push(`where: {${l}}`)}if(s?.block){const l=this.buildJsonQuery(s.block);l.length>0&&o.push(`block: {${l}}`)}const i=o.length>0?`(${o.join(", ")})`:"";let c=["id"];s?.elements&&s.elements.length>0&&(c=this.buildElements(s.elements));let d="";s?.inlineFragments&&s.inlineFragments.length>0&&(d=` ${this.buildInlineFragments(s.inlineFragments)}`);const u=`${r}${i} {${c.join(" ")}${d}}`;if(n){const l=this.buildMetadata(n);return l?`${l} ${u}`:u}return u}static buildMultipleQuery(e,n){const s=e.map(o=>this.buildQuery({collection:o.collection,params:o.params})).join(" ");if(n){const o=this.buildMetadata(n);return o?`${o} ${s}`:s}return s}static makeFullQuery(e,n="query"){return`query ${n} {${e}}`}}class Gn extends Wn{queryName;constructor(e,n){super(e,n),this.queryName="query"}async stringQuery(e){const n=await this.post("",{query:e});if(n&&typeof n=="object"&&"errors"in n){const s=n.errors.map(o=>o.message).join("; ");throw new Error(`GraphQL Error: ${s}`)}return n.data}async query(e,n){const r=z.buildQuery(e,n);return this.stringQuery(z.makeFullQuery(r,this.queryName))}async multipleQuery(e,n){const r=z.buildMultipleQuery(e,n);return this.stringQuery(z.makeFullQuery(r,this.queryName))}}exports.EthGraphQuery=Gn;exports.OptionKeys=pt;exports.QueryBuilder=z;
|
|
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,3 +1,355 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Base class for handling API requests using fetch.
|
|
3
|
+
* Provides protected methods for common HTTP verbs.
|
|
4
|
+
*/
|
|
5
|
+
declare class ApiQuery {
|
|
6
|
+
/** The root URL for all API requests. */
|
|
7
|
+
root: string;
|
|
8
|
+
/** Request options used for all requests. */
|
|
9
|
+
config: RequestOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new instance of the ApiQuery class.
|
|
12
|
+
* @param rootUrl - The base URL for the API.
|
|
13
|
+
* @param config - Optional request configuration.
|
|
14
|
+
*/
|
|
15
|
+
constructor(rootUrl: string, config?: RequestOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Performs an API request.
|
|
18
|
+
* @template T - The expected response type.
|
|
19
|
+
* @param method - The HTTP method to use.
|
|
20
|
+
* @param url - The relative URL for the request.
|
|
21
|
+
* @param data - The request payload (for POST, PUT).
|
|
22
|
+
* @param config - Optional request configuration to override defaults.
|
|
23
|
+
* @returns A promise that resolves to the response data.
|
|
24
|
+
*/
|
|
25
|
+
private request;
|
|
26
|
+
/**
|
|
27
|
+
* Performs a GET request.
|
|
28
|
+
* @template T - The expected response type.
|
|
29
|
+
* @param url - The relative URL for the request.
|
|
30
|
+
* @param config - Optional request configuration to override defaults.
|
|
31
|
+
* @returns A promise that resolves to the response data.
|
|
32
|
+
*/
|
|
33
|
+
protected get<T = any>(url: string, config?: RequestOptions): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Performs a POST request.
|
|
36
|
+
* @template B - The request body type.
|
|
37
|
+
* @template T - The expected response type.
|
|
38
|
+
* @param url - The relative URL for the request.
|
|
39
|
+
* @param data - The request payload.
|
|
40
|
+
* @param config - Optional request configuration to override defaults.
|
|
41
|
+
* @returns A promise that resolves to the response data.
|
|
42
|
+
*/
|
|
43
|
+
protected post<B = any, T = any>(url: string, data?: B, config?: RequestOptions): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Performs a PUT request.
|
|
46
|
+
* @template B - The request body type.
|
|
47
|
+
* @template T - The expected response type.
|
|
48
|
+
* @param url - The relative URL for the request.
|
|
49
|
+
* @param data - The request payload.
|
|
50
|
+
* @param config - Optional request configuration to override defaults.
|
|
51
|
+
* @returns A promise that resolves to the response data.
|
|
52
|
+
*/
|
|
53
|
+
protected put<B = any, T = any>(url: string, data?: B, config?: RequestOptions): Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Performs a DELETE request.
|
|
56
|
+
* @template T - The expected response type.
|
|
57
|
+
* @param url - The relative URL for the request.
|
|
58
|
+
* @param config - Optional request configuration to override defaults.
|
|
59
|
+
* @returns A promise that resolves to the response data.
|
|
60
|
+
*/
|
|
61
|
+
protected del<T = any>(url: string, config?: RequestOptions): Promise<T>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Base types that can be used in query filters.
|
|
66
|
+
*/
|
|
67
|
+
export declare type BaseQueryType = string | number | boolean | Array<string | number | boolean> | null | undefined;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Filter for querying data at a specific block.
|
|
71
|
+
*/
|
|
72
|
+
export declare type BlockQuery = {
|
|
73
|
+
/** Filter by block hash. */
|
|
74
|
+
hash?: string;
|
|
75
|
+
/** Filter by exact block number. */
|
|
76
|
+
number?: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Common filter options for all field types.
|
|
81
|
+
*/
|
|
82
|
+
export declare type CommonWhereOptions = {
|
|
83
|
+
/** Greater than. */
|
|
84
|
+
$gt?: BaseQueryType;
|
|
85
|
+
/** Greater than or equal to. */
|
|
86
|
+
$gte?: BaseQueryType;
|
|
87
|
+
/** Less than. */
|
|
88
|
+
$lt?: BaseQueryType;
|
|
89
|
+
/** Less than or equal to. */
|
|
90
|
+
$lte?: BaseQueryType;
|
|
91
|
+
/** Not equal to. */
|
|
92
|
+
$not?: BaseQueryType;
|
|
93
|
+
/** Included in the provided array. */
|
|
94
|
+
$in?: BaseQueryType;
|
|
95
|
+
/** Not included in the provided array. */
|
|
96
|
+
$not_in?: BaseQueryType;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Represents a field in a query. Can be a simple string (field name)
|
|
101
|
+
* or a GraphObject for nested collection queries.
|
|
102
|
+
*/
|
|
103
|
+
export declare type ElementType = string | GraphObject;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Error structure returned by The Graph API.
|
|
107
|
+
*/
|
|
108
|
+
export declare type ErrorObject = {
|
|
109
|
+
/** List of errors encountered during query execution. */
|
|
110
|
+
errors: Array<{
|
|
111
|
+
message: string;
|
|
112
|
+
locations: Array<unknown>;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Main class for performing queries against The Graph protocols.
|
|
118
|
+
* Extends ApiQuery to handle HTTP communication.
|
|
119
|
+
*/
|
|
120
|
+
export declare class EthGraphQuery extends ApiQuery {
|
|
121
|
+
/** The name of the GraphQL query, used in makeFullQuery. */
|
|
122
|
+
queryName: string;
|
|
123
|
+
/**
|
|
124
|
+
* Initializes a new EthGraphQuery instance.
|
|
125
|
+
* @param rootUrl - The endpoint URL of the subgraph.
|
|
126
|
+
* @param config - Optional request configuration for custom headers or timeouts.
|
|
127
|
+
*/
|
|
128
|
+
constructor(rootUrl: string, config?: RequestOptions);
|
|
129
|
+
/**
|
|
130
|
+
* Executes a raw GraphQL query string.
|
|
131
|
+
* @template T - The expected return type of the data.
|
|
132
|
+
* @param data - The raw GraphQL query string.
|
|
133
|
+
* @returns A promise resolving to the query result.
|
|
134
|
+
* @throws Error if the response contains any GraphQL errors.
|
|
135
|
+
*/
|
|
136
|
+
stringQuery<T = any>(data: string): Promise<T>;
|
|
137
|
+
/**
|
|
138
|
+
* Executes a single collection query using a JSON configuration.
|
|
139
|
+
* @template T - The expected return type of the data.
|
|
140
|
+
* @param data - The configuration for the collection query.
|
|
141
|
+
* @param metadata - Optional metadata fields to include in the query.
|
|
142
|
+
* @returns A promise resolving to the fetched data.
|
|
143
|
+
*/
|
|
144
|
+
query<T = any>(data: GraphObject, metadata?: Metadata): Promise<T>;
|
|
145
|
+
/**
|
|
146
|
+
* Executes multiple collection queries in a single request using JSON configurations.
|
|
147
|
+
* @template T - The expected return type of the data.
|
|
148
|
+
* @param data - An array of query configurations.
|
|
149
|
+
* @param metadata - Optional metadata fields to include in the query.
|
|
150
|
+
* @returns A promise resolving to the merged results of all queries.
|
|
151
|
+
*/
|
|
152
|
+
multipleQuery<T = any>(data: Array<GraphObject>, metadata?: Metadata): Promise<T>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Configuration for a query against a specific collection.
|
|
157
|
+
*/
|
|
158
|
+
export declare interface GraphObject {
|
|
159
|
+
/** The name of the collection to query (e.g., 'users'). */
|
|
160
|
+
collection: string;
|
|
161
|
+
/** Optional parameters for filtering, sorting, and pagination. */
|
|
162
|
+
params?: GraphParams;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Parameters for a collection query.
|
|
167
|
+
*/
|
|
168
|
+
export declare interface GraphParams {
|
|
169
|
+
/** Fields to select from the collection. */
|
|
170
|
+
elements?: Array<ElementType>;
|
|
171
|
+
/** Inline fragments for selecting fields on specific types. */
|
|
172
|
+
inlineFragments?: Array<InlineFragmentType>;
|
|
173
|
+
/** Generic GraphQL arguments (schema-agnostic). */
|
|
174
|
+
args?: {
|
|
175
|
+
[key: string]: GraphQLArgValue;
|
|
176
|
+
};
|
|
177
|
+
/** The Graph-specific 'where' filter conditions. */
|
|
178
|
+
where?: QueryJson;
|
|
179
|
+
/** Filter by specific entity ID (shortcut for where: { id: ... }). */
|
|
180
|
+
id?: string;
|
|
181
|
+
/** Number of items to return. */
|
|
182
|
+
first?: number;
|
|
183
|
+
/** Field to sort the results by. */
|
|
184
|
+
orderBy?: string;
|
|
185
|
+
/** Direction of the sort (asc or desc). */
|
|
186
|
+
orderDirection?: 'asc' | 'desc';
|
|
187
|
+
/** Number of items to skip. */
|
|
188
|
+
skip?: number;
|
|
189
|
+
/** Re-run the query even if the subgraph has indexing errors. */
|
|
190
|
+
subgraphError?: 'allow' | 'deny';
|
|
191
|
+
/** Query the collection state at a specific block (The Graph). */
|
|
192
|
+
block?: BlockQuery;
|
|
193
|
+
}
|
|
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
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Represents an inline fragment for polymorphic types.
|
|
204
|
+
*/
|
|
205
|
+
export declare type InlineFragmentType = {
|
|
206
|
+
/** The collection name for the fragment (e.g., 'User'). */
|
|
207
|
+
collection: string;
|
|
208
|
+
/** Fields to select within the fragment. */
|
|
209
|
+
params?: {
|
|
210
|
+
elements?: Array<ElementType>;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Metadata fields to query from the subgraph (_meta).
|
|
216
|
+
*/
|
|
217
|
+
export declare type Metadata = {
|
|
218
|
+
/** Specific metadata elements to fetch. */
|
|
219
|
+
elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
|
|
220
|
+
/** Query metadata for a specific block. */
|
|
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;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Type representing the valid operator keys.
|
|
238
|
+
*/
|
|
239
|
+
export declare type OptionKey = (typeof OptionKeys)[number];
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Valid operator suffixes for The Graph queries (e.g., _gt, _in, _contains).
|
|
243
|
+
*/
|
|
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"];
|
|
245
|
+
|
|
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;
|
|
251
|
+
/**
|
|
252
|
+
* Converts a JSON query object into a GraphQL-compatible string.
|
|
253
|
+
* Handles nested objects and operator mapping (e.g., $gt -> _gt).
|
|
254
|
+
* @param query - The JSON filter object to build.
|
|
255
|
+
* @returns A string representing the GraphQL 'where' or 'block' filter.
|
|
256
|
+
*/
|
|
257
|
+
static buildJsonQuery(query: QueryJson): string;
|
|
258
|
+
/**
|
|
259
|
+
* Builds the fields/elements part of a GraphQL query from an array of strings or objects.
|
|
260
|
+
* @param elements - An array of fields to query. Can include nested collections as GraphObject.
|
|
261
|
+
* @returns An array of strings representing the selected fields.
|
|
262
|
+
*/
|
|
263
|
+
static buildElements(elements: Array<ElementType>): Array<string>;
|
|
264
|
+
/**
|
|
265
|
+
* Builds the metadata (_meta) fragment of a GraphQL query.
|
|
266
|
+
* @param metadata - The metadata configuration.
|
|
267
|
+
* @returns A string representing the _meta query fragment.
|
|
268
|
+
*/
|
|
269
|
+
static buildMetadata(metadata: Metadata): string;
|
|
270
|
+
/**
|
|
271
|
+
* Builds an inline fragment (... on Collection { ... }) for a query.
|
|
272
|
+
* @param fragment - The inline fragment configuration.
|
|
273
|
+
* @returns A string representing the inline fragment.
|
|
274
|
+
* @private
|
|
275
|
+
*/
|
|
276
|
+
private static _buildInlineFragment;
|
|
277
|
+
/**
|
|
278
|
+
* Builds multiple inline fragments from an array of fragment configurations.
|
|
279
|
+
* @param fragments - An array of inline fragments.
|
|
280
|
+
* @returns A string containing all built inline fragments.
|
|
281
|
+
*/
|
|
282
|
+
static buildInlineFragments(fragments: Array<InlineFragmentType>): string;
|
|
283
|
+
/**
|
|
284
|
+
* Builds a complete GraphQL query for a single collection.
|
|
285
|
+
* @param data - The collection and parameters for the query.
|
|
286
|
+
* @param metadata - Optional metadata configuration.
|
|
287
|
+
* @returns A string containing the GraphQL query for the collection.
|
|
288
|
+
*/
|
|
289
|
+
static buildQuery(data: GraphObject, metadata?: Metadata): string;
|
|
290
|
+
/**
|
|
291
|
+
* Builds a query that targets multiple collections simultaneously.
|
|
292
|
+
* @param data - An array of collection queries and their parameters.
|
|
293
|
+
* @param metadata - Optional metadata configuration that applies to the entire query.
|
|
294
|
+
* @returns A string containing the merged GraphQL query for multiple collections.
|
|
295
|
+
*/
|
|
296
|
+
static buildMultipleQuery(data: Array<GraphObject>, metadata?: Metadata): string;
|
|
297
|
+
/**
|
|
298
|
+
* Wraps a query fragment into a full GraphQL 'query' block.
|
|
299
|
+
* @param query - The query fragment to wrap.
|
|
300
|
+
* @param queryName - An optional name for the GraphQL query (defaults to 'query').
|
|
301
|
+
* @returns The full GraphQL query string.
|
|
302
|
+
*/
|
|
303
|
+
static makeFullQuery(query: string, queryName?: string): string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* JSON structure representing the 'where' filter in a query.
|
|
308
|
+
* Keys are field names, and values can be primitive values or WhereOptions.
|
|
309
|
+
*/
|
|
310
|
+
export declare type QueryJson = {
|
|
311
|
+
[key: string]: QueryJson | WhereOptions | BaseQueryType;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
declare type RequestOptions = {
|
|
315
|
+
headers?: Record<string, string>;
|
|
316
|
+
timeoutMs?: number;
|
|
317
|
+
signal?: AbortSignal;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Filter options for text-based fields.
|
|
322
|
+
*/
|
|
323
|
+
export declare type TextWhereOptions = {
|
|
324
|
+
/** Matches values containing the substring. */
|
|
325
|
+
$contains?: BaseQueryType;
|
|
326
|
+
/** Case-insensitive contains. */
|
|
327
|
+
$contains_nocase?: BaseQueryType;
|
|
328
|
+
/** Matches values ending with the substring. */
|
|
329
|
+
$ends_with?: BaseQueryType;
|
|
330
|
+
/** Case-insensitive ends_with. */
|
|
331
|
+
$end_with_nocase?: BaseQueryType;
|
|
332
|
+
/** Matches values starting with the substring. */
|
|
333
|
+
$starts_with?: BaseQueryType;
|
|
334
|
+
/** Case-insensitive starts_with. */
|
|
335
|
+
$starts_with_nocase?: BaseQueryType;
|
|
336
|
+
/** Matches values NOT containing the substring. */
|
|
337
|
+
$not_contains?: BaseQueryType;
|
|
338
|
+
/** Case-insensitive not_contains. */
|
|
339
|
+
$not_contains_nocase?: BaseQueryType;
|
|
340
|
+
/** Matches values NOT ending with the substring. */
|
|
341
|
+
$not_ends_with?: BaseQueryType;
|
|
342
|
+
/** Case-insensitive not_ends_with. */
|
|
343
|
+
$not_ends_with_nocase?: BaseQueryType;
|
|
344
|
+
/** Matches values NOT starting with the substring. */
|
|
345
|
+
$not_starts_with?: BaseQueryType;
|
|
346
|
+
/** Case-insensitive not_starts_with. */
|
|
347
|
+
$not_starts_with_nocase?: BaseQueryType;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Combined filter options for a field.
|
|
352
|
+
*/
|
|
353
|
+
export declare type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
354
|
+
|
|
355
|
+
export { }
|