eth-graph-query 1.1.1 → 1.1.3
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 +61 -12
- package/dist/cjs/eth-graph-query.d.ts +6 -12
- package/dist/cjs/eth-graph-query.d.ts.map +1 -1
- package/dist/cjs/eth-graph-query.js +5 -5
- package/dist/cjs/eth-graph-query.js.map +1 -1
- package/dist/cjs/normal-query.d.ts.map +1 -1
- package/dist/cjs/normal-query.js +14 -5
- package/dist/cjs/normal-query.js.map +1 -1
- package/dist/cjs/query-builder.d.ts +12 -12
- package/dist/cjs/query-builder.d.ts.map +1 -1
- package/dist/cjs/query-builder.js +57 -23
- package/dist/cjs/query-builder.js.map +1 -1
- package/dist/cjs/type.d.ts +27 -22
- package/dist/cjs/type.d.ts.map +1 -1
- package/dist/esm/eth-graph-query.d.ts +6 -12
- package/dist/esm/eth-graph-query.d.ts.map +1 -1
- package/dist/esm/eth-graph-query.js +5 -5
- package/dist/esm/eth-graph-query.js.map +1 -1
- package/dist/esm/normal-query.d.ts.map +1 -1
- package/dist/esm/normal-query.js +14 -5
- package/dist/esm/normal-query.js.map +1 -1
- package/dist/esm/query-builder.d.ts +12 -12
- package/dist/esm/query-builder.d.ts.map +1 -1
- package/dist/esm/query-builder.js +58 -24
- package/dist/esm/query-builder.js.map +1 -1
- package/dist/esm/type.d.ts +27 -22
- 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 +3 -3
- package/src/eth-graph-query.ts +12 -12
- package/src/normal-query.ts +15 -5
- package/src/query-builder.ts +76 -30
- package/src/type.ts +27 -40
package/README.md
CHANGED
|
@@ -29,26 +29,58 @@ yarn add eth-graph-query
|
|
|
29
29
|
const query = new EthGraphQuery(root);
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
- This package has
|
|
32
|
+
- This package has three query options. Simply, you can create a direct string query
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
|
-
|
|
35
|
+
result = await query.fetch(`query query {
|
|
36
|
+
collection1(first: 10) {
|
|
37
|
+
element1
|
|
38
|
+
element2
|
|
39
|
+
}
|
|
40
|
+
}`);
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
-
|
|
43
|
+
- More readable, you can create a single json query
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const result = await query.query({
|
|
47
|
+
collection: 'collection1',
|
|
48
|
+
params: {
|
|
49
|
+
elements: ['element1', 'element2'],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- You can create a multiple json queries
|
|
39
55
|
|
|
40
56
|
```js
|
|
41
57
|
const result = await query.mergeQuery([
|
|
42
|
-
{
|
|
43
|
-
|
|
58
|
+
{
|
|
59
|
+
collection: 'collection1',
|
|
60
|
+
params: {
|
|
61
|
+
elements: ['element11', 'element12'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
collection: 'collection2',
|
|
66
|
+
params: {
|
|
67
|
+
elements: ['element21', 'element22'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
44
70
|
]);
|
|
45
71
|
```
|
|
46
72
|
|
|
47
73
|
- You can create a complex query
|
|
48
74
|
|
|
49
75
|
```js
|
|
50
|
-
const
|
|
51
|
-
{
|
|
76
|
+
const result = await query.mergeQuery([
|
|
77
|
+
{
|
|
78
|
+
collection: 'collection1',
|
|
79
|
+
params: {
|
|
80
|
+
elements: ['element11', 'element12'],
|
|
81
|
+
where: { element11: 'abc' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
52
84
|
{
|
|
53
85
|
collection: 'collection2',
|
|
54
86
|
params: {
|
|
@@ -56,10 +88,17 @@ const result1 = await query.mergeQuery([
|
|
|
56
88
|
'element21',
|
|
57
89
|
{
|
|
58
90
|
collection: 'collection3',
|
|
59
|
-
params: {
|
|
91
|
+
params: {
|
|
92
|
+
elements: ['element31'],
|
|
93
|
+
where: { id: { $in: ['123'] }, element31: 'element31' },
|
|
94
|
+
first: 50,
|
|
95
|
+
},
|
|
60
96
|
},
|
|
61
97
|
],
|
|
62
|
-
where: {
|
|
98
|
+
where: {
|
|
99
|
+
element21: '123',
|
|
100
|
+
collection3: { element31: '123' },
|
|
101
|
+
},
|
|
63
102
|
},
|
|
64
103
|
},
|
|
65
104
|
]);
|
|
@@ -69,14 +108,24 @@ const result1 = await query.mergeQuery([
|
|
|
69
108
|
|
|
70
109
|
### API
|
|
71
110
|
|
|
72
|
-
Read the [API Docs](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/
|
|
111
|
+
Read the [API Docs](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/documents/api.md), you also read my [examples](https://github.com/phamhongphuc1999/eth-graph-query/blob/main/examples)
|
|
73
112
|
|
|
74
113
|
---
|
|
75
114
|
|
|
76
|
-
### For
|
|
115
|
+
### For developer
|
|
77
116
|
|
|
78
|
-
-
|
|
117
|
+
- Run example
|
|
118
|
+
|
|
119
|
+
```shell
|
|
120
|
+
npm run example example/file-name
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- Run test
|
|
79
124
|
|
|
80
125
|
```shell
|
|
81
126
|
npm run test
|
|
82
127
|
```
|
|
128
|
+
|
|
129
|
+
### Reference
|
|
130
|
+
|
|
131
|
+
- https://spec.graphql.org
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { NormalQuery } from './normal-query.js';
|
|
3
|
-
import {
|
|
3
|
+
import { GraphObject, Metadata } from './type.js';
|
|
4
4
|
export declare class EthGraphQuery extends NormalQuery {
|
|
5
5
|
queryName: string;
|
|
6
6
|
/**
|
|
@@ -14,28 +14,22 @@ export declare class EthGraphQuery extends NormalQuery {
|
|
|
14
14
|
* @param {string} query A query string containing all data you want to fetch
|
|
15
15
|
* @returns The data respective with the query string
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
fetch<T>(query: string): Promise<T>;
|
|
18
18
|
/**
|
|
19
19
|
* Create a query to a particular collection, returns the data respective with the query data.
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {GraphObject} data An data for create query, contains two elements:
|
|
21
21
|
* 1. collection: string - collection name
|
|
22
22
|
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
23
23
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
24
24
|
* @returns The data respective with the query data
|
|
25
25
|
*/
|
|
26
|
-
query<T = any>(data:
|
|
27
|
-
collection: string;
|
|
28
|
-
params?: GraphParams;
|
|
29
|
-
}, metadata?: Metadata): Promise<T>;
|
|
26
|
+
query<T = any>(data: GraphObject, metadata?: Metadata): Promise<T>;
|
|
30
27
|
/**
|
|
31
28
|
* Create a query to many collections, returns the data respective with the query data.
|
|
32
|
-
* @param {Array<
|
|
29
|
+
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
33
30
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
34
31
|
* @returns The data respective with the query data
|
|
35
32
|
*/
|
|
36
|
-
mergeQuery<T = any>(data: Array<
|
|
37
|
-
collection: string;
|
|
38
|
-
params?: GraphParams;
|
|
39
|
-
}>, metadata?: Metadata): Promise<T>;
|
|
33
|
+
mergeQuery<T = any>(data: Array<GraphObject>, metadata?: Metadata): Promise<T>;
|
|
40
34
|
}
|
|
41
35
|
//# sourceMappingURL=eth-graph-query.d.ts.map
|
|
@@ -1 +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,
|
|
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,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzC;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAQxE;;;;;OAKG;IACG,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;CAIrF"}
|
|
@@ -27,14 +27,14 @@ class EthGraphQuery extends normal_query_js_1.NormalQuery {
|
|
|
27
27
|
* @param {string} query A query string containing all data you want to fetch
|
|
28
28
|
* @returns The data respective with the query string
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
fetch(query) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
return yield this.post('', { query: query });
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Create a query to a particular collection, returns the data respective with the query data.
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {GraphObject} data An data for create query, contains two elements:
|
|
38
38
|
* 1. collection: string - collection name
|
|
39
39
|
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
40
40
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
@@ -43,19 +43,19 @@ class EthGraphQuery extends normal_query_js_1.NormalQuery {
|
|
|
43
43
|
query(data, metadata) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
const sQuery = query_builder_js_1.QueryBuilder.buildQuery({ collection: data.collection, params: data.params }, metadata);
|
|
46
|
-
return yield this.
|
|
46
|
+
return yield this.fetch(query_builder_js_1.QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Create a query to many collections, returns the data respective with the query data.
|
|
51
|
-
* @param {Array<
|
|
51
|
+
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
52
52
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
53
53
|
* @returns The data respective with the query data
|
|
54
54
|
*/
|
|
55
55
|
mergeQuery(data, metadata) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
const sQuery = query_builder_js_1.QueryBuilder.mergeQuery(data, metadata);
|
|
58
|
-
return yield this.
|
|
58
|
+
return yield this.fetch(query_builder_js_1.QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth-graph-query.js","sourceRoot":"","sources":["../../src/eth-graph-query.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,uDAAgD;AAChD,yDAAkD;AAGlD,MAAa,aAAc,SAAQ,6BAAW;IAG5C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAA2B;QACtD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@@
|
|
|
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;
|
|
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;cAOxC,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAMrD,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAMzE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,kBAAkB;cAMxE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;CAKtE"}
|
package/dist/cjs/normal-query.js
CHANGED
|
@@ -22,26 +22,35 @@ function responseBody(res) {
|
|
|
22
22
|
class NormalQuery {
|
|
23
23
|
constructor(rootUrl, config) {
|
|
24
24
|
this.root = rootUrl;
|
|
25
|
-
this.config = config
|
|
25
|
+
this.config = config
|
|
26
|
+
? Object.assign(Object.assign({}, config), { headers: exports.defaultHeader }) : { headers: exports.defaultHeader };
|
|
26
27
|
}
|
|
27
28
|
get(url, config) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return yield axios_1.default
|
|
30
|
+
return yield axios_1.default
|
|
31
|
+
.get(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config))
|
|
32
|
+
.then(responseBody);
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
35
|
post(url, data, config) {
|
|
33
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return yield axios_1.default
|
|
37
|
+
return yield axios_1.default
|
|
38
|
+
.post(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config))
|
|
39
|
+
.then(responseBody);
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
put(url, data, config) {
|
|
38
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
return yield axios_1.default
|
|
44
|
+
return yield axios_1.default
|
|
45
|
+
.put(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config))
|
|
46
|
+
.then(responseBody);
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
del(url, config) {
|
|
43
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return yield axios_1.default
|
|
51
|
+
return yield axios_1.default
|
|
52
|
+
.delete(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config))
|
|
53
|
+
.then(responseBody);
|
|
45
54
|
});
|
|
46
55
|
}
|
|
47
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal-query.js","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,kDAAiE;AAEpD,QAAA,aAAa,GAAG,EAAE,MAAM,EAAE,kBAAk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IAAI,CAAI,YAAY,CAAC,CAAC;QAC3B,CAAC;KAAA;IAEe,GAAG,CAAmB,GAAW,EAAE,IAAQ,EAAE,MAA2B;;YACtF,OAAO,MAAM,eAAK;iBACf,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,EAAE,IAAI,kCAAO,MAAM,GAAK,IAAI,CAAC,MAAM,EAAG;iBAC9D,IAAI,CAAI,YAAY,CAAC,CAAC;QAC3B,CAAC;KAAA;IAEe,GAAG,CAAU,GAAW,EAAE,MAA2B;;YACnE,OAAO,MAAM,eAAK;iBACf,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,kCAAO,MAAM,GAAK,IAAI,CAAC,MAAM,EAAG;iBAC3D,IAAI,CAAI,YAAY,CAAC,CAAC;QAC3B,CAAC;KAAA;CACF;AAlCD,kCAkCC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ElementType,
|
|
1
|
+
import { ElementType, GraphObject, InlineFragmentType, Metadata, QueryJson } from './type.js';
|
|
2
2
|
export declare class QueryBuilder {
|
|
3
|
-
private static isWhereOptions;
|
|
4
3
|
/**
|
|
5
4
|
* Create a query string from a query with json format.
|
|
6
5
|
* @param {QueryJson} query the json format query
|
|
@@ -19,28 +18,29 @@ export declare class QueryBuilder {
|
|
|
19
18
|
* @returns The string represent the metadata you want to query
|
|
20
19
|
*/
|
|
21
20
|
static buildMetadata(metadata: Metadata): string;
|
|
21
|
+
private static _buildInlineFragment;
|
|
22
|
+
/**
|
|
23
|
+
* Given a instance of Array<{@link InlineFragmentType}>, returns the string represent the inline fragments you want to query
|
|
24
|
+
* @param {Array<InlineFragmentType>} fragments The instance represent the inline fragments you want to query
|
|
25
|
+
* @returns The string represent the inline fragments you want to query
|
|
26
|
+
*/
|
|
27
|
+
static buildInlineFragments(fragments: Array<InlineFragmentType>): string;
|
|
22
28
|
/**
|
|
23
29
|
* Given json data, returns the string query. This function only can create a string query for a particular collection.
|
|
24
|
-
* @param {
|
|
30
|
+
* @param {GraphObject} data An data for create query, contains two elements:
|
|
25
31
|
* 1. collection: string - collection name
|
|
26
32
|
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
27
33
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
28
34
|
* @returns The string query
|
|
29
35
|
*/
|
|
30
|
-
static buildQuery(data:
|
|
31
|
-
collection: string;
|
|
32
|
-
params?: GraphParams;
|
|
33
|
-
}, metadata?: Metadata): string;
|
|
36
|
+
static buildQuery(data: GraphObject, metadata?: Metadata): string;
|
|
34
37
|
/**
|
|
35
38
|
* Given a array contain many json data, return a query string represent a query to all collections that is in a array.
|
|
36
|
-
* @param {Array<
|
|
39
|
+
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
37
40
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
38
41
|
* @returns The query string
|
|
39
42
|
*/
|
|
40
|
-
static mergeQuery(data: Array<
|
|
41
|
-
collection: string;
|
|
42
|
-
params?: GraphParams;
|
|
43
|
-
}>, metadata?: Metadata): string;
|
|
43
|
+
static mergeQuery(data: Array<GraphObject>, metadata?: Metadata): string;
|
|
44
44
|
/**
|
|
45
45
|
* Create complete query string, you can use directly this query to query to the graph
|
|
46
46
|
* @param {string} query The query string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EAEX,kBAAkB,EAClB,QAAQ,EAER,SAAS,EAEV,MAAM,WAAW,CAAC;AAEnB,qBAAa,YAAY;IACvB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAkC/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;IA+BhD,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAMnC;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,kBAAkB,CAAC,GAAG,MAAM;IAQzE;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAuDjE;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAaxE;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAU,GAAG,MAAM;CAGjE"}
|
|
@@ -3,17 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.QueryBuilder = void 0;
|
|
4
4
|
const type_js_1 = require("./type.js");
|
|
5
5
|
class QueryBuilder {
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
static isWhereOptions(data) {
|
|
8
|
-
const keys = Object.keys(data);
|
|
9
|
-
if (keys.length == 0)
|
|
10
|
-
return true;
|
|
11
|
-
for (const key of keys) {
|
|
12
|
-
if (!type_js_1.OptionKeys.includes(key))
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
6
|
/**
|
|
18
7
|
* Create a query string from a query with json format.
|
|
19
8
|
* @param {QueryJson} query the json format query
|
|
@@ -27,20 +16,32 @@ class QueryBuilder {
|
|
|
27
16
|
const queryArray = query[key];
|
|
28
17
|
whereList.push(`${key}: [${queryArray.map((item) => `"${item}"`).join(', ')}]`);
|
|
29
18
|
}
|
|
30
|
-
else if (
|
|
31
|
-
const
|
|
19
|
+
else if (typeof query[key] == 'object') {
|
|
20
|
+
const normalJson = {};
|
|
21
|
+
const operatorJson = {};
|
|
32
22
|
const options = query[key];
|
|
33
23
|
for (const option in options) {
|
|
34
24
|
const value = options[option];
|
|
35
|
-
if (
|
|
36
|
-
|
|
25
|
+
if (option.length == 1)
|
|
26
|
+
normalJson[option] = value;
|
|
27
|
+
else {
|
|
28
|
+
if (option[0] == '$') {
|
|
29
|
+
const realOperator = option.slice(1);
|
|
30
|
+
if (type_js_1.OptionKeys.includes(realOperator))
|
|
31
|
+
operatorJson[`${key}_${realOperator}`] = value;
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
normalJson[option] = value;
|
|
35
|
+
}
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
if (Object.keys(normalJson).length > 0)
|
|
38
|
+
whereList.push(`${key}: {${this.buildJsonQuery(normalJson)}}`);
|
|
39
|
+
if (Object.keys(operatorJson).length > 0)
|
|
40
|
+
whereList.push(this.buildJsonQuery(operatorJson));
|
|
39
41
|
}
|
|
40
|
-
else if (typeof query[key] == '
|
|
41
|
-
whereList.push(`${key}: {${this.buildJsonQuery(query[key])}}`);
|
|
42
|
-
else if (typeof query[key] == 'string')
|
|
42
|
+
else if (typeof query[key] == 'string') {
|
|
43
43
|
whereList.push(`${key}: "${query[key]}"`);
|
|
44
|
+
}
|
|
44
45
|
else
|
|
45
46
|
whereList.push(`${key}: ${query[key]}`);
|
|
46
47
|
}
|
|
@@ -107,9 +108,28 @@ class QueryBuilder {
|
|
|
107
108
|
}
|
|
108
109
|
return result.length > 0 ? `_meta${result}` : '';
|
|
109
110
|
}
|
|
111
|
+
static _buildInlineFragment(fragment) {
|
|
112
|
+
var _a;
|
|
113
|
+
let elements = ['id'];
|
|
114
|
+
if ((_a = fragment.params) === null || _a === void 0 ? void 0 : _a.elements)
|
|
115
|
+
elements = this.buildElements(fragment.params.elements);
|
|
116
|
+
return `... on ${fragment.collection}{${elements.join(' ')}}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Given a instance of Array<{@link InlineFragmentType}>, returns the string represent the inline fragments you want to query
|
|
120
|
+
* @param {Array<InlineFragmentType>} fragments The instance represent the inline fragments you want to query
|
|
121
|
+
* @returns The string represent the inline fragments you want to query
|
|
122
|
+
*/
|
|
123
|
+
static buildInlineFragments(fragments) {
|
|
124
|
+
const result = [];
|
|
125
|
+
for (const fragment of fragments) {
|
|
126
|
+
result.push(this._buildInlineFragment(fragment));
|
|
127
|
+
}
|
|
128
|
+
return result.join(' ');
|
|
129
|
+
}
|
|
110
130
|
/**
|
|
111
131
|
* Given json data, returns the string query. This function only can create a string query for a particular collection.
|
|
112
|
-
* @param {
|
|
132
|
+
* @param {GraphObject} data An data for create query, contains two elements:
|
|
113
133
|
* 1. collection: string - collection name
|
|
114
134
|
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
115
135
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
@@ -119,12 +139,16 @@ class QueryBuilder {
|
|
|
119
139
|
const collection = data.collection;
|
|
120
140
|
const params = data.params;
|
|
121
141
|
const filters = [];
|
|
142
|
+
// build id
|
|
122
143
|
if ((params === null || params === void 0 ? void 0 : params.id) != undefined)
|
|
123
144
|
filters.push(`id: ${params.id}`);
|
|
145
|
+
// build order
|
|
124
146
|
if (params === null || params === void 0 ? void 0 : params.orderBy)
|
|
125
147
|
filters.push(`orderBy: ${params.orderBy}`);
|
|
148
|
+
// build order direction
|
|
126
149
|
if (params === null || params === void 0 ? void 0 : params.orderDirection)
|
|
127
150
|
filters.push(`orderDirection: ${params.orderDirection}`);
|
|
151
|
+
//build first
|
|
128
152
|
if ((params === null || params === void 0 ? void 0 : params.first) != undefined) {
|
|
129
153
|
if (params.first < 0)
|
|
130
154
|
params.first = 0;
|
|
@@ -132,6 +156,7 @@ class QueryBuilder {
|
|
|
132
156
|
params.first = 1000;
|
|
133
157
|
filters.push(`first: ${params.first}`);
|
|
134
158
|
}
|
|
159
|
+
// build skip
|
|
135
160
|
if ((params === null || params === void 0 ? void 0 : params.skip) != undefined) {
|
|
136
161
|
if (params.skip < 0)
|
|
137
162
|
params.skip = 0;
|
|
@@ -139,26 +164,35 @@ class QueryBuilder {
|
|
|
139
164
|
params.skip = 5000;
|
|
140
165
|
filters.push(`skip: ${params.skip}`);
|
|
141
166
|
}
|
|
167
|
+
// build where
|
|
142
168
|
if (params === null || params === void 0 ? void 0 : params.where) {
|
|
143
169
|
const sWhere = this.buildJsonQuery(params.where);
|
|
144
170
|
if (sWhere.length > 0)
|
|
145
171
|
filters.push(`where: {${sWhere}}`);
|
|
146
172
|
}
|
|
173
|
+
// build block
|
|
147
174
|
if (params === null || params === void 0 ? void 0 : params.block) {
|
|
148
175
|
const sBlock = this.buildJsonQuery(params.block);
|
|
149
176
|
if (sBlock.length > 0)
|
|
150
177
|
filters.push(`block: {${sBlock}}`);
|
|
151
178
|
}
|
|
152
179
|
const filterString = filters.join(', ');
|
|
180
|
+
// build elements
|
|
153
181
|
let elements = ['id'];
|
|
154
182
|
if (params === null || params === void 0 ? void 0 : params.elements)
|
|
155
183
|
if (params.elements.length > 0)
|
|
156
184
|
elements = this.buildElements(params.elements);
|
|
185
|
+
// build inline fragments
|
|
186
|
+
let inlineFragments = '';
|
|
187
|
+
if (params === null || params === void 0 ? void 0 : params.inlineFragments)
|
|
188
|
+
if (params.inlineFragments.length > 0)
|
|
189
|
+
inlineFragments = this.buildInlineFragments(params.inlineFragments);
|
|
157
190
|
let finalQuery = '';
|
|
191
|
+
const sElements = inlineFragments.length > 0 ? `${elements.join(' ')} ${inlineFragments}` : elements.join(' ');
|
|
158
192
|
if (filterString.length > 0)
|
|
159
|
-
finalQuery = `${collection}(${filterString}) {${
|
|
193
|
+
finalQuery = `${collection}(${filterString}) {${sElements}}`;
|
|
160
194
|
else
|
|
161
|
-
finalQuery = `${collection} {${
|
|
195
|
+
finalQuery = `${collection} {${sElements}}`;
|
|
162
196
|
if (metadata) {
|
|
163
197
|
const sMetadata = this.buildMetadata(metadata);
|
|
164
198
|
if (sMetadata.length > 0)
|
|
@@ -170,7 +204,7 @@ class QueryBuilder {
|
|
|
170
204
|
}
|
|
171
205
|
/**
|
|
172
206
|
* Given a array contain many json data, return a query string represent a query to all collections that is in a array.
|
|
173
|
-
* @param {Array<
|
|
207
|
+
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
174
208
|
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
175
209
|
* @returns The query string
|
|
176
210
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":";;;AAAA,uCASmB;AAEnB,MAAa,YAAY;IACvB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAgB;QACpC,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;YACvB,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE;gBAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC7B,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAkB,CAAC;oBAC/C,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACjF;qBAAM,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE;oBACxC,MAAM,UAAU,GAAc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I,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtF,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;AA3MD,oCA2MC"}
|
package/dist/cjs/type.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
declare type BaseQueryType = Array<string> | string | number | boolean | undefined;
|
|
2
2
|
export declare const OptionKeys: string[];
|
|
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
3
|
export declare type TextWhereOptions = {
|
|
5
|
-
contains?: BaseQueryType;
|
|
6
|
-
contains_nocase?: BaseQueryType;
|
|
7
|
-
ends_with?: BaseQueryType;
|
|
8
|
-
end_with_nocase?: BaseQueryType;
|
|
9
|
-
starts_with?: BaseQueryType;
|
|
10
|
-
starts_with_nocase?: BaseQueryType;
|
|
11
|
-
not_contains?: BaseQueryType;
|
|
12
|
-
not_contains_nocase?: BaseQueryType;
|
|
13
|
-
not_ends_with?: BaseQueryType;
|
|
14
|
-
not_ends_with_nocase?: BaseQueryType;
|
|
15
|
-
not_starts_with?: BaseQueryType;
|
|
16
|
-
not_starts_with_nocase?: BaseQueryType;
|
|
4
|
+
$contains?: BaseQueryType;
|
|
5
|
+
$contains_nocase?: BaseQueryType;
|
|
6
|
+
$ends_with?: BaseQueryType;
|
|
7
|
+
$end_with_nocase?: BaseQueryType;
|
|
8
|
+
$starts_with?: BaseQueryType;
|
|
9
|
+
$starts_with_nocase?: BaseQueryType;
|
|
10
|
+
$not_contains?: BaseQueryType;
|
|
11
|
+
$not_contains_nocase?: BaseQueryType;
|
|
12
|
+
$not_ends_with?: BaseQueryType;
|
|
13
|
+
$not_ends_with_nocase?: BaseQueryType;
|
|
14
|
+
$not_starts_with?: BaseQueryType;
|
|
15
|
+
$not_starts_with_nocase?: BaseQueryType;
|
|
17
16
|
};
|
|
18
17
|
export declare type CommonWhereOptions = {
|
|
19
|
-
gt?: BaseQueryType;
|
|
20
|
-
gte?: BaseQueryType;
|
|
21
|
-
lt?: BaseQueryType;
|
|
22
|
-
lte?: BaseQueryType;
|
|
23
|
-
not?: BaseQueryType;
|
|
24
|
-
in?: BaseQueryType;
|
|
25
|
-
not_in?: BaseQueryType;
|
|
18
|
+
$gt?: BaseQueryType;
|
|
19
|
+
$gte?: BaseQueryType;
|
|
20
|
+
$lt?: BaseQueryType;
|
|
21
|
+
$lte?: BaseQueryType;
|
|
22
|
+
$not?: BaseQueryType;
|
|
23
|
+
$in?: BaseQueryType;
|
|
24
|
+
$not_in?: BaseQueryType;
|
|
26
25
|
};
|
|
27
26
|
export declare type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
28
27
|
export declare type QueryJson = {
|
|
@@ -37,12 +36,14 @@ export declare type Metadata = {
|
|
|
37
36
|
elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
|
|
38
37
|
blockQuery?: BlockQuery;
|
|
39
38
|
};
|
|
40
|
-
export declare type ElementType = string |
|
|
39
|
+
export declare type ElementType = string | GraphObject;
|
|
40
|
+
export declare type InlineFragmentType = {
|
|
41
41
|
collection: string;
|
|
42
|
-
params?: GraphParams
|
|
42
|
+
params?: Pick<GraphParams, 'elements'>;
|
|
43
43
|
};
|
|
44
44
|
export interface GraphParams {
|
|
45
45
|
elements?: Array<ElementType>;
|
|
46
|
+
inlineFragments?: Array<InlineFragmentType>;
|
|
46
47
|
where?: QueryJson;
|
|
47
48
|
id?: string;
|
|
48
49
|
first?: number;
|
|
@@ -52,5 +53,9 @@ export interface GraphParams {
|
|
|
52
53
|
subgraphError?: 'allow' | 'deny';
|
|
53
54
|
block?: BlockQuery;
|
|
54
55
|
}
|
|
56
|
+
export interface GraphObject {
|
|
57
|
+
collection: string;
|
|
58
|
+
params?: GraphParams;
|
|
59
|
+
}
|
|
55
60
|
export {};
|
|
56
61
|
//# sourceMappingURL=type.d.ts.map
|
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,aAAK,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3E,eAAO,MAAM,UAAU,UAoBtB,CAAC;
|
|
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;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,gBAAgB,CAAC,EAAE,aAAa,CAAC;IACjC,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,gBAAgB,CAAC,EAAE,aAAa,CAAC;IACjC,YAAY,CAAC,EAAE,aAAa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