@0xobelisk/grpc-client 1.2.0-pre.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +92 -0
- package/README.md +407 -0
- package/dist/client.d.ts +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +899 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +867 -0
- package/dist/index.mjs.map +1 -0
- package/dist/proto/dubhe_grpc.client.d.ts +54 -0
- package/dist/proto/dubhe_grpc.d.ts +534 -0
- package/dist/proto/google/protobuf/struct.d.ts +186 -0
- package/dist/types.d.ts +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/to-json.d.ts +3 -0
- package/package.json +71 -0
- package/src/client.ts +28 -0
- package/src/index.ts +30 -0
- package/src/proto/dubhe_grpc.client.ts +83 -0
- package/src/proto/dubhe_grpc.ts +727 -0
- package/src/proto/google/protobuf/struct.ts +585 -0
- package/src/types.ts +24 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/to-json.ts +7 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type DubheMetadata = {
|
|
2
|
+
components: Array<Record<string, {
|
|
3
|
+
fields: Array<Record<string, any>>;
|
|
4
|
+
keys: string[];
|
|
5
|
+
offchain?: boolean;
|
|
6
|
+
}>>;
|
|
7
|
+
resources: Array<Record<string, {
|
|
8
|
+
fields: Array<Record<string, any>>;
|
|
9
|
+
keys: string[];
|
|
10
|
+
offchain?: boolean;
|
|
11
|
+
}>>;
|
|
12
|
+
enums: any[];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './to-json';
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0xobelisk/grpc-client",
|
|
3
|
+
"version": "1.2.0-pre.100",
|
|
4
|
+
"description": "Toolkit for interacting with dubhe gRPC indexer",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sui",
|
|
7
|
+
"obelisk labs",
|
|
8
|
+
"move",
|
|
9
|
+
"blockchain",
|
|
10
|
+
"grpc",
|
|
11
|
+
"indexer"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/0xobelisk/dubhe/tree/main/packages/grpc-client#readme",
|
|
14
|
+
"bugs": "https://github.com/0xobelisk/dubhe/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/0xobelisk/dubhe.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"author": "team@obelisk.build",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"source": "./src/index.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"module": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@protobuf-ts/grpcweb-transport": "^2.11.1",
|
|
38
|
+
"@protobuf-ts/runtime": "^2.11.1",
|
|
39
|
+
"@protobuf-ts/runtime-rpc": "^2.11.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@protobuf-ts/plugin": "^2.11.1",
|
|
43
|
+
"@types/node": "^24.2.0",
|
|
44
|
+
"dotenv": "^16.3.1",
|
|
45
|
+
"eslint": "^9.0.0",
|
|
46
|
+
"eslint-config-prettier": "^9.1.0",
|
|
47
|
+
"prettier": "3.3.3",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"tsconfig-paths": "^4.2.0",
|
|
50
|
+
"tsup": "^7.1.0",
|
|
51
|
+
"typescript": "^5.2.2"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.0.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "pnpm run build:types && pnpm run build:tsup",
|
|
61
|
+
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
|
|
62
|
+
"build:types": "tsc --build",
|
|
63
|
+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
64
|
+
"generate": "rm -rf src/proto && mkdir src/proto && pnpm generate:proto && pnpm lint && pnpm prettier:fix",
|
|
65
|
+
"generate:proto": "protoc --ts_out=./src/proto --ts_opt force_server_none --ts_opt optimize_code_size --ts_opt ts_nocheck -I ../../crates/dubhe-indexer-grpc/proto ../../crates/dubhe-indexer-grpc/proto/dubhe_grpc.proto",
|
|
66
|
+
"lint": "eslint . --ext .ts",
|
|
67
|
+
"prettier:check": "prettier -c --ignore-unknown .",
|
|
68
|
+
"prettier:fix": "prettier -w --ignore-unknown .",
|
|
69
|
+
"type-check": "tsc --noEmit"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';
|
|
2
|
+
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';
|
|
3
|
+
import { DubheGrpcClient as ProtoDubheGrpcClient } from './proto/dubhe_grpc.client';
|
|
4
|
+
|
|
5
|
+
export class DubheGrpcClient {
|
|
6
|
+
public dubheGrpcClient: ProtoDubheGrpcClient;
|
|
7
|
+
private currentOptions: GrpcWebOptions;
|
|
8
|
+
|
|
9
|
+
constructor(options: GrpcWebOptions) {
|
|
10
|
+
this.currentOptions = options;
|
|
11
|
+
this.dubheGrpcClient = new ProtoDubheGrpcClient(new GrpcWebFetchTransport(options));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Update gRPC configuration dynamically
|
|
16
|
+
* @param options - Partial configuration to update (same type as constructor)
|
|
17
|
+
*/
|
|
18
|
+
updateConfig(options: Partial<GrpcWebOptions>) {
|
|
19
|
+
// Merge with current options
|
|
20
|
+
this.currentOptions = {
|
|
21
|
+
...this.currentOptions,
|
|
22
|
+
...options
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Recreate transport and client with new options
|
|
26
|
+
this.dubheGrpcClient = new ProtoDubheGrpcClient(new GrpcWebFetchTransport(this.currentOptions));
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Type exports
|
|
2
|
+
export * from './types';
|
|
3
|
+
|
|
4
|
+
// Protobuf client export (for advanced usage)
|
|
5
|
+
export { DubheGrpcClient as ProtoDubheGrpcClient } from './proto/dubhe_grpc.client';
|
|
6
|
+
|
|
7
|
+
// Re-export protobuf enums as values
|
|
8
|
+
export { FilterOperator, SortDirection } from './proto/dubhe_grpc';
|
|
9
|
+
|
|
10
|
+
// Re-export protobuf types
|
|
11
|
+
export type {
|
|
12
|
+
QueryRequest,
|
|
13
|
+
QueryResponse,
|
|
14
|
+
SubscribeRequest,
|
|
15
|
+
TableChange,
|
|
16
|
+
FilterCondition,
|
|
17
|
+
FilterValue,
|
|
18
|
+
SortSpecification,
|
|
19
|
+
PaginationRequest,
|
|
20
|
+
PaginationResponse
|
|
21
|
+
} from './proto/dubhe_grpc';
|
|
22
|
+
|
|
23
|
+
// Re-export protobuf types
|
|
24
|
+
export { Struct } from './proto/google/protobuf/struct';
|
|
25
|
+
|
|
26
|
+
// Utils
|
|
27
|
+
export * from './utils';
|
|
28
|
+
|
|
29
|
+
// Index
|
|
30
|
+
export { DubheGrpcClient } from './client';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// @generated by protobuf-ts 2.11.1 with parameter force_server_none,optimize_code_size,ts_nocheck
|
|
2
|
+
// @generated from protobuf file "dubhe_grpc.proto" (package "dubhe_grpc", syntax proto3)
|
|
3
|
+
// tslint:disable
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
|
|
6
|
+
import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
|
|
7
|
+
import { DubheGrpc } from './dubhe_grpc';
|
|
8
|
+
import type { TableChange } from './dubhe_grpc';
|
|
9
|
+
import type { SubscribeRequest } from './dubhe_grpc';
|
|
10
|
+
import type { ServerStreamingCall } from '@protobuf-ts/runtime-rpc';
|
|
11
|
+
import { stackIntercept } from '@protobuf-ts/runtime-rpc';
|
|
12
|
+
import type { QueryResponse } from './dubhe_grpc';
|
|
13
|
+
import type { QueryRequest } from './dubhe_grpc';
|
|
14
|
+
import type { UnaryCall } from '@protobuf-ts/runtime-rpc';
|
|
15
|
+
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
16
|
+
/**
|
|
17
|
+
* GRPC service definition
|
|
18
|
+
*
|
|
19
|
+
* @generated from protobuf service dubhe_grpc.DubheGrpc
|
|
20
|
+
*/
|
|
21
|
+
export interface IDubheGrpcClient {
|
|
22
|
+
/**
|
|
23
|
+
* Query data from a specific table with filters, sorting, and pagination
|
|
24
|
+
*
|
|
25
|
+
* @generated from protobuf rpc: QueryTable
|
|
26
|
+
*/
|
|
27
|
+
queryTable(input: QueryRequest, options?: RpcOptions): UnaryCall<QueryRequest, QueryResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribe to table updates
|
|
30
|
+
*
|
|
31
|
+
* @generated from protobuf rpc: SubscribeTable
|
|
32
|
+
*/
|
|
33
|
+
subscribeTable(
|
|
34
|
+
input: SubscribeRequest,
|
|
35
|
+
options?: RpcOptions
|
|
36
|
+
): ServerStreamingCall<SubscribeRequest, TableChange>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* GRPC service definition
|
|
40
|
+
*
|
|
41
|
+
* @generated from protobuf service dubhe_grpc.DubheGrpc
|
|
42
|
+
*/
|
|
43
|
+
export class DubheGrpcClient implements IDubheGrpcClient, ServiceInfo {
|
|
44
|
+
typeName = DubheGrpc.typeName;
|
|
45
|
+
methods = DubheGrpc.methods;
|
|
46
|
+
options = DubheGrpc.options;
|
|
47
|
+
constructor(private readonly _transport: RpcTransport) {}
|
|
48
|
+
/**
|
|
49
|
+
* Query data from a specific table with filters, sorting, and pagination
|
|
50
|
+
*
|
|
51
|
+
* @generated from protobuf rpc: QueryTable
|
|
52
|
+
*/
|
|
53
|
+
queryTable(input: QueryRequest, options?: RpcOptions): UnaryCall<QueryRequest, QueryResponse> {
|
|
54
|
+
const method = this.methods[0],
|
|
55
|
+
opt = this._transport.mergeOptions(options);
|
|
56
|
+
return stackIntercept<QueryRequest, QueryResponse>(
|
|
57
|
+
'unary',
|
|
58
|
+
this._transport,
|
|
59
|
+
method,
|
|
60
|
+
opt,
|
|
61
|
+
input
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to table updates
|
|
66
|
+
*
|
|
67
|
+
* @generated from protobuf rpc: SubscribeTable
|
|
68
|
+
*/
|
|
69
|
+
subscribeTable(
|
|
70
|
+
input: SubscribeRequest,
|
|
71
|
+
options?: RpcOptions
|
|
72
|
+
): ServerStreamingCall<SubscribeRequest, TableChange> {
|
|
73
|
+
const method = this.methods[1],
|
|
74
|
+
opt = this._transport.mergeOptions(options);
|
|
75
|
+
return stackIntercept<SubscribeRequest, TableChange>(
|
|
76
|
+
'serverStreaming',
|
|
77
|
+
this._transport,
|
|
78
|
+
method,
|
|
79
|
+
opt,
|
|
80
|
+
input
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|