@satrush/api 0.1.0 → 0.1.2
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 +22 -20
- package/dist/index.cjs +371 -45
- package/dist/index.d.cts +747 -3
- package/dist/index.d.ts +747 -3
- package/dist/index.js +349 -44
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -14,16 +14,14 @@ pnpm add @satrush/api
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import {SatrushBackendSdk, createClient, unwrap} from
|
|
17
|
+
import { SatrushBackendSdk, createClient, unwrap } from '@satrush/api';
|
|
18
18
|
|
|
19
19
|
const client = createClient({
|
|
20
|
-
|
|
20
|
+
baseUrl: 'https://api.satrush.io/api'
|
|
21
21
|
});
|
|
22
|
-
const sdk = new SatrushBackendSdk({client});
|
|
22
|
+
const sdk = new SatrushBackendSdk({ client });
|
|
23
23
|
|
|
24
|
-
const board = await unwrap(
|
|
25
|
-
sdk.getBoard(),
|
|
26
|
-
);
|
|
24
|
+
const board = await unwrap(sdk.getBoard());
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
## How the SDK works
|
|
@@ -32,10 +30,10 @@ const board = await unwrap(
|
|
|
32
30
|
- Pre-processing: `scripts/camelizeOpenapi.mjs` produces `openapi.camel.yaml` (converts snake_case into cameCase).
|
|
33
31
|
- Code generation: `@hey-api/openapi-ts` generates `src/generated/**`.
|
|
34
32
|
- Post-processing: `scripts/postprocessOpenapi.mjs` patches the generated client to:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
- snake_case request payloads/params
|
|
34
|
+
- camelCase response payloads
|
|
35
|
+
- apply response transforms before validators where needed
|
|
36
|
+
- apply custom SSE transforms (see below)
|
|
39
37
|
|
|
40
38
|
## Case transforms and scalar transforms
|
|
41
39
|
|
|
@@ -59,15 +57,19 @@ To throw on non-2xx responses for all SDK calls, set `throwOnError: true` on the
|
|
|
59
57
|
and attach the built-in interceptor that wraps errors as `SatRushSdkError`:
|
|
60
58
|
|
|
61
59
|
```ts
|
|
62
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
SatRushBackendSdk,
|
|
62
|
+
createClient,
|
|
63
|
+
satrushSdkErrorInterceptor
|
|
64
|
+
} from '@satrush/api';
|
|
63
65
|
|
|
64
66
|
const client = createClient({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
baseUrl: 'https://api.satrush.io/api',
|
|
68
|
+
throwOnError: true
|
|
67
69
|
});
|
|
68
70
|
client.interceptors.error.use(satrushSdkErrorInterceptor);
|
|
69
71
|
|
|
70
|
-
const sdk = new SatRushBackendSdk({client});
|
|
72
|
+
const sdk = new SatRushBackendSdk({ client });
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
`SatRushSdkError` includes the HTTP status and the original error payload in `cause`.
|
|
@@ -75,9 +77,9 @@ const sdk = new SatRushBackendSdk({client});
|
|
|
75
77
|
If you already have a client, you can also enable it later:
|
|
76
78
|
|
|
77
79
|
```ts
|
|
78
|
-
import {client, satrushSdkErrorInterceptor} from
|
|
80
|
+
import { client, satrushSdkErrorInterceptor } from '@satrush/api';
|
|
79
81
|
|
|
80
|
-
client.setConfig({throwOnError: true});
|
|
82
|
+
client.setConfig({ throwOnError: true });
|
|
81
83
|
client.interceptors.error.use(satrushSdkErrorInterceptor);
|
|
82
84
|
```
|
|
83
85
|
|
|
@@ -85,13 +87,13 @@ When `responseStyle` is set to `"data"`, SDK calls return only the response payl
|
|
|
85
87
|
(no `{ data, error, request, response }` wrapper). This is useful for simpler call sites:
|
|
86
88
|
|
|
87
89
|
```ts
|
|
88
|
-
import {SatRushBackendSdk, createClient} from
|
|
90
|
+
import { SatRushBackendSdk, createClient } from '@satrush/api';
|
|
89
91
|
|
|
90
92
|
const client = createClient({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
baseUrl: 'https://api.satrush.io/api',
|
|
94
|
+
responseStyle: 'data'
|
|
93
95
|
});
|
|
94
96
|
|
|
95
|
-
const sdk = new SatrushBackendSdk({client});
|
|
97
|
+
const sdk = new SatrushBackendSdk({ client });
|
|
96
98
|
const board = await sdk.getBoard();
|
|
97
99
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/index.ts
|
|
30
30
|
var index_exports = {};
|
|
31
31
|
__export(index_exports, {
|
|
32
|
+
NotificationEntity: () => NotificationEntity,
|
|
32
33
|
RoundStateDto: () => RoundStateDto,
|
|
33
34
|
SatrushBackendSdk: () => SatrushBackendSdk,
|
|
34
35
|
SatrushBackendSdkError: () => SatrushBackendSdkError,
|
|
@@ -37,19 +38,39 @@ __export(index_exports, {
|
|
|
37
38
|
isSatrushSdkError: () => isSatrushSdkError,
|
|
38
39
|
satrushSdkErrorInterceptor: () => satrushSdkErrorInterceptor,
|
|
39
40
|
unwrap: () => unwrap,
|
|
41
|
+
zBadRequestErrorCodeErrorBody: () => zBadRequestErrorCodeErrorBody,
|
|
40
42
|
zBoardDto: () => zBoardDto,
|
|
43
|
+
zFieldError: () => zFieldError,
|
|
41
44
|
zGetBoardData: () => zGetBoardData,
|
|
42
45
|
zGetBoardResponse: () => zGetBoardResponse,
|
|
46
|
+
zGetConfigData: () => zGetConfigData,
|
|
47
|
+
zGetConfigResponse: () => zGetConfigResponse,
|
|
48
|
+
zGetUserProfileData: () => zGetUserProfileData,
|
|
49
|
+
zGetUserProfileResponse: () => zGetUserProfileResponse,
|
|
43
50
|
zI128Dto: () => zI128Dto,
|
|
44
51
|
zI64Dto: () => zI64Dto,
|
|
45
52
|
zInternalErrorCodeErrorBody: () => zInternalErrorCodeErrorBody,
|
|
53
|
+
zMinerDto: () => zMinerDto,
|
|
54
|
+
zNotificationEntity: () => zNotificationEntity,
|
|
55
|
+
zProfileDto: () => zProfileDto,
|
|
46
56
|
zPubkeyDto: () => zPubkeyDto,
|
|
57
|
+
zPublicDeploymentDto: () => zPublicDeploymentDto,
|
|
47
58
|
zRoundDto: () => zRoundDto,
|
|
48
59
|
zRoundStateDto: () => zRoundStateDto,
|
|
60
|
+
zSatrushConfigDto: () => zSatrushConfigDto,
|
|
61
|
+
zSnapshotDto: () => zSnapshotDto,
|
|
62
|
+
zSseData: () => zSseData,
|
|
63
|
+
zSseResponse: () => zSseResponse,
|
|
64
|
+
zSseResponse2: () => zSseResponse2,
|
|
65
|
+
zSseResponseSnapshot: () => zSseResponseSnapshot,
|
|
49
66
|
zStrikeJackpotDto: () => zStrikeJackpotDto,
|
|
50
67
|
zTileStakeDto: () => zTileStakeDto,
|
|
51
68
|
zU128Dto: () => zU128Dto,
|
|
52
|
-
zU64Dto: () => zU64Dto
|
|
69
|
+
zU64Dto: () => zU64Dto,
|
|
70
|
+
zUserProfileApiError400Error: () => zUserProfileApiError400Error,
|
|
71
|
+
zUserProfileApiError400InvalidAddress: () => zUserProfileApiError400InvalidAddress,
|
|
72
|
+
zValidationErrorCodeErrorBody: () => zValidationErrorCodeErrorBody,
|
|
73
|
+
zValidationErrorCodeValidationDetailsErrorBody: () => zValidationErrorCodeValidationDetailsErrorBody
|
|
53
74
|
});
|
|
54
75
|
module.exports = __toCommonJS(index_exports);
|
|
55
76
|
|
|
@@ -73,6 +94,140 @@ var extraPrefixesMap = {
|
|
|
73
94
|
$query_: "query"
|
|
74
95
|
};
|
|
75
96
|
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
97
|
+
var buildKeyMap = (fields, map) => {
|
|
98
|
+
if (!map) {
|
|
99
|
+
map = /* @__PURE__ */ new Map();
|
|
100
|
+
}
|
|
101
|
+
for (const config of fields) {
|
|
102
|
+
if ("in" in config) {
|
|
103
|
+
if (config.key) {
|
|
104
|
+
map.set(config.key, {
|
|
105
|
+
in: config.in,
|
|
106
|
+
map: config.map
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
} else if ("key" in config) {
|
|
110
|
+
map.set(config.key, {
|
|
111
|
+
map: config.map
|
|
112
|
+
});
|
|
113
|
+
} else if (config.args) {
|
|
114
|
+
buildKeyMap(config.args, map);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return map;
|
|
118
|
+
};
|
|
119
|
+
var stripEmptySlots = (params) => {
|
|
120
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
121
|
+
if (value && typeof value === "object" && !Object.keys(value).length) {
|
|
122
|
+
delete params[slot];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var buildClientParams = (args, fields) => {
|
|
127
|
+
const params = {
|
|
128
|
+
body: {},
|
|
129
|
+
headers: {},
|
|
130
|
+
path: {},
|
|
131
|
+
query: {}
|
|
132
|
+
};
|
|
133
|
+
const map = buildKeyMap(fields);
|
|
134
|
+
let config;
|
|
135
|
+
for (const [index, arg] of args.entries()) {
|
|
136
|
+
if (fields[index]) {
|
|
137
|
+
config = fields[index];
|
|
138
|
+
}
|
|
139
|
+
if (!config) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if ("in" in config) {
|
|
143
|
+
if (config.key) {
|
|
144
|
+
const field = map.get(config.key);
|
|
145
|
+
const name = field.map || config.key;
|
|
146
|
+
if (field.in) {
|
|
147
|
+
params[field.in][name] = arg;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
params.body = arg;
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
154
|
+
const field = map.get(key);
|
|
155
|
+
if (field) {
|
|
156
|
+
if (field.in) {
|
|
157
|
+
const name = field.map || key;
|
|
158
|
+
params[field.in][name] = value;
|
|
159
|
+
} else {
|
|
160
|
+
params[field.map] = value;
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
164
|
+
if (extra) {
|
|
165
|
+
const [prefix, slot] = extra;
|
|
166
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
167
|
+
} else if ("allowExtra" in config && config.allowExtra) {
|
|
168
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
169
|
+
if (allowed) {
|
|
170
|
+
params[slot][key] = value;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
stripEmptySlots(params);
|
|
180
|
+
return params;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/utils/sse.ts
|
|
184
|
+
var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
185
|
+
var applySseResponseTransforms = async (payload) => {
|
|
186
|
+
if (!isRecord(payload)) return payload;
|
|
187
|
+
return payload;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/utils/transforms.ts
|
|
191
|
+
var snakeToCamel = (value) => value.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
192
|
+
var camelToSnake = (value) => value.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
193
|
+
var isPlainObject = (value) => !!value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
194
|
+
var mapKeysDeep = (value, mapKey) => {
|
|
195
|
+
if (Array.isArray(value)) {
|
|
196
|
+
return value.map((item) => mapKeysDeep(item, mapKey));
|
|
197
|
+
}
|
|
198
|
+
if (isPlainObject(value)) {
|
|
199
|
+
const next = {};
|
|
200
|
+
for (const [key, val] of Object.entries(value)) {
|
|
201
|
+
next[mapKey(key)] = mapKeysDeep(val, mapKey);
|
|
202
|
+
}
|
|
203
|
+
return next;
|
|
204
|
+
}
|
|
205
|
+
return value;
|
|
206
|
+
};
|
|
207
|
+
var shouldTransformBody = (value) => isPlainObject(value) || Array.isArray(value);
|
|
208
|
+
var snakecaseQuerySerializerParams = (value) => {
|
|
209
|
+
if (!isPlainObject(value)) return value;
|
|
210
|
+
if (!isPlainObject(value.parameters)) return value;
|
|
211
|
+
const nextParameters = {};
|
|
212
|
+
for (const [key, param] of Object.entries(value.parameters)) {
|
|
213
|
+
nextParameters[camelToSnake(key)] = param;
|
|
214
|
+
}
|
|
215
|
+
return { ...value, parameters: nextParameters };
|
|
216
|
+
};
|
|
217
|
+
var applyRequestCaseTransforms = (options) => {
|
|
218
|
+
const next = { ...options };
|
|
219
|
+
if ("query" in next && isPlainObject(next.query)) {
|
|
220
|
+
next.query = mapKeysDeep(next.query, camelToSnake);
|
|
221
|
+
}
|
|
222
|
+
if ("querySerializer" in next && next.querySerializer) {
|
|
223
|
+
next.querySerializer = snakecaseQuerySerializerParams(next.querySerializer);
|
|
224
|
+
}
|
|
225
|
+
if ("body" in next && shouldTransformBody(next.body)) {
|
|
226
|
+
next.body = mapKeysDeep(next.body, camelToSnake);
|
|
227
|
+
}
|
|
228
|
+
return next;
|
|
229
|
+
};
|
|
230
|
+
var applyResponseCaseTransforms = (value) => mapKeysDeep(value, snakeToCamel);
|
|
76
231
|
|
|
77
232
|
// src/generated/core/serverSentEvents.gen.ts
|
|
78
233
|
var createSseClient = ({
|
|
@@ -164,9 +319,11 @@ var createSseClient = ({
|
|
|
164
319
|
}
|
|
165
320
|
}
|
|
166
321
|
if (parsedJson) {
|
|
322
|
+
data = applyResponseCaseTransforms(data);
|
|
167
323
|
if (responseValidator) {
|
|
168
324
|
await responseValidator(data);
|
|
169
325
|
}
|
|
326
|
+
data = await applySseResponseTransforms(data);
|
|
170
327
|
if (responseTransformer) {
|
|
171
328
|
data = await responseTransformer(data);
|
|
172
329
|
}
|
|
@@ -422,48 +579,6 @@ function getValidRequestBody(options) {
|
|
|
422
579
|
return void 0;
|
|
423
580
|
}
|
|
424
581
|
|
|
425
|
-
// src/utils/transforms.ts
|
|
426
|
-
var snakeToCamel = (value) => value.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
427
|
-
var camelToSnake = (value) => value.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
428
|
-
var isPlainObject = (value) => !!value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
429
|
-
var mapKeysDeep = (value, mapKey) => {
|
|
430
|
-
if (Array.isArray(value)) {
|
|
431
|
-
return value.map((item) => mapKeysDeep(item, mapKey));
|
|
432
|
-
}
|
|
433
|
-
if (isPlainObject(value)) {
|
|
434
|
-
const next = {};
|
|
435
|
-
for (const [key, val] of Object.entries(value)) {
|
|
436
|
-
next[mapKey(key)] = mapKeysDeep(val, mapKey);
|
|
437
|
-
}
|
|
438
|
-
return next;
|
|
439
|
-
}
|
|
440
|
-
return value;
|
|
441
|
-
};
|
|
442
|
-
var shouldTransformBody = (value) => isPlainObject(value) || Array.isArray(value);
|
|
443
|
-
var snakecaseQuerySerializerParams = (value) => {
|
|
444
|
-
if (!isPlainObject(value)) return value;
|
|
445
|
-
if (!isPlainObject(value.parameters)) return value;
|
|
446
|
-
const nextParameters = {};
|
|
447
|
-
for (const [key, param] of Object.entries(value.parameters)) {
|
|
448
|
-
nextParameters[camelToSnake(key)] = param;
|
|
449
|
-
}
|
|
450
|
-
return { ...value, parameters: nextParameters };
|
|
451
|
-
};
|
|
452
|
-
var applyRequestCaseTransforms = (options) => {
|
|
453
|
-
const next = { ...options };
|
|
454
|
-
if ("query" in next && isPlainObject(next.query)) {
|
|
455
|
-
next.query = mapKeysDeep(next.query, camelToSnake);
|
|
456
|
-
}
|
|
457
|
-
if ("querySerializer" in next && next.querySerializer) {
|
|
458
|
-
next.querySerializer = snakecaseQuerySerializerParams(next.querySerializer);
|
|
459
|
-
}
|
|
460
|
-
if ("body" in next && shouldTransformBody(next.body)) {
|
|
461
|
-
next.body = mapKeysDeep(next.body, camelToSnake);
|
|
462
|
-
}
|
|
463
|
-
return next;
|
|
464
|
-
};
|
|
465
|
-
var applyResponseCaseTransforms = (value) => mapKeysDeep(value, snakeToCamel);
|
|
466
|
-
|
|
467
582
|
// src/generated/core/auth.gen.ts
|
|
468
583
|
var getAuthToken = async (auth, callback) => {
|
|
469
584
|
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
@@ -950,14 +1065,64 @@ var getBoardResponseTransformer = async (data) => {
|
|
|
950
1065
|
data.data = boardDtoSchemaResponseTransformer(data.data);
|
|
951
1066
|
return data;
|
|
952
1067
|
};
|
|
1068
|
+
var publicDeploymentDtoSchemaResponseTransformer = (data) => {
|
|
1069
|
+
data.deployedUsdAmount = u64DtoSchemaResponseTransformer(data.deployedUsdAmount);
|
|
1070
|
+
return data;
|
|
1071
|
+
};
|
|
1072
|
+
var minerDtoSchemaResponseTransformer = (data) => {
|
|
1073
|
+
data.hashrateAmount = u64DtoSchemaResponseTransformer(data.hashrateAmount);
|
|
1074
|
+
data.unclaimedBtcShares = u64DtoSchemaResponseTransformer(data.unclaimedBtcShares);
|
|
1075
|
+
data.unclaimedUsdAmount = u64DtoSchemaResponseTransformer(data.unclaimedUsdAmount);
|
|
1076
|
+
return data;
|
|
1077
|
+
};
|
|
1078
|
+
var profileDtoSchemaResponseTransformer = (data) => {
|
|
1079
|
+
data.deployments = data.deployments.map((item) => publicDeploymentDtoSchemaResponseTransformer(item));
|
|
1080
|
+
data.miner = minerDtoSchemaResponseTransformer(data.miner);
|
|
1081
|
+
return data;
|
|
1082
|
+
};
|
|
1083
|
+
var snapshotDtoSchemaResponseTransformer = (data) => {
|
|
1084
|
+
data.board = boardDtoSchemaResponseTransformer(data.board);
|
|
1085
|
+
if (data.profile) {
|
|
1086
|
+
data.profile = profileDtoSchemaResponseTransformer(data.profile);
|
|
1087
|
+
}
|
|
1088
|
+
return data;
|
|
1089
|
+
};
|
|
1090
|
+
var sseResponseSnapshotSchemaResponseTransformer = (data) => {
|
|
1091
|
+
data = snapshotDtoSchemaResponseTransformer(data);
|
|
1092
|
+
return data;
|
|
1093
|
+
};
|
|
1094
|
+
var sseResponseSchemaResponseTransformer = (data) => {
|
|
1095
|
+
data = sseResponseSnapshotSchemaResponseTransformer(data);
|
|
1096
|
+
return data;
|
|
1097
|
+
};
|
|
1098
|
+
var sseResponseTransformer = async (data) => {
|
|
1099
|
+
data = sseResponseSchemaResponseTransformer(data);
|
|
1100
|
+
return data;
|
|
1101
|
+
};
|
|
1102
|
+
var getUserProfileResponseTransformer = async (data) => {
|
|
1103
|
+
data.data = profileDtoSchemaResponseTransformer(data.data);
|
|
1104
|
+
return data;
|
|
1105
|
+
};
|
|
953
1106
|
|
|
954
1107
|
// src/generated/zod.gen.ts
|
|
955
1108
|
var z = __toESM(require("zod"), 1);
|
|
1109
|
+
var zBadRequestErrorCodeErrorBody = z.object({
|
|
1110
|
+
code: z.enum([
|
|
1111
|
+
"invalid_path",
|
|
1112
|
+
"invalid_query",
|
|
1113
|
+
"invalid_body"
|
|
1114
|
+
])
|
|
1115
|
+
});
|
|
1116
|
+
var zFieldError = z.object({
|
|
1117
|
+
field: z.string(),
|
|
1118
|
+
message: z.string()
|
|
1119
|
+
});
|
|
956
1120
|
var zI128Dto = z.string();
|
|
957
1121
|
var zI64Dto = z.coerce.bigint().min(BigInt("-9223372036854775808"), { error: "Invalid value: Expected int64 to be >= -9223372036854775808" }).max(BigInt("9223372036854775807"), { error: "Invalid value: Expected int64 to be <= 9223372036854775807" });
|
|
958
1122
|
var zInternalErrorCodeErrorBody = z.object({
|
|
959
1123
|
code: z.enum(["internal_error"])
|
|
960
1124
|
});
|
|
1125
|
+
var zNotificationEntity = z.enum(["state_snapshot"]);
|
|
961
1126
|
var zPubkeyDto = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
|
|
962
1127
|
var zRoundStateDto = z.enum([
|
|
963
1128
|
"active",
|
|
@@ -965,8 +1130,37 @@ var zRoundStateDto = z.enum([
|
|
|
965
1130
|
"settled",
|
|
966
1131
|
"finished"
|
|
967
1132
|
]);
|
|
1133
|
+
var zSatrushConfigDto = z.object({
|
|
1134
|
+
address: zPubkeyDto,
|
|
1135
|
+
btcMint: zPubkeyDto,
|
|
1136
|
+
epochFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1137
|
+
oneBtcFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1138
|
+
protocolFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1139
|
+
satsVaultClaimFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1140
|
+
satsVaultRoundFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1141
|
+
strikeFeeBps: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1142
|
+
usdMint: zPubkeyDto
|
|
1143
|
+
});
|
|
968
1144
|
var zU128Dto = z.string();
|
|
969
1145
|
var zU64Dto = z.coerce.bigint().min(BigInt("0"), { error: "Invalid value: Expected uint64 to be >= 0" }).max(BigInt("18446744073709551615"), { error: "Invalid value: Expected uint64 to be <= 18446744073709551615" });
|
|
1146
|
+
var zMinerDto = z.object({
|
|
1147
|
+
authority: zPubkeyDto,
|
|
1148
|
+
currentStreakCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1149
|
+
hashrateAmount: zU64Dto,
|
|
1150
|
+
lastMinedRoundId: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1151
|
+
unclaimedBtcShares: zU64Dto,
|
|
1152
|
+
unclaimedUsdAmount: zU64Dto
|
|
1153
|
+
});
|
|
1154
|
+
var zPublicDeploymentDto = z.object({
|
|
1155
|
+
address: zPubkeyDto,
|
|
1156
|
+
deployedUsdAmount: zU64Dto,
|
|
1157
|
+
roundId: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1158
|
+
selectionMask: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" })
|
|
1159
|
+
});
|
|
1160
|
+
var zProfileDto = z.object({
|
|
1161
|
+
deployments: z.array(zPublicDeploymentDto),
|
|
1162
|
+
miner: zMinerDto
|
|
1163
|
+
});
|
|
970
1164
|
var zStrikeJackpotDto = z.object({
|
|
971
1165
|
btcAmount: zU64Dto,
|
|
972
1166
|
lastTriggerRoundId: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
@@ -1014,6 +1208,47 @@ var zBoardDto = z.object({
|
|
|
1014
1208
|
startSlot: zU64Dto,
|
|
1015
1209
|
strike: zStrikeJackpotDto
|
|
1016
1210
|
});
|
|
1211
|
+
var zSnapshotDto = z.object({
|
|
1212
|
+
board: zBoardDto,
|
|
1213
|
+
entity: zNotificationEntity,
|
|
1214
|
+
profile: z.optional(z.union([
|
|
1215
|
+
z.null(),
|
|
1216
|
+
zProfileDto
|
|
1217
|
+
]))
|
|
1218
|
+
});
|
|
1219
|
+
var zSseResponseSnapshot = zSnapshotDto.and(z.object({
|
|
1220
|
+
entity: z.enum(["state_snapshot"])
|
|
1221
|
+
}));
|
|
1222
|
+
var zSseResponse = z.object({
|
|
1223
|
+
entity: z.literal("state_snapshot")
|
|
1224
|
+
}).and(zSseResponseSnapshot);
|
|
1225
|
+
var zUserProfileApiError400InvalidAddress = z.object({
|
|
1226
|
+
code: z.enum(["invalid_address"])
|
|
1227
|
+
});
|
|
1228
|
+
var zUserProfileApiError400Error = z.union([
|
|
1229
|
+
z.object({
|
|
1230
|
+
code: z.literal("invalid_address")
|
|
1231
|
+
}).and(zUserProfileApiError400InvalidAddress),
|
|
1232
|
+
z.object({
|
|
1233
|
+
code: z.union([
|
|
1234
|
+
z.literal("invalid_body"),
|
|
1235
|
+
z.literal("invalid_path"),
|
|
1236
|
+
z.literal("invalid_query")
|
|
1237
|
+
])
|
|
1238
|
+
}).and(zBadRequestErrorCodeErrorBody)
|
|
1239
|
+
]);
|
|
1240
|
+
var zValidationErrorCodeErrorBody = z.object({
|
|
1241
|
+
code: z.enum(["validation_failed"]),
|
|
1242
|
+
data: z.optional(z.object({
|
|
1243
|
+
errors: z.array(zFieldError)
|
|
1244
|
+
}))
|
|
1245
|
+
});
|
|
1246
|
+
var zValidationErrorCodeValidationDetailsErrorBody = z.object({
|
|
1247
|
+
code: z.enum(["validation_failed"]),
|
|
1248
|
+
data: z.optional(z.object({
|
|
1249
|
+
errors: z.array(zFieldError)
|
|
1250
|
+
}))
|
|
1251
|
+
});
|
|
1017
1252
|
var zGetBoardData = z.object({
|
|
1018
1253
|
body: z.optional(z.never()),
|
|
1019
1254
|
path: z.optional(z.never()),
|
|
@@ -1022,6 +1257,32 @@ var zGetBoardData = z.object({
|
|
|
1022
1257
|
var zGetBoardResponse = z.object({
|
|
1023
1258
|
data: zBoardDto
|
|
1024
1259
|
});
|
|
1260
|
+
var zGetConfigData = z.object({
|
|
1261
|
+
body: z.optional(z.never()),
|
|
1262
|
+
path: z.optional(z.never()),
|
|
1263
|
+
query: z.optional(z.never())
|
|
1264
|
+
});
|
|
1265
|
+
var zGetConfigResponse = z.object({
|
|
1266
|
+
data: zSatrushConfigDto
|
|
1267
|
+
});
|
|
1268
|
+
var zSseData = z.object({
|
|
1269
|
+
body: z.optional(z.never()),
|
|
1270
|
+
path: z.optional(z.never()),
|
|
1271
|
+
query: z.optional(z.object({
|
|
1272
|
+
wallet: z.optional(z.string())
|
|
1273
|
+
}))
|
|
1274
|
+
});
|
|
1275
|
+
var zSseResponse2 = zSseResponse;
|
|
1276
|
+
var zGetUserProfileData = z.object({
|
|
1277
|
+
body: z.optional(z.never()),
|
|
1278
|
+
path: z.object({
|
|
1279
|
+
address: z.string()
|
|
1280
|
+
}),
|
|
1281
|
+
query: z.optional(z.never())
|
|
1282
|
+
});
|
|
1283
|
+
var zGetUserProfileResponse = z.object({
|
|
1284
|
+
data: zProfileDto
|
|
1285
|
+
});
|
|
1025
1286
|
|
|
1026
1287
|
// src/generated/sdk.gen.ts
|
|
1027
1288
|
var HeyApiClient = class {
|
|
@@ -1062,9 +1323,49 @@ var SatrushBackendSdk = class _SatrushBackendSdk extends HeyApiClient {
|
|
|
1062
1323
|
...options
|
|
1063
1324
|
});
|
|
1064
1325
|
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Request config
|
|
1328
|
+
*/
|
|
1329
|
+
getConfig(options) {
|
|
1330
|
+
return (options?.client ?? this.client).get({
|
|
1331
|
+
requestValidator: async (data) => await zGetConfigData.parseAsync(data),
|
|
1332
|
+
responseValidator: async (data) => await zGetConfigResponse.parseAsync(data),
|
|
1333
|
+
url: "/v1/config",
|
|
1334
|
+
...options
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Subscribe for SSE stream
|
|
1339
|
+
*/
|
|
1340
|
+
sse(parameters, options) {
|
|
1341
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "wallet" }] }]);
|
|
1342
|
+
return (options?.client ?? this.client).sse.get({
|
|
1343
|
+
requestValidator: async (data) => await zSseData.parseAsync(data),
|
|
1344
|
+
responseTransformer: sseResponseTransformer,
|
|
1345
|
+
responseValidator: async (data) => await zSseResponse2.parseAsync(data),
|
|
1346
|
+
url: "/v1/streams/sse",
|
|
1347
|
+
...options,
|
|
1348
|
+
...params
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Request user profile
|
|
1353
|
+
*/
|
|
1354
|
+
getUserProfile(parameters, options) {
|
|
1355
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "address" }] }]);
|
|
1356
|
+
return (options?.client ?? this.client).get({
|
|
1357
|
+
requestValidator: async (data) => await zGetUserProfileData.parseAsync(data),
|
|
1358
|
+
responseTransformer: getUserProfileResponseTransformer,
|
|
1359
|
+
responseValidator: async (data) => await zGetUserProfileResponse.parseAsync(data),
|
|
1360
|
+
url: "/v1/user/{address}/profile",
|
|
1361
|
+
...options,
|
|
1362
|
+
...params
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1065
1365
|
};
|
|
1066
1366
|
|
|
1067
1367
|
// src/generated/types.gen.ts
|
|
1368
|
+
var NotificationEntity = { STATE_SNAPSHOT: "state_snapshot" };
|
|
1068
1369
|
var RoundStateDto = {
|
|
1069
1370
|
ACTIVE: "active",
|
|
1070
1371
|
REVEALED: "revealed",
|
|
@@ -1104,7 +1405,11 @@ async function unwrap(promise) {
|
|
|
1104
1405
|
if (res && typeof res === "object" && "response" in res) {
|
|
1105
1406
|
const sdkRes = res;
|
|
1106
1407
|
if ("error" in sdkRes && sdkRes.error !== void 0) {
|
|
1107
|
-
throw new SatrushBackendSdkError(
|
|
1408
|
+
throw new SatrushBackendSdkError(
|
|
1409
|
+
String(sdkRes.error),
|
|
1410
|
+
sdkRes.response?.status ?? 0,
|
|
1411
|
+
sdkRes.error
|
|
1412
|
+
);
|
|
1108
1413
|
}
|
|
1109
1414
|
if ("data" in sdkRes) {
|
|
1110
1415
|
return unwrapData(sdkRes.data);
|
|
@@ -1114,6 +1419,7 @@ async function unwrap(promise) {
|
|
|
1114
1419
|
}
|
|
1115
1420
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1116
1421
|
0 && (module.exports = {
|
|
1422
|
+
NotificationEntity,
|
|
1117
1423
|
RoundStateDto,
|
|
1118
1424
|
SatrushBackendSdk,
|
|
1119
1425
|
SatrushBackendSdkError,
|
|
@@ -1122,17 +1428,37 @@ async function unwrap(promise) {
|
|
|
1122
1428
|
isSatrushSdkError,
|
|
1123
1429
|
satrushSdkErrorInterceptor,
|
|
1124
1430
|
unwrap,
|
|
1431
|
+
zBadRequestErrorCodeErrorBody,
|
|
1125
1432
|
zBoardDto,
|
|
1433
|
+
zFieldError,
|
|
1126
1434
|
zGetBoardData,
|
|
1127
1435
|
zGetBoardResponse,
|
|
1436
|
+
zGetConfigData,
|
|
1437
|
+
zGetConfigResponse,
|
|
1438
|
+
zGetUserProfileData,
|
|
1439
|
+
zGetUserProfileResponse,
|
|
1128
1440
|
zI128Dto,
|
|
1129
1441
|
zI64Dto,
|
|
1130
1442
|
zInternalErrorCodeErrorBody,
|
|
1443
|
+
zMinerDto,
|
|
1444
|
+
zNotificationEntity,
|
|
1445
|
+
zProfileDto,
|
|
1131
1446
|
zPubkeyDto,
|
|
1447
|
+
zPublicDeploymentDto,
|
|
1132
1448
|
zRoundDto,
|
|
1133
1449
|
zRoundStateDto,
|
|
1450
|
+
zSatrushConfigDto,
|
|
1451
|
+
zSnapshotDto,
|
|
1452
|
+
zSseData,
|
|
1453
|
+
zSseResponse,
|
|
1454
|
+
zSseResponse2,
|
|
1455
|
+
zSseResponseSnapshot,
|
|
1134
1456
|
zStrikeJackpotDto,
|
|
1135
1457
|
zTileStakeDto,
|
|
1136
1458
|
zU128Dto,
|
|
1137
|
-
zU64Dto
|
|
1459
|
+
zU64Dto,
|
|
1460
|
+
zUserProfileApiError400Error,
|
|
1461
|
+
zUserProfileApiError400InvalidAddress,
|
|
1462
|
+
zValidationErrorCodeErrorBody,
|
|
1463
|
+
zValidationErrorCodeValidationDetailsErrorBody
|
|
1138
1464
|
});
|