eth-graph-query 2.0.15 → 2.0.21
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/index.cjs +1 -6
- package/dist/index.d.ts +324 -3
- package/dist/index.js +210 -1599
- package/package.json +28 -33
- package/dist/api-query.d.ts +0 -14
- package/dist/eth-graph-query.d.ts +0 -34
- package/dist/query-builder.d.ts +0 -51
- package/dist/type.d.ts +0 -66
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eth-graph-query",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.21",
|
|
4
|
+
"description": "A lightweight and flexible library for building The Graph queries using simple JSON objects. Eliminate the need for complex string concatenation and maintain type-safe queries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
+
"sideEffects": false,
|
|
12
13
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
+
"build": "bun run clear && tsc && vite build",
|
|
14
15
|
"preview": "vite preview",
|
|
15
16
|
"clear": "rm -rf dist",
|
|
16
17
|
"test": "vitest run",
|
|
17
|
-
"prepare": "
|
|
18
|
-
"eslint": "eslint . --
|
|
19
|
-
"
|
|
18
|
+
"prepare": "bun run build && husky install",
|
|
19
|
+
"eslint": "eslint --config ./eslint.config.js --cache",
|
|
20
|
+
"format": "prettier --write .",
|
|
21
|
+
"prepublishOnly": "bun run clear && bun run build && bun run test"
|
|
20
22
|
},
|
|
21
23
|
"repository": {
|
|
22
24
|
"type": "git",
|
|
@@ -32,29 +34,28 @@
|
|
|
32
34
|
"url": "https://github.com/phamhongphuc1999/eth-graph-query/issues"
|
|
33
35
|
},
|
|
34
36
|
"homepage": "https://github.com/phamhongphuc1999/eth-graph-query#readme",
|
|
35
|
-
"
|
|
36
|
-
"axios": "^1.
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"axios": "^1.13.2"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@commitlint/cli": "^
|
|
40
|
-
"@commitlint/config-conventional": "^
|
|
41
|
-
"@
|
|
41
|
+
"@commitlint/cli": "^19.4.0",
|
|
42
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
43
|
+
"@eslint/js": "^9.29.0",
|
|
42
44
|
"@types/node": "^20.12.2",
|
|
43
|
-
"
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"eslint-
|
|
46
|
-
"eslint-import
|
|
47
|
-
"eslint-plugin-
|
|
48
|
-
"eslint-plugin-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
45
|
+
"axios": "^1.13.2",
|
|
46
|
+
"eslint": "^9.29.0",
|
|
47
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
48
|
+
"eslint-plugin-import": "^2.32.0",
|
|
49
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
50
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
51
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
52
|
+
"husky": "^9.1.6",
|
|
51
53
|
"path": "^0.12.7",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"vitest": "^1.4.0"
|
|
54
|
+
"typescript": "5.5.3",
|
|
55
|
+
"typescript-eslint": "^8.34.1",
|
|
56
|
+
"vite": "^7.2.7",
|
|
57
|
+
"vite-plugin-dts": "^4.5.4",
|
|
58
|
+
"vitest": "^4.0.15"
|
|
58
59
|
},
|
|
59
60
|
"contributors": [
|
|
60
61
|
{
|
|
@@ -64,18 +65,12 @@
|
|
|
64
65
|
}
|
|
65
66
|
],
|
|
66
67
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
68
|
-
"npm": ">=
|
|
68
|
+
"node": ">=20",
|
|
69
|
+
"npm": ">=10"
|
|
69
70
|
},
|
|
70
71
|
"commitlint": {
|
|
71
72
|
"extends": [
|
|
72
73
|
"@commitlint/config-conventional"
|
|
73
74
|
]
|
|
74
|
-
},
|
|
75
|
-
"lint-staged": {
|
|
76
|
-
"*.{js,jsx,ts,tsx}": "eslint --config ./.eslintrc-staged.cjs --cache --fix",
|
|
77
|
-
"*.{json,yml,md}": [
|
|
78
|
-
"prettier --write"
|
|
79
|
-
]
|
|
80
75
|
}
|
|
81
76
|
}
|
package/dist/api-query.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
export declare const defaultHeader: {
|
|
3
|
-
Accept: string;
|
|
4
|
-
'Content-Type': string;
|
|
5
|
-
};
|
|
6
|
-
export declare class ApiQuery {
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { ApiQuery } from './api-query';
|
|
3
|
-
import { GraphObject, Metadata } from './type';
|
|
4
|
-
export declare class EthGraphQuery extends ApiQuery {
|
|
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
|
-
}
|
package/dist/query-builder.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ElementType, GraphObject, InlineFragmentType, Metadata, QueryJson } from './type';
|
|
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
|
-
}
|
package/dist/type.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
type BaseQueryType = Array<string | number | boolean> | string | number | boolean | null | undefined;
|
|
2
|
-
export declare const OptionKeys: string[];
|
|
3
|
-
export 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 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 type WhereOptions = TextWhereOptions & CommonWhereOptions;
|
|
27
|
-
export type QueryJson = {
|
|
28
|
-
[key: string]: QueryJson | WhereOptions | BaseQueryType;
|
|
29
|
-
};
|
|
30
|
-
export type BlockQuery = {
|
|
31
|
-
hash?: string;
|
|
32
|
-
number?: number;
|
|
33
|
-
number_gte?: number;
|
|
34
|
-
};
|
|
35
|
-
export type Metadata = {
|
|
36
|
-
elements?: Array<'deployment' | 'hasIndexingErrors' | 'hash' | 'number' | 'timestamp'>;
|
|
37
|
-
blockQuery?: BlockQuery;
|
|
38
|
-
};
|
|
39
|
-
export type ElementType = string | GraphObject;
|
|
40
|
-
export 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 type ErrorObject = {
|
|
61
|
-
errors: Array<{
|
|
62
|
-
message: string;
|
|
63
|
-
locations: Array<unknown>;
|
|
64
|
-
}>;
|
|
65
|
-
};
|
|
66
|
-
export {};
|