@n1xyz/nord-ts 0.0.18-8121ed05.0 → 0.0.19

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.
Files changed (77) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/.local/qa.ts +77 -0
  3. package/.local/test-atomic.ts +112 -0
  4. package/check.sh +4 -0
  5. package/default.nix +47 -0
  6. package/package.json +20 -27
  7. package/src/index.ts +0 -16
  8. package/src/nord/api/actions.ts +131 -9
  9. package/src/nord/api/core.ts +0 -71
  10. package/src/nord/client/Nord.ts +142 -76
  11. package/src/nord/client/NordUser.ts +171 -50
  12. package/src/nord/index.ts +0 -2
  13. package/src/nord/models/Subscriber.ts +2 -2
  14. package/src/types.ts +55 -216
  15. package/src/utils.ts +6 -42
  16. package/src/websocket/NordWebSocketClient.ts +23 -15
  17. package/src/websocket/index.ts +1 -1
  18. package/tests/utils.spec.ts +1 -34
  19. package/dist/bridge/client.d.ts +0 -151
  20. package/dist/bridge/client.js +0 -434
  21. package/dist/bridge/const.d.ts +0 -23
  22. package/dist/bridge/const.js +0 -47
  23. package/dist/bridge/index.d.ts +0 -4
  24. package/dist/bridge/index.js +0 -23
  25. package/dist/bridge/types.d.ts +0 -120
  26. package/dist/bridge/types.js +0 -18
  27. package/dist/bridge/utils.d.ts +0 -64
  28. package/dist/bridge/utils.js +0 -131
  29. package/dist/const.d.ts +0 -8
  30. package/dist/const.js +0 -30
  31. package/dist/gen/common.d.ts +0 -68
  32. package/dist/gen/common.js +0 -215
  33. package/dist/gen/nord.d.ts +0 -853
  34. package/dist/gen/nord.js +0 -6368
  35. package/dist/idl/bridge.d.ts +0 -569
  36. package/dist/idl/bridge.js +0 -8
  37. package/dist/idl/bridge.json +0 -1506
  38. package/dist/idl/index.d.ts +0 -607
  39. package/dist/idl/index.js +0 -8
  40. package/dist/index.d.ts +0 -6
  41. package/dist/index.js +0 -30
  42. package/dist/nord/api/actions.d.ts +0 -106
  43. package/dist/nord/api/actions.js +0 -256
  44. package/dist/nord/api/core.d.ts +0 -49
  45. package/dist/nord/api/core.js +0 -164
  46. package/dist/nord/api/market.d.ts +0 -36
  47. package/dist/nord/api/market.js +0 -96
  48. package/dist/nord/api/metrics.d.ts +0 -67
  49. package/dist/nord/api/metrics.js +0 -229
  50. package/dist/nord/api/queries.d.ts +0 -46
  51. package/dist/nord/api/queries.js +0 -109
  52. package/dist/nord/client/Nord.d.ts +0 -284
  53. package/dist/nord/client/Nord.js +0 -491
  54. package/dist/nord/client/NordUser.d.ts +0 -287
  55. package/dist/nord/client/NordUser.js +0 -595
  56. package/dist/nord/index.d.ts +0 -9
  57. package/dist/nord/index.js +0 -33
  58. package/dist/nord/models/Subscriber.d.ts +0 -37
  59. package/dist/nord/models/Subscriber.js +0 -25
  60. package/dist/nord/utils/NordError.d.ts +0 -35
  61. package/dist/nord/utils/NordError.js +0 -49
  62. package/dist/types.d.ts +0 -407
  63. package/dist/types.js +0 -103
  64. package/dist/utils.d.ts +0 -116
  65. package/dist/utils.js +0 -271
  66. package/dist/websocket/NordWebSocketClient.d.ts +0 -68
  67. package/dist/websocket/NordWebSocketClient.js +0 -338
  68. package/dist/websocket/events.d.ts +0 -19
  69. package/dist/websocket/events.js +0 -2
  70. package/dist/websocket/index.d.ts +0 -2
  71. package/dist/websocket/index.js +0 -5
  72. package/jest.config.ts +0 -9
  73. package/nodemon.json +0 -4
  74. package/protoc-generate.sh +0 -23
  75. package/src/idl/bridge.json +0 -1506
  76. package/src/nord/api/market.ts +0 -122
  77. package/src/nord/api/queries.ts +0 -135
@@ -1,122 +0,0 @@
1
- import {
2
- MarketsStatsResponse,
3
- OrderbookQuery,
4
- OrderbookResponse,
5
- TradesQuery,
6
- TradesResponse,
7
- UserAccountIdsQuery,
8
- UserAccountIdsResponse,
9
- } from "../../types";
10
- import { checkedFetch } from "../../utils";
11
- import { NordError } from "../utils/NordError";
12
-
13
- /**
14
- * Get market statistics
15
- *
16
- * @param webServerUrl - Base URL for the Nord web server
17
- * @returns Market statistics response
18
- * @throws {NordError} If the request fails
19
- */
20
- export async function marketsStats(
21
- webServerUrl: string,
22
- ): Promise<MarketsStatsResponse> {
23
- try {
24
- const response = await checkedFetch(`${webServerUrl}/stats`);
25
- return await response.json();
26
- } catch (error) {
27
- throw new NordError("Failed to fetch markets stats", { cause: error });
28
- }
29
- }
30
-
31
- /**
32
- * Get trades for a market
33
- *
34
- * @param webServerUrl - Base URL for the Nord web server
35
- * @param query - Trades query parameters
36
- * @returns Trades response
37
- * @throws {NordError} If the request fails
38
- */
39
- export async function getTrades(
40
- webServerUrl: string,
41
- query: TradesQuery,
42
- ): Promise<TradesResponse> {
43
- try {
44
- const params = new URLSearchParams();
45
- params.append("accountId", query.accountId.toString());
46
-
47
- if (query.since) {
48
- params.append("since", query.since);
49
- }
50
-
51
- if (query.until) {
52
- params.append("until", query.until);
53
- }
54
-
55
- if (query.pageId) {
56
- params.append("pageId", query.pageId);
57
- }
58
-
59
- const response = await checkedFetch(
60
- `${webServerUrl}/trades?${params.toString()}`,
61
- );
62
- return await response.json();
63
- } catch (error) {
64
- throw new NordError("Failed to get trades", { cause: error });
65
- }
66
- }
67
-
68
- /**
69
- * Get user account IDs
70
- *
71
- * @param webServerUrl - Base URL for the Nord web server
72
- * @param query - User account IDs query parameters
73
- * @returns User account IDs response
74
- * @throws {NordError} If the request fails
75
- */
76
- export async function getUserAccountIds(
77
- webServerUrl: string,
78
- query: UserAccountIdsQuery,
79
- ): Promise<UserAccountIdsResponse> {
80
- try {
81
- const response = await checkedFetch(
82
- `${webServerUrl}/user/${query.pubkey.toString()}`,
83
- );
84
- return await response.json();
85
- } catch (error) {
86
- throw new NordError("Failed to get user account IDs", { cause: error });
87
- }
88
- }
89
-
90
- /**
91
- * Get orderbook for a market
92
- *
93
- * @param webServerUrl - Base URL for the Nord web server
94
- * @param query - Orderbook query parameters
95
- * @returns Orderbook response
96
- * @throws {NordError} If the request fails
97
- */
98
- export async function getOrderbook(
99
- webServerUrl: string,
100
- query: OrderbookQuery,
101
- ): Promise<OrderbookResponse> {
102
- try {
103
- const params = new URLSearchParams();
104
-
105
- if (query.symbol) {
106
- params.append("symbol", query.symbol);
107
- } else if (query.market_id !== undefined) {
108
- params.append("market_id", query.market_id.toString());
109
- } else {
110
- throw new NordError(
111
- "Either symbol or market_id must be provided for orderbook query",
112
- );
113
- }
114
-
115
- const response = await checkedFetch(
116
- `${webServerUrl}/orderbook?${params.toString()}`,
117
- );
118
- return await response.json();
119
- } catch (error) {
120
- throw new NordError("Failed to get orderbook", { cause: error });
121
- }
122
- }
@@ -1,135 +0,0 @@
1
- import {
2
- ActionQuery,
3
- ActionResponse,
4
- ActionsResponse,
5
- RollmanActionResponse,
6
- RollmanActionsResponse,
7
- } from "../../types";
8
- import { checkedFetch } from "../../utils";
9
- import { NordError } from "../utils/NordError";
10
-
11
- /**
12
- * Query a specific action
13
- *
14
- * @param webServerUrl - Base URL for the Nord web server
15
- * @param query - Action query parameters
16
- * @returns Action response
17
- * @throws {NordError} If the request fails
18
- */
19
- export async function queryAction(
20
- webServerUrl: string,
21
- query: ActionQuery,
22
- ): Promise<ActionResponse> {
23
- try {
24
- const params = new URLSearchParams();
25
- if (query.action_id !== undefined) {
26
- params.append("action_id", query.action_id.toString());
27
- }
28
-
29
- const response = await checkedFetch(
30
- `${webServerUrl}/action?${params.toString()}`,
31
- );
32
- return await response.json();
33
- } catch (error) {
34
- throw new NordError("Failed to query action", { cause: error });
35
- }
36
- }
37
-
38
- /**
39
- * Query recent actions
40
- *
41
- * @param webServerUrl - Base URL for the Nord web server
42
- * @param from - Starting action index
43
- * @param to - Ending action index
44
- * @returns Actions response
45
- * @throws {NordError} If the request fails
46
- */
47
- export async function queryRecentActions(
48
- webServerUrl: string,
49
- from: number,
50
- to: number,
51
- ): Promise<ActionsResponse> {
52
- try {
53
- const response = await checkedFetch(
54
- `${webServerUrl}/actions?from=${from}&to=${to}`,
55
- );
56
- return await response.json();
57
- } catch (error) {
58
- throw new NordError(
59
- `Failed to query recent actions (from ${from} to ${to})`,
60
- {
61
- cause: error,
62
- },
63
- );
64
- }
65
- }
66
-
67
- /**
68
- * Get the last action ID
69
- *
70
- * @param webServerUrl - Base URL for the Nord web server
71
- * @returns Last action ID
72
- * @throws {NordError} If the request fails
73
- */
74
- export async function getLastActionId(webServerUrl: string): Promise<number> {
75
- try {
76
- const response = await checkedFetch(`${webServerUrl}/actions/last-id`);
77
- const data = await response.json();
78
- return data;
79
- } catch (error) {
80
- throw new NordError("Failed to get last action ID", {
81
- cause: error,
82
- });
83
- }
84
- }
85
-
86
- /**
87
- * Query an action from Rollman
88
- *
89
- * @param webServerUrl - Base URL for the Nord web server
90
- * @param query - Action query parameters
91
- * @returns Rollman action response
92
- * @throws {NordError} If the request fails
93
- */
94
- export async function actionQueryRollman(
95
- webServerUrl: string,
96
- query: ActionQuery,
97
- ): Promise<RollmanActionResponse> {
98
- try {
99
- const params = new URLSearchParams();
100
- if (query.action_id !== undefined) {
101
- params.append("action_id", query.action_id.toString());
102
- }
103
-
104
- const response = await checkedFetch(
105
- `${webServerUrl}/rollman/action?${params.toString()}`,
106
- );
107
- return await response.json();
108
- } catch (error) {
109
- throw new NordError("Failed to query Rollman action", { cause: error });
110
- }
111
- }
112
-
113
- /**
114
- * Query actions from Rollman
115
- *
116
- * @param webServerUrl - Base URL for the Nord web server
117
- * @param last_n - Number of recent actions to query
118
- * @returns Rollman actions response
119
- * @throws {NordError} If the request fails
120
- */
121
- export async function actionsQueryRollman(
122
- webServerUrl: string,
123
- last_n: number,
124
- ): Promise<RollmanActionsResponse> {
125
- try {
126
- const response = await checkedFetch(
127
- `${webServerUrl}/rollman/actions?last_n=${last_n}`,
128
- );
129
- return await response.json();
130
- } catch (error) {
131
- throw new NordError(`Failed to query Rollman actions (last ${last_n})`, {
132
- cause: error,
133
- });
134
- }
135
- }