eth-graph-query 2.0.1 → 2.0.20
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 +79 -90
- package/dist/.vite/manifest.json +8 -0
- package/dist/api-query.d.ts +67 -0
- package/dist/eth-graph-query.d.ts +41 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2072 -0
- package/dist/query-builder.d.ts +56 -0
- package/dist/type.d.ts +149 -0
- package/package.json +35 -50
- package/dist/cjs/eth-graph-query.d.ts +0 -35
- package/dist/cjs/eth-graph-query.d.ts.map +0 -1
- package/dist/cjs/eth-graph-query.js +0 -69
- package/dist/cjs/eth-graph-query.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/normal-query.d.ts +0 -15
- package/dist/cjs/normal-query.d.ts.map +0 -1
- package/dist/cjs/normal-query.js +0 -65
- package/dist/cjs/normal-query.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/query-builder.d.ts +0 -52
- package/dist/cjs/query-builder.d.ts.map +0 -1
- package/dist/cjs/query-builder.js +0 -238
- package/dist/cjs/query-builder.js.map +0 -1
- package/dist/cjs/type.d.ts +0 -67
- package/dist/cjs/type.d.ts.map +0 -1
- package/dist/cjs/type.js +0 -25
- package/dist/cjs/type.js.map +0 -1
- package/dist/esm/eth-graph-query.d.ts +0 -35
- package/dist/esm/eth-graph-query.d.ts.map +0 -1
- package/dist/esm/eth-graph-query.js +0 -65
- package/dist/esm/eth-graph-query.js.map +0 -1
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/normal-query.d.ts +0 -15
- package/dist/esm/normal-query.d.ts.map +0 -1
- package/dist/esm/normal-query.js +0 -58
- package/dist/esm/normal-query.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/query-builder.d.ts +0 -52
- package/dist/esm/query-builder.d.ts.map +0 -1
- package/dist/esm/query-builder.js +0 -234
- package/dist/esm/query-builder.js.map +0 -1
- package/dist/esm/type.d.ts +0 -67
- package/dist/esm/type.d.ts.map +0 -1
- package/dist/esm/type.js +0 -22
- package/dist/esm/type.js.map +0 -1
- package/dist/tsconfig.prod.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.prod.esm.tsbuildinfo +0 -1
- package/src/eth-graph-query.ts +0 -61
- package/src/index.ts +0 -3
- package/src/normal-query.ts +0 -46
- package/src/query-builder.ts +0 -216
- package/src/type.ts +0 -89
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryBuilder = void 0;
|
|
4
|
-
const type_js_1 = require("./type.js");
|
|
5
|
-
class QueryBuilder {
|
|
6
|
-
/**
|
|
7
|
-
* Create a query string from a query with json format.
|
|
8
|
-
* @param {QueryJson} query the json format query
|
|
9
|
-
* @returns a query string respective with the json format query
|
|
10
|
-
*/
|
|
11
|
-
static buildJsonQuery(query) {
|
|
12
|
-
const whereList = [];
|
|
13
|
-
for (const key in query) {
|
|
14
|
-
if (query[key] !== undefined) {
|
|
15
|
-
if (query[key] === null)
|
|
16
|
-
whereList.push(`${key}: null`);
|
|
17
|
-
if (Array.isArray(query[key])) {
|
|
18
|
-
const queryArray = query[key];
|
|
19
|
-
whereList.push(`${key}: [${queryArray.map((item) => `"${item}"`).join(', ')}]`);
|
|
20
|
-
}
|
|
21
|
-
else if (typeof query[key] == 'string') {
|
|
22
|
-
whereList.push(`${key}: "${query[key]}"`);
|
|
23
|
-
}
|
|
24
|
-
else if (typeof query[key] == 'object') {
|
|
25
|
-
const normalJson = {};
|
|
26
|
-
const operatorJson = {};
|
|
27
|
-
const options = query[key];
|
|
28
|
-
for (const option in options) {
|
|
29
|
-
const value = options[option];
|
|
30
|
-
if (option.length == 1)
|
|
31
|
-
normalJson[option] = value;
|
|
32
|
-
else {
|
|
33
|
-
if (option[0] == '$') {
|
|
34
|
-
const realOperator = option.slice(1);
|
|
35
|
-
if (type_js_1.OptionKeys.includes(realOperator))
|
|
36
|
-
operatorJson[`${key}_${realOperator}`] = value;
|
|
37
|
-
}
|
|
38
|
-
else
|
|
39
|
-
normalJson[option] = value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (Object.keys(normalJson).length > 0)
|
|
43
|
-
whereList.push(`${key}: {${this.buildJsonQuery(normalJson)}}`);
|
|
44
|
-
if (Object.keys(operatorJson).length > 0)
|
|
45
|
-
whereList.push(this.buildJsonQuery(operatorJson));
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
whereList.push(`${key}: ${query[key]}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return whereList.join(', ');
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Given a json format array as element input, returns the string array represent elements you want to query in the graph.
|
|
55
|
-
* @param {Array<ElementType>} elements A array with {@link ElementType} elements, each element in the array represent a element in the graph you want to query
|
|
56
|
-
* @returns {Array<string>} The string array represent the input array
|
|
57
|
-
*/
|
|
58
|
-
static buildElements(elements) {
|
|
59
|
-
const elementList = [];
|
|
60
|
-
for (const element of elements) {
|
|
61
|
-
if (typeof element == 'string')
|
|
62
|
-
elementList.push(element);
|
|
63
|
-
else {
|
|
64
|
-
const object = element;
|
|
65
|
-
elementList.push(this.buildQuery({ collection: object.collection, params: object.params }));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return elementList;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Given a instance of {@link Metadata}, returns the string represent the metadata you want to query
|
|
72
|
-
* @param {Metadata} metadata The instance represent all metadata you want to query
|
|
73
|
-
* @returns The string represent the metadata you want to query
|
|
74
|
-
*/
|
|
75
|
-
static buildMetadata(metadata) {
|
|
76
|
-
let result = '';
|
|
77
|
-
const blockQuery = [];
|
|
78
|
-
if (metadata.blockQuery) {
|
|
79
|
-
if (metadata.blockQuery.hash)
|
|
80
|
-
blockQuery.push(`hash: "${metadata.blockQuery.hash}"`);
|
|
81
|
-
if (metadata.blockQuery.number)
|
|
82
|
-
blockQuery.push(`number: ${metadata.blockQuery.number}`);
|
|
83
|
-
if (metadata.blockQuery.number_gte)
|
|
84
|
-
blockQuery.push(`number_gte: ${metadata.blockQuery.number_gte}`);
|
|
85
|
-
}
|
|
86
|
-
const sBlockQuery = blockQuery.join(', ');
|
|
87
|
-
if (sBlockQuery.length > 0)
|
|
88
|
-
result += `(block: {${sBlockQuery}})`;
|
|
89
|
-
const filters = [];
|
|
90
|
-
const blockFilters = [];
|
|
91
|
-
if (metadata.elements) {
|
|
92
|
-
for (const filter of metadata.elements) {
|
|
93
|
-
if (filter == 'deployment' || filter == 'hasIndexingErrors') {
|
|
94
|
-
const sFilter = filter.toString();
|
|
95
|
-
if (!filters.includes(sFilter))
|
|
96
|
-
filters.push(sFilter);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const sFilter = filter.toString();
|
|
100
|
-
if (!blockFilters.includes(sFilter))
|
|
101
|
-
blockFilters.push(sFilter);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const blockFilterQuery = blockFilters.join(' ');
|
|
105
|
-
if (blockFilterQuery.length > 0)
|
|
106
|
-
filters.push(`block{${blockFilterQuery}}`);
|
|
107
|
-
const sFiltersQuery = filters.join(' ');
|
|
108
|
-
if (sFiltersQuery.length > 0)
|
|
109
|
-
result += `{${sFiltersQuery}}`;
|
|
110
|
-
}
|
|
111
|
-
return result.length > 0 ? `_meta${result}` : '';
|
|
112
|
-
}
|
|
113
|
-
static _buildInlineFragment(fragment) {
|
|
114
|
-
var _a;
|
|
115
|
-
let elements = ['id'];
|
|
116
|
-
if ((_a = fragment.params) === null || _a === void 0 ? void 0 : _a.elements)
|
|
117
|
-
elements = this.buildElements(fragment.params.elements);
|
|
118
|
-
return `... on ${fragment.collection}{${elements.join(' ')}}`;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Given a instance of Array<{@link InlineFragmentType}>, returns the string represent the inline fragments you want to query
|
|
122
|
-
* @param {Array<InlineFragmentType>} fragments The instance represent the inline fragments you want to query
|
|
123
|
-
* @returns The string represent the inline fragments you want to query
|
|
124
|
-
*/
|
|
125
|
-
static buildInlineFragments(fragments) {
|
|
126
|
-
const result = [];
|
|
127
|
-
for (const fragment of fragments) {
|
|
128
|
-
result.push(this._buildInlineFragment(fragment));
|
|
129
|
-
}
|
|
130
|
-
return result.join(' ');
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Given json data, returns the string query. This function only can create a string query for a particular collection.
|
|
134
|
-
* @param {GraphObject} data An data for create query, contains two elements:
|
|
135
|
-
* 1. collection: string - collection name
|
|
136
|
-
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
137
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
138
|
-
* @returns The string query
|
|
139
|
-
*/
|
|
140
|
-
static buildQuery(data, metadata) {
|
|
141
|
-
const collection = data.collection;
|
|
142
|
-
const params = data.params;
|
|
143
|
-
const filters = [];
|
|
144
|
-
// build id
|
|
145
|
-
if ((params === null || params === void 0 ? void 0 : params.id) != undefined)
|
|
146
|
-
filters.push(`id: ${params.id}`);
|
|
147
|
-
// build order
|
|
148
|
-
if (params === null || params === void 0 ? void 0 : params.orderBy)
|
|
149
|
-
filters.push(`orderBy: ${params.orderBy}`);
|
|
150
|
-
// build order direction
|
|
151
|
-
if (params === null || params === void 0 ? void 0 : params.orderDirection)
|
|
152
|
-
filters.push(`orderDirection: ${params.orderDirection}`);
|
|
153
|
-
//build first
|
|
154
|
-
if ((params === null || params === void 0 ? void 0 : params.first) != undefined) {
|
|
155
|
-
if (params.first < 0)
|
|
156
|
-
params.first = 0;
|
|
157
|
-
else if (params.first > 1000)
|
|
158
|
-
params.first = 1000;
|
|
159
|
-
filters.push(`first: ${params.first}`);
|
|
160
|
-
}
|
|
161
|
-
// build skip
|
|
162
|
-
if ((params === null || params === void 0 ? void 0 : params.skip) != undefined) {
|
|
163
|
-
if (params.skip < 0)
|
|
164
|
-
params.skip = 0;
|
|
165
|
-
else if (params.skip > 5000)
|
|
166
|
-
params.skip = 5000;
|
|
167
|
-
filters.push(`skip: ${params.skip}`);
|
|
168
|
-
}
|
|
169
|
-
// build where
|
|
170
|
-
if (params === null || params === void 0 ? void 0 : params.where) {
|
|
171
|
-
const sWhere = this.buildJsonQuery(params.where);
|
|
172
|
-
if (sWhere.length > 0)
|
|
173
|
-
filters.push(`where: {${sWhere}}`);
|
|
174
|
-
}
|
|
175
|
-
// build block
|
|
176
|
-
if (params === null || params === void 0 ? void 0 : params.block) {
|
|
177
|
-
const sBlock = this.buildJsonQuery(params.block);
|
|
178
|
-
if (sBlock.length > 0)
|
|
179
|
-
filters.push(`block: {${sBlock}}`);
|
|
180
|
-
}
|
|
181
|
-
const filterString = filters.join(', ');
|
|
182
|
-
// build elements
|
|
183
|
-
let elements = ['id'];
|
|
184
|
-
if (params === null || params === void 0 ? void 0 : params.elements)
|
|
185
|
-
if (params.elements.length > 0)
|
|
186
|
-
elements = this.buildElements(params.elements);
|
|
187
|
-
// build inline fragments
|
|
188
|
-
let inlineFragments = '';
|
|
189
|
-
if (params === null || params === void 0 ? void 0 : params.inlineFragments)
|
|
190
|
-
if (params.inlineFragments.length > 0)
|
|
191
|
-
inlineFragments = this.buildInlineFragments(params.inlineFragments);
|
|
192
|
-
let finalQuery = '';
|
|
193
|
-
const sElements = inlineFragments.length > 0 ? `${elements.join(' ')} ${inlineFragments}` : elements.join(' ');
|
|
194
|
-
if (filterString.length > 0)
|
|
195
|
-
finalQuery = `${collection}(${filterString}) {${sElements}}`;
|
|
196
|
-
else
|
|
197
|
-
finalQuery = `${collection} {${sElements}}`;
|
|
198
|
-
if (metadata) {
|
|
199
|
-
const sMetadata = this.buildMetadata(metadata);
|
|
200
|
-
if (sMetadata.length > 0)
|
|
201
|
-
return `${sMetadata} ${finalQuery}`;
|
|
202
|
-
else
|
|
203
|
-
return finalQuery;
|
|
204
|
-
}
|
|
205
|
-
return finalQuery;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Given a array contain many json data, return a query string represent a query to all collections that is in a array.
|
|
209
|
-
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
210
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
211
|
-
* @returns The query string
|
|
212
|
-
*/
|
|
213
|
-
static buildMultipleQuery(data, metadata) {
|
|
214
|
-
const queries = [];
|
|
215
|
-
for (const item of data)
|
|
216
|
-
queries.push(this.buildQuery({ collection: item.collection, params: item.params }));
|
|
217
|
-
const finalQuery = queries.join(' ');
|
|
218
|
-
if (metadata) {
|
|
219
|
-
const sMetadata = this.buildMetadata(metadata);
|
|
220
|
-
if (sMetadata.length > 0)
|
|
221
|
-
return `${sMetadata} ${finalQuery}`;
|
|
222
|
-
else
|
|
223
|
-
return finalQuery;
|
|
224
|
-
}
|
|
225
|
-
return finalQuery;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Create complete query string, you can use directly this query to query to the graph
|
|
229
|
-
* @param {string} query The query string
|
|
230
|
-
* @param {string} queryName The query name(default query)
|
|
231
|
-
* @returns The complete query string
|
|
232
|
-
*/
|
|
233
|
-
static makeFullQuery(query, queryName = 'query') {
|
|
234
|
-
return `query ${queryName} {${query}}`;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.QueryBuilder = QueryBuilder;
|
|
238
|
-
//# sourceMappingURL=query-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../src/query-builder.ts"],"names":[],"mappings":";;;AAAA,uCASmB;AAEnB,MAAa,YAAY;IAC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5MD,oCA4MC"}
|
package/dist/cjs/type.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
declare type BaseQueryType = Array<string | number | boolean> | string | number | boolean | null | undefined;
|
|
2
|
-
export declare const OptionKeys: string[];
|
|
3
|
-
export declare type TextWhereOptions = {
|
|
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;
|
|
16
|
-
};
|
|
17
|
-
export declare type CommonWhereOptions = {
|
|
18
|
-
$gt?: BaseQueryType;
|
|
19
|
-
$gte?: BaseQueryType;
|
|
20
|
-
$lt?: BaseQueryType;
|
|
21
|
-
$lte?: BaseQueryType;
|
|
22
|
-
$not?: BaseQueryType;
|
|
23
|
-
$in?: BaseQueryType;
|
|
24
|
-
$not_in?: BaseQueryType;
|
|
25
|
-
};
|
|
26
|
-
export declare type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
27
|
-
export declare type QueryJson = {
|
|
28
|
-
[key: string]: QueryJson | WhereOptions | BaseQueryType;
|
|
29
|
-
};
|
|
30
|
-
export declare type BlockQuery = {
|
|
31
|
-
hash?: string;
|
|
32
|
-
number?: number;
|
|
33
|
-
number_gte?: number;
|
|
34
|
-
};
|
|
35
|
-
export declare type Metadata = {
|
|
36
|
-
elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
|
|
37
|
-
blockQuery?: BlockQuery;
|
|
38
|
-
};
|
|
39
|
-
export declare type ElementType = string | GraphObject;
|
|
40
|
-
export declare type InlineFragmentType = {
|
|
41
|
-
collection: string;
|
|
42
|
-
params?: Pick<GraphParams, 'elements'>;
|
|
43
|
-
};
|
|
44
|
-
export interface GraphParams {
|
|
45
|
-
elements?: Array<ElementType>;
|
|
46
|
-
inlineFragments?: Array<InlineFragmentType>;
|
|
47
|
-
where?: QueryJson;
|
|
48
|
-
id?: string;
|
|
49
|
-
first?: number;
|
|
50
|
-
orderBy?: string;
|
|
51
|
-
orderDirection?: 'asc' | 'desc';
|
|
52
|
-
skip?: number;
|
|
53
|
-
subgraphError?: 'allow' | 'deny';
|
|
54
|
-
block?: BlockQuery;
|
|
55
|
-
}
|
|
56
|
-
export interface GraphObject {
|
|
57
|
-
collection: string;
|
|
58
|
-
params?: GraphParams;
|
|
59
|
-
}
|
|
60
|
-
export declare type ErrorObject = {
|
|
61
|
-
errors: Array<{
|
|
62
|
-
message: string;
|
|
63
|
-
locations: Array<unknown>;
|
|
64
|
-
}>;
|
|
65
|
-
};
|
|
66
|
-
export {};
|
|
67
|
-
//# sourceMappingURL=type.d.ts.map
|
package/dist/cjs/type.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,aAAK,aAAa,GACd,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAChC,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,CAAC;AAEd,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,CAAC;IAC7B,mBAAmB,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CAAC;AAEhG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,eAAe,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,oBAAY,WAAW,GAAG;IACxB,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC"}
|
package/dist/cjs/type.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OptionKeys = void 0;
|
|
4
|
-
exports.OptionKeys = [
|
|
5
|
-
'contains',
|
|
6
|
-
'contains_nocase',
|
|
7
|
-
'ends_with',
|
|
8
|
-
'end_with_nocase',
|
|
9
|
-
'starts_with',
|
|
10
|
-
'starts_with_nocase',
|
|
11
|
-
'not_contains',
|
|
12
|
-
'not_contains_nocase',
|
|
13
|
-
'not_ends_with',
|
|
14
|
-
'not_ends_with_nocase',
|
|
15
|
-
'not_starts_with',
|
|
16
|
-
'not_starts_with_nocase',
|
|
17
|
-
'gt',
|
|
18
|
-
'gte',
|
|
19
|
-
'lt',
|
|
20
|
-
'lte',
|
|
21
|
-
'not',
|
|
22
|
-
'in',
|
|
23
|
-
'not_in',
|
|
24
|
-
];
|
|
25
|
-
//# sourceMappingURL=type.js.map
|
package/dist/cjs/type.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":";;;AAQa,QAAA,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"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { NormalQuery } from './normal-query.js';
|
|
3
|
-
import { GraphObject, 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
|
-
stringQuery<T = any>(data: string): Promise<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Create a query to a particular collection, returns the data respective with the query data.
|
|
20
|
-
* @param {GraphObject} 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: GraphObject, metadata?: Metadata): Promise<T>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a query to many collections, returns the data respective with the query data.
|
|
29
|
-
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
30
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
31
|
-
* @returns The data respective with the query data
|
|
32
|
-
*/
|
|
33
|
-
multipleQuery<T = any>(data: Array<GraphObject>, metadata?: Metadata): Promise<T>;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=eth-graph-query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAE/D,qBAAa,aAAc,SAAQ,WAAW;IAC5C,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB;IAKxD;;;;OAIG;IACG,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IASpD;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IASxE;;;;;OAKG;IACG,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;CAIxF"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { NormalQuery } from './normal-query.js';
|
|
11
|
-
import { QueryBuilder } from './query-builder.js';
|
|
12
|
-
export class EthGraphQuery extends NormalQuery {
|
|
13
|
-
/**
|
|
14
|
-
* The constructor for create a query instance.
|
|
15
|
-
* @param {string} rootUrl The url leading to the graph
|
|
16
|
-
* @param {AxiosRequestConfig | undefined} config Config for base axios
|
|
17
|
-
*/
|
|
18
|
-
constructor(rootUrl, config) {
|
|
19
|
-
super(rootUrl, config);
|
|
20
|
-
this.queryName = 'query';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Given query string, returns the data respective with it.
|
|
24
|
-
* @param {string} query A query string containing all data you want to fetch
|
|
25
|
-
* @returns The data respective with the query string
|
|
26
|
-
*/
|
|
27
|
-
stringQuery(data) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const result = yield this.post('', { query: data });
|
|
30
|
-
if (result.errors) {
|
|
31
|
-
const _error = result;
|
|
32
|
-
throw new Error(_error.errors[0].message);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Create a query to a particular collection, returns the data respective with the query data.
|
|
39
|
-
* @param {GraphObject} data An data for create query, contains two elements:
|
|
40
|
-
* 1. collection: string - collection name
|
|
41
|
-
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
42
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
43
|
-
* @returns The data respective with the query data
|
|
44
|
-
*/
|
|
45
|
-
query(data, metadata) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const _data = data;
|
|
48
|
-
const sQuery = QueryBuilder.buildQuery({ collection: _data.collection, params: _data.params }, metadata);
|
|
49
|
-
return yield this.stringQuery(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Create a query to many collections, returns the data respective with the query data.
|
|
54
|
-
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
55
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
56
|
-
* @returns The data respective with the query data
|
|
57
|
-
*/
|
|
58
|
-
multipleQuery(data, metadata) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const sQuery = QueryBuilder.buildMultipleQuery(data, metadata);
|
|
61
|
-
return yield this.stringQuery(QueryBuilder.makeFullQuery(sQuery, this.queryName));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=eth-graph-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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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names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,15 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
export declare const defaultHeader: {
|
|
3
|
-
Accept: string;
|
|
4
|
-
'Content-Type': string;
|
|
5
|
-
};
|
|
6
|
-
export declare class NormalQuery {
|
|
7
|
-
root: string;
|
|
8
|
-
config: AxiosRequestConfig;
|
|
9
|
-
constructor(rootUrl: string, config?: AxiosRequestConfig);
|
|
10
|
-
protected get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
11
|
-
protected post<B = any, T = any>(url: string, data?: B, config?: AxiosRequestConfig): Promise<T>;
|
|
12
|
-
protected put<B = any, T = any>(url: string, data?: B, config?: AxiosRequestConfig): Promise<T>;
|
|
13
|
-
protected del<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=normal-query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;cASxC,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/esm/normal-query.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
-
import axios from 'axios';
|
|
12
|
-
export const defaultHeader = { Accept: 'application/json', 'Content-Type': 'application/json' };
|
|
13
|
-
function responseBody(res) {
|
|
14
|
-
return res.data;
|
|
15
|
-
}
|
|
16
|
-
export class NormalQuery {
|
|
17
|
-
constructor(rootUrl, config) {
|
|
18
|
-
var _a;
|
|
19
|
-
this.root = rootUrl;
|
|
20
|
-
if (config) {
|
|
21
|
-
this.config = config;
|
|
22
|
-
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.headers))
|
|
23
|
-
this.config.headers = {};
|
|
24
|
-
this.config['headers'] = Object.assign(Object.assign({}, this.config['headers']), defaultHeader);
|
|
25
|
-
}
|
|
26
|
-
else
|
|
27
|
-
this.config = { headers: defaultHeader };
|
|
28
|
-
}
|
|
29
|
-
get(url, config) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
return yield axios
|
|
32
|
-
.get(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config))
|
|
33
|
-
.then(responseBody);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
post(url, data, config) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return yield axios
|
|
39
|
-
.post(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config))
|
|
40
|
-
.then(responseBody);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
put(url, data, config) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return yield axios
|
|
46
|
-
.put(`${this.root}${url}`, data, Object.assign(Object.assign({}, config), this.config))
|
|
47
|
-
.then(responseBody);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
del(url, config) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
return yield axios
|
|
53
|
-
.delete(`${this.root}${url}`, Object.assign(Object.assign({}, config), this.config))
|
|
54
|
-
.then(responseBody);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=normal-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normal-query.js","sourceRoot":"","sources":["../../src/normal-query.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAAuD;AACvD,OAAO,KAA4C,MAAM,OAAO,CAAC;AA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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,KAAK;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"}
|
package/dist/esm/package.json
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ElementType, GraphObject, InlineFragmentType, Metadata, QueryJson } from './type.js';
|
|
2
|
-
export declare class QueryBuilder {
|
|
3
|
-
/**
|
|
4
|
-
* Create a query string from a query with json format.
|
|
5
|
-
* @param {QueryJson} query the json format query
|
|
6
|
-
* @returns a query string respective with the json format query
|
|
7
|
-
*/
|
|
8
|
-
static buildJsonQuery(query: QueryJson): string;
|
|
9
|
-
/**
|
|
10
|
-
* Given a json format array as element input, returns the string array represent elements you want to query in the graph.
|
|
11
|
-
* @param {Array<ElementType>} elements A array with {@link ElementType} elements, each element in the array represent a element in the graph you want to query
|
|
12
|
-
* @returns {Array<string>} The string array represent the input array
|
|
13
|
-
*/
|
|
14
|
-
static buildElements(elements: Array<ElementType>): Array<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Given a instance of {@link Metadata}, returns the string represent the metadata you want to query
|
|
17
|
-
* @param {Metadata} metadata The instance represent all metadata you want to query
|
|
18
|
-
* @returns The string represent the metadata you want to query
|
|
19
|
-
*/
|
|
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;
|
|
28
|
-
/**
|
|
29
|
-
* Given json data, returns the string query. This function only can create a string query for a particular collection.
|
|
30
|
-
* @param {GraphObject} data An data for create query, contains two elements:
|
|
31
|
-
* 1. collection: string - collection name
|
|
32
|
-
* 2. params: GraphParams | undefined - If it is defined, it create a query to the collection
|
|
33
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
34
|
-
* @returns The string query
|
|
35
|
-
*/
|
|
36
|
-
static buildQuery(data: GraphObject, metadata?: Metadata): string;
|
|
37
|
-
/**
|
|
38
|
-
* Given a array contain many json data, return a query string represent a query to all collections that is in a array.
|
|
39
|
-
* @param {Array<GraphObject>} data An array contain data to query to many collections
|
|
40
|
-
* @param {Metadata | undefined} metadata If it is defined, the query can get metadata that you defined
|
|
41
|
-
* @returns The query string
|
|
42
|
-
*/
|
|
43
|
-
static buildMultipleQuery(data: Array<GraphObject>, metadata?: Metadata): string;
|
|
44
|
-
/**
|
|
45
|
-
* Create complete query string, you can use directly this query to query to the graph
|
|
46
|
-
* @param {string} query The query string
|
|
47
|
-
* @param {string} queryName The query name(default query)
|
|
48
|
-
* @returns The complete query string
|
|
49
|
-
*/
|
|
50
|
-
static makeFullQuery(query: string, queryName?: string): string;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=query-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IAmC/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,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAahF;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAU,GAAG,MAAM;CAGjE"}
|