@hashgrid/sdk 0.1.0 → 0.2.8
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 +3 -1
- package/dist/resources.d.ts +4 -3
- package/dist/resources.js +6 -5
- package/package.json +1 -1
- package/src/resources.ts +8 -6
package/README.md
CHANGED
|
@@ -27,8 +27,8 @@ async function main() {
|
|
|
27
27
|
const replies = messages.map((msg) =>
|
|
28
28
|
new Message(
|
|
29
29
|
msg.peer_id,
|
|
30
|
-
"Hello, fellow grid peer!",
|
|
31
30
|
msg.round,
|
|
31
|
+
"Hello, fellow grid peer!",
|
|
32
32
|
0.9
|
|
33
33
|
)
|
|
34
34
|
);
|
|
@@ -50,7 +50,9 @@ The SDK provides the following resources:
|
|
|
50
50
|
- **`User`** - User data model
|
|
51
51
|
- **`Quota`** - Quota data model
|
|
52
52
|
- **`Message`** - Message for recv/send operations
|
|
53
|
+
- Constructor: `new Message(peer_id, round, message = "", score = null)`
|
|
53
54
|
- **`Status`** - Status response from send operations
|
|
55
|
+
- Properties: `peer_id`, `round`, `success`
|
|
54
56
|
|
|
55
57
|
## Examples
|
|
56
58
|
|
package/dist/resources.d.ts
CHANGED
|
@@ -24,15 +24,16 @@ export declare class Edge {
|
|
|
24
24
|
}
|
|
25
25
|
export declare class Message {
|
|
26
26
|
peer_id: string;
|
|
27
|
-
message: string;
|
|
28
27
|
round: number;
|
|
28
|
+
message: string;
|
|
29
29
|
score: number | null;
|
|
30
|
-
constructor(peer_id: string,
|
|
30
|
+
constructor(peer_id: string, round: number, message?: string, score?: number | null);
|
|
31
31
|
}
|
|
32
32
|
export declare class Status {
|
|
33
33
|
peer_id: string;
|
|
34
|
+
round: number;
|
|
34
35
|
success: boolean;
|
|
35
|
-
constructor(peer_id: string, success: boolean);
|
|
36
|
+
constructor(peer_id: string, round: number, success: boolean);
|
|
36
37
|
}
|
|
37
38
|
export declare class Grid {
|
|
38
39
|
name: string;
|
package/dist/resources.js
CHANGED
|
@@ -31,17 +31,18 @@ class Edge {
|
|
|
31
31
|
}
|
|
32
32
|
exports.Edge = Edge;
|
|
33
33
|
class Message {
|
|
34
|
-
constructor(peer_id,
|
|
34
|
+
constructor(peer_id, round, message = "", score = null) {
|
|
35
35
|
this.peer_id = peer_id;
|
|
36
|
-
this.message = message;
|
|
37
36
|
this.round = round;
|
|
37
|
+
this.message = message;
|
|
38
38
|
this.score = score;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
exports.Message = Message;
|
|
42
42
|
class Status {
|
|
43
|
-
constructor(peer_id, success) {
|
|
43
|
+
constructor(peer_id, round, success) {
|
|
44
44
|
this.peer_id = peer_id;
|
|
45
|
+
this.round = round;
|
|
45
46
|
this.success = success;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -96,7 +97,7 @@ class Node {
|
|
|
96
97
|
}
|
|
97
98
|
async recv() {
|
|
98
99
|
const data = await this._client._request("GET", `/api/v1/node/${this.node_id}/recv`);
|
|
99
|
-
return data.map((item) => new Message(item.peer_id, item.
|
|
100
|
+
return data.map((item) => new Message(item.peer_id, item.round, item.message, item.score ?? null));
|
|
100
101
|
}
|
|
101
102
|
async send(replies) {
|
|
102
103
|
const json_data = replies.map((msg) => {
|
|
@@ -111,7 +112,7 @@ class Node {
|
|
|
111
112
|
return obj;
|
|
112
113
|
});
|
|
113
114
|
const data = await this._client._request("POST", `/api/v1/node/${this.node_id}/send`, undefined, json_data);
|
|
114
|
-
return data.map((item) => new Status(item.peer_id, item.success));
|
|
115
|
+
return data.map((item) => new Status(item.peer_id, item.round, item.success));
|
|
115
116
|
}
|
|
116
117
|
async update(name, message, capacity) {
|
|
117
118
|
const json_data = {};
|
package/package.json
CHANGED
package/src/resources.ts
CHANGED
|
@@ -60,29 +60,31 @@ export class Edge {
|
|
|
60
60
|
|
|
61
61
|
export class Message {
|
|
62
62
|
peer_id: string;
|
|
63
|
-
message: string;
|
|
64
63
|
round: number;
|
|
64
|
+
message: string;
|
|
65
65
|
score: number | null;
|
|
66
66
|
|
|
67
67
|
constructor(
|
|
68
68
|
peer_id: string,
|
|
69
|
-
message: string,
|
|
70
69
|
round: number,
|
|
70
|
+
message: string = "",
|
|
71
71
|
score: number | null = null
|
|
72
72
|
) {
|
|
73
73
|
this.peer_id = peer_id;
|
|
74
|
-
this.message = message;
|
|
75
74
|
this.round = round;
|
|
75
|
+
this.message = message;
|
|
76
76
|
this.score = score;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export class Status {
|
|
81
81
|
peer_id: string;
|
|
82
|
+
round: number;
|
|
82
83
|
success: boolean;
|
|
83
84
|
|
|
84
|
-
constructor(peer_id: string, success: boolean) {
|
|
85
|
+
constructor(peer_id: string, round: number, success: boolean) {
|
|
85
86
|
this.peer_id = peer_id;
|
|
87
|
+
this.round = round;
|
|
86
88
|
this.success = success;
|
|
87
89
|
}
|
|
88
90
|
}
|
|
@@ -183,7 +185,7 @@ export class Node {
|
|
|
183
185
|
);
|
|
184
186
|
return data.map(
|
|
185
187
|
(item: any) =>
|
|
186
|
-
new Message(item.peer_id, item.
|
|
188
|
+
new Message(item.peer_id, item.round, item.message, item.score ?? null)
|
|
187
189
|
);
|
|
188
190
|
}
|
|
189
191
|
|
|
@@ -205,7 +207,7 @@ export class Node {
|
|
|
205
207
|
undefined,
|
|
206
208
|
json_data
|
|
207
209
|
);
|
|
208
|
-
return data.map((item: any) => new Status(item.peer_id, item.success));
|
|
210
|
+
return data.map((item: any) => new Status(item.peer_id, item.round, item.success));
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
async update(
|