eth-graph-query 1.0.63 → 1.1.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/README.md +0 -6
- package/dist/cjs/eth-graph-query.d.ts +41 -0
- package/dist/cjs/eth-graph-query.d.ts.map +1 -0
- package/dist/cjs/eth-graph-query.js +44 -0
- package/dist/cjs/eth-graph-query.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -40
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -61
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/normal-query.d.ts +1 -1
- package/dist/cjs/normal-query.d.ts.map +1 -1
- package/dist/cjs/normal-query.js +12 -33
- package/dist/cjs/normal-query.js.map +1 -1
- package/dist/cjs/query-builder.d.ts +2 -2
- package/dist/cjs/query-builder.d.ts.map +1 -1
- package/dist/cjs/query-builder.js +11 -14
- package/dist/cjs/query-builder.js.map +1 -1
- package/dist/cjs/type.d.ts +9 -9
- package/dist/cjs/type.d.ts.map +1 -1
- package/dist/cjs/type.js +1 -4
- package/dist/cjs/type.js.map +1 -1
- package/dist/esm/eth-graph-query.d.ts +41 -0
- package/dist/esm/eth-graph-query.d.ts.map +1 -0
- package/dist/esm/eth-graph-query.js +44 -0
- package/dist/esm/eth-graph-query.js.map +1 -0
- package/dist/esm/index.d.ts +3 -40
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -58
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/normal-query.d.ts +1 -1
- package/dist/esm/normal-query.d.ts.map +1 -1
- package/dist/esm/normal-query.js +10 -27
- package/dist/esm/normal-query.js.map +1 -1
- package/dist/esm/query-builder.d.ts +2 -2
- package/dist/esm/query-builder.d.ts.map +1 -1
- package/dist/esm/query-builder.js +10 -10
- package/dist/esm/query-builder.js.map +1 -1
- package/dist/esm/type.d.ts +9 -9
- package/dist/esm/type.d.ts.map +1 -1
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/eth-graph-query.ts +55 -0
- package/src/index.ts +3 -55
- package/src/normal-query.ts +1 -1
- package/src/query-builder.ts +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { NormalQuery } from './normal-query.js';
|
|
3
|
+
import { GraphParams, Metadata } from './type.js';
|
|
4
|
+
export declare class EthGraphQuery extends NormalQuery {
|
|
5
|
+
queryName: string;
|
|
6
|
+
/**
|
|
7
|
+
* The constructor for create a query instance.
|
|
8
|
+
* @param {string} rootUrl The url leading to the graph
|
|
9
|
+
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
10
|
+
*/
|
|
11
|
+
constructor(rootUrl: string, config?: AxiosRequestConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Given query string, returns the data respective with it.
|
|
14
|
+
* @param {string} query A query string containing all data you want to fetch
|
|
15
|
+
* @returns The data respective with the query string
|
|
16
|
+
*/
|
|
17
|
+
_fetch<T>(query: string): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a query to a particular collection, returns the data respective with the query data.
|
|
20
|
+
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
21
|
+
* 1. collection: string - collection name
|
|
22
|
+
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
23
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
24
|
+
* @returns The data respective with the query data
|
|
25
|
+
*/
|
|
26
|
+
query<T = any>(data: {
|
|
27
|
+
collection: string;
|
|
28
|
+
params?: GraphParams;
|
|
29
|
+
}, metadata?: Metadata): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a query to many collections, returns the data respective with the query data.
|
|
32
|
+
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
33
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
34
|
+
* @returns The data respective with the query data
|
|
35
|
+
*/
|
|
36
|
+
mergeQuery<T = any>(data: Array<{
|
|
37
|
+
collection: string;
|
|
38
|
+
params?: GraphParams;
|
|
39
|
+
}>, metadata?: Metadata): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=eth-graph-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-graph-query.d.ts","sourceRoot":"","sources":["../../src/eth-graph-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAElD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;IAKxD;;;;OAIG;IACG,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1C;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAKzG;;;;;OAKG;IACG,UAAU,CAAC,CAAC,GAAG,GAAG,EACtB,IAAI,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC,EACzD,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,CAAC,CAAC;CAId"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NormalQuery } from './normal-query.js';
|
|
2
|
+
import { QueryBuilder } from './query-builder.js';
|
|
3
|
+
export class EthGraphQuery extends NormalQuery {
|
|
4
|
+
/**
|
|
5
|
+
* The constructor for create a query instance.
|
|
6
|
+
* @param {string} rootUrl The url leading to the graph
|
|
7
|
+
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
8
|
+
*/
|
|
9
|
+
constructor(rootUrl, config) {
|
|
10
|
+
super(rootUrl, config);
|
|
11
|
+
this.queryName = 'query';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Given query string, returns the data respective with it.
|
|
15
|
+
* @param {string} query A query string containing all data you want to fetch
|
|
16
|
+
* @returns The data respective with the query string
|
|
17
|
+
*/
|
|
18
|
+
async _fetch(query) {
|
|
19
|
+
return await this.post('', { query: query });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a query to a particular collection, returns the data respective with the query data.
|
|
23
|
+
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
24
|
+
* 1. collection: string - collection name
|
|
25
|
+
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
26
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
27
|
+
* @returns The data respective with the query data
|
|
28
|
+
*/
|
|
29
|
+
async query(data, metadata) {
|
|
30
|
+
const sQuery = QueryBuilder.buildQuery({ collection: data.collection, params: data.params }, metadata);
|
|
31
|
+
return await this._fetch(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a query to many collections, returns the data respective with the query data.
|
|
35
|
+
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
36
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
37
|
+
* @returns The data respective with the query data
|
|
38
|
+
*/
|
|
39
|
+
async mergeQuery(data, metadata) {
|
|
40
|
+
const sQuery = QueryBuilder.mergeQuery(data, metadata);
|
|
41
|
+
return await this._fetch(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=eth-graph-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-graph-query.js","sourceRoot":"","sources":["../../src/eth-graph-query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,OAAO,aAAc,SAAQ,WAAW;IAG5C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAA2B;QACtD,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAI,KAAa;QAC3B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAuB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CAAU,IAAkD,EAAE,QAAmB;QAC1F,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;QACvG,OAAO,MAAM,IAAI,CAAC,MAAM,CAAI,YAAY,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,IAAyD,EACzD,QAAmB;QAEnB,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAI,YAAY,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;CACF"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default class EthGraphQuery extends NormalQuery {
|
|
5
|
-
queryName: string;
|
|
6
|
-
/**
|
|
7
|
-
* The constructor for create a query instance.
|
|
8
|
-
* @param {string} rootUrl The url leading to the graph
|
|
9
|
-
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
10
|
-
*/
|
|
11
|
-
constructor(rootUrl: string, config?: AxiosRequestConfig);
|
|
12
|
-
/**
|
|
13
|
-
* Given query string, returns the data respective with it.
|
|
14
|
-
* @param {string} query A query string containing all data you want to fetch
|
|
15
|
-
* @returns The data respective with the query string
|
|
16
|
-
*/
|
|
17
|
-
_fetch<T>(query: string): Promise<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Create a query to a particular collection, returns the data respective with the query data.
|
|
20
|
-
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
21
|
-
* 1. collection: string - collection name
|
|
22
|
-
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
23
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
24
|
-
* @returns The data respective with the query data
|
|
25
|
-
*/
|
|
26
|
-
query<T = any>(data: {
|
|
27
|
-
collection: string;
|
|
28
|
-
params?: GraphParams;
|
|
29
|
-
}, metadata?: Metadata): Promise<T>;
|
|
30
|
-
/**
|
|
31
|
-
* Create a query to many collections, returns the data respective with the query data.
|
|
32
|
-
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
33
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
34
|
-
* @returns The data respective with the query data
|
|
35
|
-
*/
|
|
36
|
-
mergeQuery<T = any>(data: Array<{
|
|
37
|
-
collection: string;
|
|
38
|
-
params?: GraphParams;
|
|
39
|
-
}>, metadata?: Metadata): Promise<T>;
|
|
40
|
-
}
|
|
1
|
+
export { EthGraphQuery } from './eth-graph-query.js';
|
|
2
|
+
export * from './query-builder.js';
|
|
3
|
+
export * from './type.js';
|
|
41
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,62 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const normal_query_1 = require("./normal-query");
|
|
13
|
-
const query_builder_1 = require("./query-builder");
|
|
14
|
-
class EthGraphQuery extends normal_query_1.default {
|
|
15
|
-
/**
|
|
16
|
-
* The constructor for create a query instance.
|
|
17
|
-
* @param {string} rootUrl The url leading to the graph
|
|
18
|
-
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
19
|
-
*/
|
|
20
|
-
constructor(rootUrl, config) {
|
|
21
|
-
super(rootUrl, config);
|
|
22
|
-
this.queryName = 'query';
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Given query string, returns the data respective with it.
|
|
26
|
-
* @param {string} query A query string containing all data you want to fetch
|
|
27
|
-
* @returns The data respective with the query string
|
|
28
|
-
*/
|
|
29
|
-
_fetch(query) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
return yield this.post('', { query: query });
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a query to a particular collection, returns the data respective with the query data.
|
|
36
|
-
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
37
|
-
* 1. collection: string - collection name
|
|
38
|
-
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
39
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
40
|
-
* @returns The data respective with the query data
|
|
41
|
-
*/
|
|
42
|
-
query(data, metadata) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const sQuery = query_builder_1.default.buildQuery({ collection: data.collection, params: data.params }, metadata);
|
|
45
|
-
return yield this._fetch(query_builder_1.default.makeFullQuery(sQuery, this.queryName));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Create a query to many collections, returns the data respective with the query data.
|
|
50
|
-
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
51
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
52
|
-
* @returns The data respective with the query data
|
|
53
|
-
*/
|
|
54
|
-
mergeQuery(data, metadata) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const sQuery = query_builder_1.default.mergeQuery(data, metadata);
|
|
57
|
-
return yield this._fetch(query_builder_1.default.makeFullQuery(sQuery, this.queryName));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.default = EthGraphQuery;
|
|
1
|
+
export { EthGraphQuery } from './eth-graph-query.js';
|
|
2
|
+
export * from './query-builder.js';
|
|
3
|
+
export * from './type.js';
|
|
62
4
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal-query.d.ts","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAEjE,eAAO,MAAM,aAAa;;;CAAqE,CAAC;AAMhG,
|
|
1
|
+
{"version":3,"file":"normal-query.d.ts","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAEjE,eAAO,MAAM,aAAa;;;CAAqE,CAAC;AAMhG,qBAAa,WAAW;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,kBAAkB,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAKxC,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAIrD,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAIzE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAIxE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;CAGtE"}
|
package/dist/cjs/normal-query.js
CHANGED
|
@@ -1,46 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.defaultHeader = void 0;
|
|
13
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
export const defaultHeader = { Accept: 'application/json', 'Content-Type': 'application/json' };
|
|
16
4
|
function responseBody(res) {
|
|
17
5
|
return res.data;
|
|
18
6
|
}
|
|
19
|
-
class NormalQuery {
|
|
7
|
+
export class NormalQuery {
|
|
20
8
|
constructor(rootUrl, config) {
|
|
21
9
|
this.root = rootUrl;
|
|
22
|
-
this.config = config ?
|
|
10
|
+
this.config = config ? { ...config, ...{ headers: defaultHeader } } : { headers: defaultHeader };
|
|
23
11
|
}
|
|
24
|
-
get(url, config) {
|
|
25
|
-
return
|
|
26
|
-
return yield axios_1.default.get(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config)).then(responseBody);
|
|
27
|
-
});
|
|
12
|
+
async get(url, config) {
|
|
13
|
+
return await axios.get(`${this.root}${url}`, { ...config, ...this.config }).then(responseBody);
|
|
28
14
|
}
|
|
29
|
-
post(url, data, config) {
|
|
30
|
-
return
|
|
31
|
-
return yield axios_1.default.post(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config)).then(responseBody);
|
|
32
|
-
});
|
|
15
|
+
async post(url, data, config) {
|
|
16
|
+
return await axios.post(`${this.root}${url}`, data, { ...config, ...this.config }).then(responseBody);
|
|
33
17
|
}
|
|
34
|
-
put(url, data, config) {
|
|
35
|
-
return
|
|
36
|
-
return yield axios_1.default.put(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config)).then(responseBody);
|
|
37
|
-
});
|
|
18
|
+
async put(url, data, config) {
|
|
19
|
+
return await axios.put(`${this.root}${url}`, data, { ...config, ...this.config }).then(responseBody);
|
|
38
20
|
}
|
|
39
|
-
del(url, config) {
|
|
40
|
-
return
|
|
41
|
-
return yield axios_1.default.delete(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config)).then(responseBody);
|
|
42
|
-
});
|
|
21
|
+
async del(url, config) {
|
|
22
|
+
return await axios.delete(`${this.root}${url}`, { ...config, ...this.config }).then(responseBody);
|
|
43
23
|
}
|
|
44
24
|
}
|
|
45
|
-
exports.default = NormalQuery;
|
|
46
25
|
//# sourceMappingURL=normal-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal-query.js","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normal-query.js","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;AAEhG,SAAS,YAAY,CAAI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IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAI,YAAY,CAAC,CAAC;IACvG,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementType, GraphParams, Metadata, QueryJson } from './type';
|
|
2
|
-
export
|
|
1
|
+
import { ElementType, GraphParams, Metadata, QueryJson } from './type.js';
|
|
2
|
+
export declare class QueryBuilder {
|
|
3
3
|
private static isWhereOptions;
|
|
4
4
|
/**
|
|
5
5
|
* Create a query string from a query with json format.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAA0B,SAAS,EAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAA0B,SAAS,EAAgB,MAAM,WAAW,CAAC;AAEhH,qBAAa,YAAY;IAEvB,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAwB/C;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IAYjE;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM;IA8BhD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAuClG;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAYzG;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAU,GAAG,MAAM;CAGjE"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const type_1 = require("./type");
|
|
4
|
-
class QueryBuilder {
|
|
1
|
+
import { OptionKeys } from './type.js';
|
|
2
|
+
export class QueryBuilder {
|
|
5
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
4
|
static isWhereOptions(data) {
|
|
7
5
|
const keys = Object.keys(data);
|
|
8
6
|
if (keys.length == 0)
|
|
9
7
|
return true;
|
|
10
8
|
for (const key of keys) {
|
|
11
|
-
if (!
|
|
9
|
+
if (!OptionKeys.includes(key))
|
|
12
10
|
return false;
|
|
13
11
|
}
|
|
14
12
|
return true;
|
|
@@ -118,39 +116,39 @@ class QueryBuilder {
|
|
|
118
116
|
const collection = data.collection;
|
|
119
117
|
const params = data.params;
|
|
120
118
|
const filters = [];
|
|
121
|
-
if (
|
|
119
|
+
if (params?.id != undefined)
|
|
122
120
|
filters.push(`id: ${params.id}`);
|
|
123
|
-
if (params
|
|
121
|
+
if (params?.orderBy)
|
|
124
122
|
filters.push(`orderBy: ${params.orderBy}`);
|
|
125
|
-
if (params
|
|
123
|
+
if (params?.orderDirection)
|
|
126
124
|
filters.push(`orderDirection: ${params.orderDirection}`);
|
|
127
|
-
if (
|
|
125
|
+
if (params?.first != undefined) {
|
|
128
126
|
if (params.first < 0)
|
|
129
127
|
params.first = 0;
|
|
130
128
|
else if (params.first > 1000)
|
|
131
129
|
params.first = 1000;
|
|
132
130
|
filters.push(`first: ${params.first}`);
|
|
133
131
|
}
|
|
134
|
-
if (
|
|
132
|
+
if (params?.skip != undefined) {
|
|
135
133
|
if (params.skip < 0)
|
|
136
134
|
params.skip = 0;
|
|
137
135
|
else if (params.skip > 5000)
|
|
138
136
|
params.skip = 5000;
|
|
139
137
|
filters.push(`skip: ${params.skip}`);
|
|
140
138
|
}
|
|
141
|
-
if (params
|
|
139
|
+
if (params?.where) {
|
|
142
140
|
const sWhere = this.buildJsonQuery(params.where);
|
|
143
141
|
if (sWhere.length > 0)
|
|
144
142
|
filters.push(`where: {${sWhere}}`);
|
|
145
143
|
}
|
|
146
|
-
if (params
|
|
144
|
+
if (params?.block) {
|
|
147
145
|
const sBlock = this.buildJsonQuery(params.block);
|
|
148
146
|
if (sBlock.length > 0)
|
|
149
147
|
filters.push(`block: {${sBlock}}`);
|
|
150
148
|
}
|
|
151
149
|
const filterString = filters.join(', ');
|
|
152
150
|
let elements = ['id'];
|
|
153
|
-
if (params
|
|
151
|
+
if (params?.elements)
|
|
154
152
|
if (params.elements.length > 0)
|
|
155
153
|
elements = this.buildElements(params.elements);
|
|
156
154
|
let finalQuery = '';
|
|
@@ -197,5 +195,4 @@ class QueryBuilder {
|
|
|
197
195
|
return `query ${queryName} {${query}}`;
|
|
198
196
|
}
|
|
199
197
|
}
|
|
200
|
-
exports.default = QueryBuilder;
|
|
201
198
|
//# sourceMappingURL=query-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,UAAU,EAAuC,MAAM,WAAW,CAAC;AAEhH,MAAM,OAAO,YAAY;IACvB,8DAA8D;IACtD,MAAM,CAAC,cAAc,CAAC,IAAS;QACrC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAA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M,GAAG,CAAC;gBAAE,OAAO,GAAG,SAAS,IAAI,UAAU,EAAE,CAAC;;gBACzD,OAAO,UAAU,CAAC;SACxB;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,IAAyD,EAAE,QAAmB;QAC9F,MAAM,OAAO,GAAkB,EAAE,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7G,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,EAAE;YACZ,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,GAAG,SAAS,IAAI,UAAU,EAAE,CAAC;;gBACzD,OAAO,UAAU,CAAC;SACxB;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAa,EAAE,SAAS,GAAG,OAAO;QACrD,OAAO,SAAS,SAAS,KAAK,KAAK,GAAG,CAAC;IACzC,CAAC;CACF"}
|
package/dist/cjs/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
type BaseQueryType = Array<string> | string | number | boolean | undefined;
|
|
1
|
+
declare type BaseQueryType = Array<string> | string | number | boolean | undefined;
|
|
2
2
|
export declare const OptionKeys: string[];
|
|
3
|
-
export type OptionsKey = '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';
|
|
4
|
-
export type TextWhereOptions = {
|
|
3
|
+
export declare type OptionsKey = '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';
|
|
4
|
+
export declare type TextWhereOptions = {
|
|
5
5
|
contains?: BaseQueryType;
|
|
6
6
|
contains_nocase?: BaseQueryType;
|
|
7
7
|
ends_with?: BaseQueryType;
|
|
@@ -15,7 +15,7 @@ export type TextWhereOptions = {
|
|
|
15
15
|
not_starts_with?: BaseQueryType;
|
|
16
16
|
not_starts_with_nocase?: BaseQueryType;
|
|
17
17
|
};
|
|
18
|
-
export type CommonWhereOptions = {
|
|
18
|
+
export declare type CommonWhereOptions = {
|
|
19
19
|
gt?: BaseQueryType;
|
|
20
20
|
gte?: BaseQueryType;
|
|
21
21
|
lt?: BaseQueryType;
|
|
@@ -24,20 +24,20 @@ export type CommonWhereOptions = {
|
|
|
24
24
|
in?: BaseQueryType;
|
|
25
25
|
not_in?: BaseQueryType;
|
|
26
26
|
};
|
|
27
|
-
export type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
28
|
-
export type QueryJson = {
|
|
27
|
+
export declare type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
28
|
+
export declare type QueryJson = {
|
|
29
29
|
[key: string]: QueryJson | WhereOptions | BaseQueryType;
|
|
30
30
|
};
|
|
31
|
-
export type BlockQuery = {
|
|
31
|
+
export declare type BlockQuery = {
|
|
32
32
|
hash?: string;
|
|
33
33
|
number?: number;
|
|
34
34
|
number_gte?: number;
|
|
35
35
|
};
|
|
36
|
-
export type Metadata = {
|
|
36
|
+
export declare type Metadata = {
|
|
37
37
|
elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
|
|
38
38
|
blockQuery?: BlockQuery;
|
|
39
39
|
};
|
|
40
|
-
export type ElementType = string | {
|
|
40
|
+
export declare type ElementType = string | {
|
|
41
41
|
collection: string;
|
|
42
42
|
params?: GraphParams;
|
|
43
43
|
};
|
package/dist/cjs/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,aAAK,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3E,eAAO,MAAM,UAAU,UAoBtB,CAAC;AACF,oBAAY,UAAU,GAClB,UAAU,GACV,iBAAiB,GACjB,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,oBAAoB,GACpB,cAAc,GACd,qBAAqB,GACrB,eAAe,GACf,sBAAsB,GACtB,iBAAiB,GACjB,wBAAwB,GACxB,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,KAAK,GACL,IAAI,GACJ,QAAQ,CAAC;AAEb,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,mBAAmB,CAAC,EAAE,aAAa,CAAC;IACpC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,s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CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB"}
|
package/dist/cjs/type.js
CHANGED
package/dist/cjs/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,oBAAoB;IACpB,cAAc;IACd,qBAAqB;IACrB,eAAe;IACf,sBAAsB;IACtB,iBAAiB;IACjB,wBAAwB;IACxB,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,QAAQ;CACT,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { NormalQuery } from './normal-query.js';
|
|
3
|
+
import { GraphParams, Metadata } from './type.js';
|
|
4
|
+
export declare class EthGraphQuery extends NormalQuery {
|
|
5
|
+
queryName: string;
|
|
6
|
+
/**
|
|
7
|
+
* The constructor for create a query instance.
|
|
8
|
+
* @param {string} rootUrl The url leading to the graph
|
|
9
|
+
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
10
|
+
*/
|
|
11
|
+
constructor(rootUrl: string, config?: AxiosRequestConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Given query string, returns the data respective with it.
|
|
14
|
+
* @param {string} query A query string containing all data you want to fetch
|
|
15
|
+
* @returns The data respective with the query string
|
|
16
|
+
*/
|
|
17
|
+
_fetch<T>(query: string): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a query to a particular collection, returns the data respective with the query data.
|
|
20
|
+
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
21
|
+
* 1. collection: string - collection name
|
|
22
|
+
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
23
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
24
|
+
* @returns The data respective with the query data
|
|
25
|
+
*/
|
|
26
|
+
query<T = any>(data: {
|
|
27
|
+
collection: string;
|
|
28
|
+
params?: GraphParams;
|
|
29
|
+
}, metadata?: Metadata): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a query to many collections, returns the data respective with the query data.
|
|
32
|
+
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
33
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
34
|
+
* @returns The data respective with the query data
|
|
35
|
+
*/
|
|
36
|
+
mergeQuery<T = any>(data: Array<{
|
|
37
|
+
collection: string;
|
|
38
|
+
params?: GraphParams;
|
|
39
|
+
}>, metadata?: Metadata): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=eth-graph-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-graph-query.d.ts","sourceRoot":"","sources":["../../src/eth-graph-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAElD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;IAKxD;;;;OAIG;IACG,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1C;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAKzG;;;;;OAKG;IACG,UAAU,CAAC,CAAC,GAAG,GAAG,EACtB,IAAI,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC,EACzD,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,CAAC,CAAC;CAId"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NormalQuery } from './normal-query.js';
|
|
2
|
+
import { QueryBuilder } from './query-builder.js';
|
|
3
|
+
export class EthGraphQuery extends NormalQuery {
|
|
4
|
+
/**
|
|
5
|
+
* The constructor for create a query instance.
|
|
6
|
+
* @param {string} rootUrl The url leading to the graph
|
|
7
|
+
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
8
|
+
*/
|
|
9
|
+
constructor(rootUrl, config) {
|
|
10
|
+
super(rootUrl, config);
|
|
11
|
+
this.queryName = 'query';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Given query string, returns the data respective with it.
|
|
15
|
+
* @param {string} query A query string containing all data you want to fetch
|
|
16
|
+
* @returns The data respective with the query string
|
|
17
|
+
*/
|
|
18
|
+
async _fetch(query) {
|
|
19
|
+
return await this.post('', { query: query });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a query to a particular collection, returns the data respective with the query data.
|
|
23
|
+
* @param {{ collection: string; params?: GraphParams }} data An data for create query, contains two elements:
|
|
24
|
+
* 1. collection: string - collection name
|
|
25
|
+
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
26
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
27
|
+
* @returns The data respective with the query data
|
|
28
|
+
*/
|
|
29
|
+
async query(data, metadata) {
|
|
30
|
+
const sQuery = QueryBuilder.buildQuery({ collection: data.collection, params: data.params }, metadata);
|
|
31
|
+
return await this._fetch(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a query to many collections, returns the data respective with the query data.
|
|
35
|
+
* @param {Array<{ collection: string; params?: GraphParams }>} data An array contain data to query to many collections
|
|
36
|
+
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
37
|
+
* @returns The data respective with the query data
|
|
38
|
+
*/
|
|
39
|
+
async mergeQuery(data, metadata) {
|
|
40
|
+
const sQuery = QueryBuilder.mergeQuery(data, metadata);
|
|
41
|
+
return await this._fetch(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=eth-graph-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-graph-query.js","sourceRoot":"","sources":["../../src/eth-graph-query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,OAAO,aAAc,SAAQ,WAAW;IAG5C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAA2B;QACtD,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAI,KAAa;QAC3B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAuB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CAAU,IAAkD,EAAE,QAAmB;QAC1F,MAAM,MAAM,GAAG,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