@satrush/api 0.1.0
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 +97 -0
- package/dist/index.cjs +1138 -0
- package/dist/index.d.cts +728 -0
- package/dist/index.d.ts +728 -0
- package/dist/index.js +1082 -0
- package/package.json +51 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1138 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
RoundStateDto: () => RoundStateDto,
|
|
33
|
+
SatrushBackendSdk: () => SatrushBackendSdk,
|
|
34
|
+
SatrushBackendSdkError: () => SatrushBackendSdkError,
|
|
35
|
+
createClient: () => createClient,
|
|
36
|
+
createSseClient: () => createSseClient,
|
|
37
|
+
isSatrushSdkError: () => isSatrushSdkError,
|
|
38
|
+
satrushSdkErrorInterceptor: () => satrushSdkErrorInterceptor,
|
|
39
|
+
unwrap: () => unwrap,
|
|
40
|
+
zBoardDto: () => zBoardDto,
|
|
41
|
+
zGetBoardData: () => zGetBoardData,
|
|
42
|
+
zGetBoardResponse: () => zGetBoardResponse,
|
|
43
|
+
zI128Dto: () => zI128Dto,
|
|
44
|
+
zI64Dto: () => zI64Dto,
|
|
45
|
+
zInternalErrorCodeErrorBody: () => zInternalErrorCodeErrorBody,
|
|
46
|
+
zPubkeyDto: () => zPubkeyDto,
|
|
47
|
+
zRoundDto: () => zRoundDto,
|
|
48
|
+
zRoundStateDto: () => zRoundStateDto,
|
|
49
|
+
zStrikeJackpotDto: () => zStrikeJackpotDto,
|
|
50
|
+
zTileStakeDto: () => zTileStakeDto,
|
|
51
|
+
zU128Dto: () => zU128Dto,
|
|
52
|
+
zU64Dto: () => zU64Dto
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(index_exports);
|
|
55
|
+
|
|
56
|
+
// src/config.ts
|
|
57
|
+
var createClientConfig = (config) => ({
|
|
58
|
+
...config,
|
|
59
|
+
responseStyle: "data",
|
|
60
|
+
throwOnError: true
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// src/generated/core/bodySerializer.gen.ts
|
|
64
|
+
var jsonBodySerializer = {
|
|
65
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/generated/core/params.gen.ts
|
|
69
|
+
var extraPrefixesMap = {
|
|
70
|
+
$body_: "body",
|
|
71
|
+
$headers_: "headers",
|
|
72
|
+
$path_: "path",
|
|
73
|
+
$query_: "query"
|
|
74
|
+
};
|
|
75
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
76
|
+
|
|
77
|
+
// src/generated/core/serverSentEvents.gen.ts
|
|
78
|
+
var createSseClient = ({
|
|
79
|
+
onRequest,
|
|
80
|
+
onSseError,
|
|
81
|
+
onSseEvent,
|
|
82
|
+
responseTransformer,
|
|
83
|
+
responseValidator,
|
|
84
|
+
sseDefaultRetryDelay,
|
|
85
|
+
sseMaxRetryAttempts,
|
|
86
|
+
sseMaxRetryDelay,
|
|
87
|
+
sseSleepFn,
|
|
88
|
+
url,
|
|
89
|
+
...options
|
|
90
|
+
}) => {
|
|
91
|
+
let lastEventId;
|
|
92
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
93
|
+
const createStream = async function* () {
|
|
94
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
95
|
+
let attempt = 0;
|
|
96
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
97
|
+
while (true) {
|
|
98
|
+
if (signal.aborted) break;
|
|
99
|
+
attempt++;
|
|
100
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
101
|
+
if (lastEventId !== void 0) {
|
|
102
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const requestInit = {
|
|
106
|
+
redirect: "follow",
|
|
107
|
+
...options,
|
|
108
|
+
body: options.serializedBody,
|
|
109
|
+
headers,
|
|
110
|
+
signal
|
|
111
|
+
};
|
|
112
|
+
let request = new Request(url, requestInit);
|
|
113
|
+
if (onRequest) {
|
|
114
|
+
request = await onRequest(url, requestInit);
|
|
115
|
+
}
|
|
116
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
117
|
+
const response = await _fetch(request);
|
|
118
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
119
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
120
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
121
|
+
let buffer = "";
|
|
122
|
+
const abortHandler = () => {
|
|
123
|
+
try {
|
|
124
|
+
reader.cancel();
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
signal.addEventListener("abort", abortHandler);
|
|
129
|
+
try {
|
|
130
|
+
while (true) {
|
|
131
|
+
const { done, value } = await reader.read();
|
|
132
|
+
if (done) break;
|
|
133
|
+
buffer += value;
|
|
134
|
+
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
135
|
+
const chunks = buffer.split("\n\n");
|
|
136
|
+
buffer = chunks.pop() ?? "";
|
|
137
|
+
for (const chunk of chunks) {
|
|
138
|
+
const lines = chunk.split("\n");
|
|
139
|
+
const dataLines = [];
|
|
140
|
+
let eventName;
|
|
141
|
+
for (const line of lines) {
|
|
142
|
+
if (line.startsWith("data:")) {
|
|
143
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
144
|
+
} else if (line.startsWith("event:")) {
|
|
145
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
146
|
+
} else if (line.startsWith("id:")) {
|
|
147
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
148
|
+
} else if (line.startsWith("retry:")) {
|
|
149
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
150
|
+
if (!Number.isNaN(parsed)) {
|
|
151
|
+
retryDelay = parsed;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
let data;
|
|
156
|
+
let parsedJson = false;
|
|
157
|
+
if (dataLines.length) {
|
|
158
|
+
const rawData = dataLines.join("\n");
|
|
159
|
+
try {
|
|
160
|
+
data = JSON.parse(rawData);
|
|
161
|
+
parsedJson = true;
|
|
162
|
+
} catch {
|
|
163
|
+
data = rawData;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (parsedJson) {
|
|
167
|
+
if (responseValidator) {
|
|
168
|
+
await responseValidator(data);
|
|
169
|
+
}
|
|
170
|
+
if (responseTransformer) {
|
|
171
|
+
data = await responseTransformer(data);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
onSseEvent?.({
|
|
175
|
+
data,
|
|
176
|
+
event: eventName,
|
|
177
|
+
id: lastEventId,
|
|
178
|
+
retry: retryDelay
|
|
179
|
+
});
|
|
180
|
+
if (dataLines.length) {
|
|
181
|
+
yield data;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} finally {
|
|
186
|
+
signal.removeEventListener("abort", abortHandler);
|
|
187
|
+
reader.releaseLock();
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
onSseError?.(error);
|
|
192
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
196
|
+
await sleep(backoff);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const stream = createStream();
|
|
201
|
+
return { stream };
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// src/generated/core/pathSerializer.gen.ts
|
|
205
|
+
var separatorArrayExplode = (style) => {
|
|
206
|
+
switch (style) {
|
|
207
|
+
case "label":
|
|
208
|
+
return ".";
|
|
209
|
+
case "matrix":
|
|
210
|
+
return ";";
|
|
211
|
+
case "simple":
|
|
212
|
+
return ",";
|
|
213
|
+
default:
|
|
214
|
+
return "&";
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var separatorArrayNoExplode = (style) => {
|
|
218
|
+
switch (style) {
|
|
219
|
+
case "form":
|
|
220
|
+
return ",";
|
|
221
|
+
case "pipeDelimited":
|
|
222
|
+
return "|";
|
|
223
|
+
case "spaceDelimited":
|
|
224
|
+
return "%20";
|
|
225
|
+
default:
|
|
226
|
+
return ",";
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var separatorObjectExplode = (style) => {
|
|
230
|
+
switch (style) {
|
|
231
|
+
case "label":
|
|
232
|
+
return ".";
|
|
233
|
+
case "matrix":
|
|
234
|
+
return ";";
|
|
235
|
+
case "simple":
|
|
236
|
+
return ",";
|
|
237
|
+
default:
|
|
238
|
+
return "&";
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var serializeArrayParam = ({
|
|
242
|
+
allowReserved,
|
|
243
|
+
explode,
|
|
244
|
+
name,
|
|
245
|
+
style,
|
|
246
|
+
value
|
|
247
|
+
}) => {
|
|
248
|
+
if (!explode) {
|
|
249
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
250
|
+
switch (style) {
|
|
251
|
+
case "label":
|
|
252
|
+
return `.${joinedValues2}`;
|
|
253
|
+
case "matrix":
|
|
254
|
+
return `;${name}=${joinedValues2}`;
|
|
255
|
+
case "simple":
|
|
256
|
+
return joinedValues2;
|
|
257
|
+
default:
|
|
258
|
+
return `${name}=${joinedValues2}`;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const separator = separatorArrayExplode(style);
|
|
262
|
+
const joinedValues = value.map((v) => {
|
|
263
|
+
if (style === "label" || style === "simple") {
|
|
264
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
265
|
+
}
|
|
266
|
+
return serializePrimitiveParam({
|
|
267
|
+
allowReserved,
|
|
268
|
+
name,
|
|
269
|
+
value: v
|
|
270
|
+
});
|
|
271
|
+
}).join(separator);
|
|
272
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
273
|
+
};
|
|
274
|
+
var serializePrimitiveParam = ({
|
|
275
|
+
allowReserved,
|
|
276
|
+
name,
|
|
277
|
+
value
|
|
278
|
+
}) => {
|
|
279
|
+
if (value === void 0 || value === null) {
|
|
280
|
+
return "";
|
|
281
|
+
}
|
|
282
|
+
if (typeof value === "object") {
|
|
283
|
+
throw new Error(
|
|
284
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
288
|
+
};
|
|
289
|
+
var serializeObjectParam = ({
|
|
290
|
+
allowReserved,
|
|
291
|
+
explode,
|
|
292
|
+
name,
|
|
293
|
+
style,
|
|
294
|
+
value,
|
|
295
|
+
valueOnly
|
|
296
|
+
}) => {
|
|
297
|
+
if (value instanceof Date) {
|
|
298
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
299
|
+
}
|
|
300
|
+
if (style !== "deepObject" && !explode) {
|
|
301
|
+
let values = [];
|
|
302
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
303
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
304
|
+
});
|
|
305
|
+
const joinedValues2 = values.join(",");
|
|
306
|
+
switch (style) {
|
|
307
|
+
case "form":
|
|
308
|
+
return `${name}=${joinedValues2}`;
|
|
309
|
+
case "label":
|
|
310
|
+
return `.${joinedValues2}`;
|
|
311
|
+
case "matrix":
|
|
312
|
+
return `;${name}=${joinedValues2}`;
|
|
313
|
+
default:
|
|
314
|
+
return joinedValues2;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const separator = separatorObjectExplode(style);
|
|
318
|
+
const joinedValues = Object.entries(value).map(
|
|
319
|
+
([key, v]) => serializePrimitiveParam({
|
|
320
|
+
allowReserved,
|
|
321
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
322
|
+
value: v
|
|
323
|
+
})
|
|
324
|
+
).join(separator);
|
|
325
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// src/generated/core/utils.gen.ts
|
|
329
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
330
|
+
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
331
|
+
let url = _url;
|
|
332
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
333
|
+
if (matches) {
|
|
334
|
+
for (const match of matches) {
|
|
335
|
+
let explode = false;
|
|
336
|
+
let name = match.substring(1, match.length - 1);
|
|
337
|
+
let style = "simple";
|
|
338
|
+
if (name.endsWith("*")) {
|
|
339
|
+
explode = true;
|
|
340
|
+
name = name.substring(0, name.length - 1);
|
|
341
|
+
}
|
|
342
|
+
if (name.startsWith(".")) {
|
|
343
|
+
name = name.substring(1);
|
|
344
|
+
style = "label";
|
|
345
|
+
} else if (name.startsWith(";")) {
|
|
346
|
+
name = name.substring(1);
|
|
347
|
+
style = "matrix";
|
|
348
|
+
}
|
|
349
|
+
const value = path[name];
|
|
350
|
+
if (value === void 0 || value === null) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (Array.isArray(value)) {
|
|
354
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (typeof value === "object") {
|
|
358
|
+
url = url.replace(
|
|
359
|
+
match,
|
|
360
|
+
serializeObjectParam({
|
|
361
|
+
explode,
|
|
362
|
+
name,
|
|
363
|
+
style,
|
|
364
|
+
value,
|
|
365
|
+
valueOnly: true
|
|
366
|
+
})
|
|
367
|
+
);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (style === "matrix") {
|
|
371
|
+
url = url.replace(
|
|
372
|
+
match,
|
|
373
|
+
`;${serializePrimitiveParam({
|
|
374
|
+
name,
|
|
375
|
+
value
|
|
376
|
+
})}`
|
|
377
|
+
);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
const replaceValue = encodeURIComponent(
|
|
381
|
+
style === "label" ? `.${value}` : value
|
|
382
|
+
);
|
|
383
|
+
url = url.replace(match, replaceValue);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return url;
|
|
387
|
+
};
|
|
388
|
+
var getUrl = ({
|
|
389
|
+
baseUrl,
|
|
390
|
+
path,
|
|
391
|
+
query,
|
|
392
|
+
querySerializer,
|
|
393
|
+
url: _url
|
|
394
|
+
}) => {
|
|
395
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
396
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
397
|
+
if (path) {
|
|
398
|
+
url = defaultPathSerializer({ path, url });
|
|
399
|
+
}
|
|
400
|
+
let search = query ? querySerializer(query) : "";
|
|
401
|
+
if (search.startsWith("?")) {
|
|
402
|
+
search = search.substring(1);
|
|
403
|
+
}
|
|
404
|
+
if (search) {
|
|
405
|
+
url += `?${search}`;
|
|
406
|
+
}
|
|
407
|
+
return url;
|
|
408
|
+
};
|
|
409
|
+
function getValidRequestBody(options) {
|
|
410
|
+
const hasBody = options.body !== void 0;
|
|
411
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
412
|
+
if (isSerializedBody) {
|
|
413
|
+
if ("serializedBody" in options) {
|
|
414
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
415
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
416
|
+
}
|
|
417
|
+
return options.body !== "" ? options.body : null;
|
|
418
|
+
}
|
|
419
|
+
if (hasBody) {
|
|
420
|
+
return options.body;
|
|
421
|
+
}
|
|
422
|
+
return void 0;
|
|
423
|
+
}
|
|
424
|
+
|
|
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
|
+
// src/generated/core/auth.gen.ts
|
|
468
|
+
var getAuthToken = async (auth, callback) => {
|
|
469
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
470
|
+
if (!token) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (auth.scheme === "bearer") {
|
|
474
|
+
return `Bearer ${token}`;
|
|
475
|
+
}
|
|
476
|
+
if (auth.scheme === "basic") {
|
|
477
|
+
return `Basic ${btoa(token)}`;
|
|
478
|
+
}
|
|
479
|
+
return token;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// src/generated/client/utils.gen.ts
|
|
483
|
+
var createQuerySerializer = ({
|
|
484
|
+
parameters = {},
|
|
485
|
+
...args
|
|
486
|
+
} = {}) => {
|
|
487
|
+
const querySerializer = (queryParams) => {
|
|
488
|
+
const search = [];
|
|
489
|
+
if (queryParams && typeof queryParams === "object") {
|
|
490
|
+
for (const name in queryParams) {
|
|
491
|
+
const value = queryParams[name];
|
|
492
|
+
if (value === void 0 || value === null) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const options = parameters[name] || args;
|
|
496
|
+
if (Array.isArray(value)) {
|
|
497
|
+
const serializedArray = serializeArrayParam({
|
|
498
|
+
allowReserved: options.allowReserved,
|
|
499
|
+
explode: true,
|
|
500
|
+
name,
|
|
501
|
+
style: "form",
|
|
502
|
+
value,
|
|
503
|
+
...options.array
|
|
504
|
+
});
|
|
505
|
+
if (serializedArray) search.push(serializedArray);
|
|
506
|
+
} else if (typeof value === "object") {
|
|
507
|
+
const serializedObject = serializeObjectParam({
|
|
508
|
+
allowReserved: options.allowReserved,
|
|
509
|
+
explode: true,
|
|
510
|
+
name,
|
|
511
|
+
style: "deepObject",
|
|
512
|
+
value,
|
|
513
|
+
...options.object
|
|
514
|
+
});
|
|
515
|
+
if (serializedObject) search.push(serializedObject);
|
|
516
|
+
} else {
|
|
517
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
518
|
+
allowReserved: options.allowReserved,
|
|
519
|
+
name,
|
|
520
|
+
value
|
|
521
|
+
});
|
|
522
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return search.join("&");
|
|
527
|
+
};
|
|
528
|
+
return querySerializer;
|
|
529
|
+
};
|
|
530
|
+
var getParseAs = (contentType) => {
|
|
531
|
+
if (!contentType) {
|
|
532
|
+
return "stream";
|
|
533
|
+
}
|
|
534
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
535
|
+
if (!cleanContent) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
539
|
+
return "json";
|
|
540
|
+
}
|
|
541
|
+
if (cleanContent === "multipart/form-data") {
|
|
542
|
+
return "formData";
|
|
543
|
+
}
|
|
544
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
545
|
+
return "blob";
|
|
546
|
+
}
|
|
547
|
+
if (cleanContent.startsWith("text/")) {
|
|
548
|
+
return "text";
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
551
|
+
};
|
|
552
|
+
var checkForExistence = (options, name) => {
|
|
553
|
+
if (!name) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
return false;
|
|
560
|
+
};
|
|
561
|
+
var setAuthParams = async ({
|
|
562
|
+
security,
|
|
563
|
+
...options
|
|
564
|
+
}) => {
|
|
565
|
+
for (const auth of security) {
|
|
566
|
+
if (checkForExistence(options, auth.name)) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const token = await getAuthToken(auth, options.auth);
|
|
570
|
+
if (!token) {
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const name = auth.name ?? "Authorization";
|
|
574
|
+
switch (auth.in) {
|
|
575
|
+
case "query":
|
|
576
|
+
if (!options.query) {
|
|
577
|
+
options.query = {};
|
|
578
|
+
}
|
|
579
|
+
options.query[name] = token;
|
|
580
|
+
break;
|
|
581
|
+
case "cookie":
|
|
582
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
583
|
+
break;
|
|
584
|
+
case "header":
|
|
585
|
+
default:
|
|
586
|
+
options.headers.set(name, token);
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
var buildUrl = (options) => getUrl({
|
|
592
|
+
baseUrl: options.baseUrl,
|
|
593
|
+
path: options.path,
|
|
594
|
+
query: options.query,
|
|
595
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
596
|
+
url: options.url
|
|
597
|
+
});
|
|
598
|
+
var mergeConfigs = (a, b) => {
|
|
599
|
+
const config = { ...a, ...b };
|
|
600
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
601
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
602
|
+
}
|
|
603
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
604
|
+
return config;
|
|
605
|
+
};
|
|
606
|
+
var headersEntries = (headers) => {
|
|
607
|
+
const entries = [];
|
|
608
|
+
headers.forEach((value, key) => {
|
|
609
|
+
entries.push([key, value]);
|
|
610
|
+
});
|
|
611
|
+
return entries;
|
|
612
|
+
};
|
|
613
|
+
var mergeHeaders = (...headers) => {
|
|
614
|
+
const mergedHeaders = new Headers();
|
|
615
|
+
for (const header of headers) {
|
|
616
|
+
if (!header) {
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
620
|
+
for (const [key, value] of iterator) {
|
|
621
|
+
if (value === null) {
|
|
622
|
+
mergedHeaders.delete(key);
|
|
623
|
+
} else if (Array.isArray(value)) {
|
|
624
|
+
for (const v of value) {
|
|
625
|
+
mergedHeaders.append(key, v);
|
|
626
|
+
}
|
|
627
|
+
} else if (value !== void 0) {
|
|
628
|
+
mergedHeaders.set(
|
|
629
|
+
key,
|
|
630
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return mergedHeaders;
|
|
636
|
+
};
|
|
637
|
+
var Interceptors = class {
|
|
638
|
+
fns = [];
|
|
639
|
+
clear() {
|
|
640
|
+
this.fns = [];
|
|
641
|
+
}
|
|
642
|
+
eject(id) {
|
|
643
|
+
const index = this.getInterceptorIndex(id);
|
|
644
|
+
if (this.fns[index]) {
|
|
645
|
+
this.fns[index] = null;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
exists(id) {
|
|
649
|
+
const index = this.getInterceptorIndex(id);
|
|
650
|
+
return Boolean(this.fns[index]);
|
|
651
|
+
}
|
|
652
|
+
getInterceptorIndex(id) {
|
|
653
|
+
if (typeof id === "number") {
|
|
654
|
+
return this.fns[id] ? id : -1;
|
|
655
|
+
}
|
|
656
|
+
return this.fns.indexOf(id);
|
|
657
|
+
}
|
|
658
|
+
update(id, fn) {
|
|
659
|
+
const index = this.getInterceptorIndex(id);
|
|
660
|
+
if (this.fns[index]) {
|
|
661
|
+
this.fns[index] = fn;
|
|
662
|
+
return id;
|
|
663
|
+
}
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
use(fn) {
|
|
667
|
+
this.fns.push(fn);
|
|
668
|
+
return this.fns.length - 1;
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
var createInterceptors = () => ({
|
|
672
|
+
error: new Interceptors(),
|
|
673
|
+
request: new Interceptors(),
|
|
674
|
+
response: new Interceptors()
|
|
675
|
+
});
|
|
676
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
677
|
+
allowReserved: false,
|
|
678
|
+
array: {
|
|
679
|
+
explode: true,
|
|
680
|
+
style: "form"
|
|
681
|
+
},
|
|
682
|
+
object: {
|
|
683
|
+
explode: true,
|
|
684
|
+
style: "deepObject"
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
var defaultHeaders = {
|
|
688
|
+
"Content-Type": "application/json"
|
|
689
|
+
};
|
|
690
|
+
var createConfig = (override = {}) => ({
|
|
691
|
+
...jsonBodySerializer,
|
|
692
|
+
headers: defaultHeaders,
|
|
693
|
+
parseAs: "auto",
|
|
694
|
+
querySerializer: defaultQuerySerializer,
|
|
695
|
+
...override
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// src/generated/client/client.gen.ts
|
|
699
|
+
var createClient = (config = {}) => {
|
|
700
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
701
|
+
const getConfig = () => ({ ..._config });
|
|
702
|
+
const setConfig = (config2) => {
|
|
703
|
+
_config = mergeConfigs(_config, config2);
|
|
704
|
+
return getConfig();
|
|
705
|
+
};
|
|
706
|
+
const interceptors = createInterceptors();
|
|
707
|
+
const beforeRequest = async (options) => {
|
|
708
|
+
const opts = {
|
|
709
|
+
..._config,
|
|
710
|
+
...options,
|
|
711
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
712
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
713
|
+
serializedBody: void 0
|
|
714
|
+
};
|
|
715
|
+
if (opts.security) {
|
|
716
|
+
await setAuthParams({
|
|
717
|
+
...opts,
|
|
718
|
+
security: opts.security
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
if (opts.requestValidator) {
|
|
722
|
+
await opts.requestValidator(opts);
|
|
723
|
+
}
|
|
724
|
+
const transformed = applyRequestCaseTransforms(opts);
|
|
725
|
+
if (transformed.body !== void 0 && transformed.bodySerializer) {
|
|
726
|
+
transformed.serializedBody = transformed.bodySerializer(transformed.body);
|
|
727
|
+
}
|
|
728
|
+
if (transformed.body === void 0 || transformed.serializedBody === "") {
|
|
729
|
+
transformed.headers.delete("Content-Type");
|
|
730
|
+
}
|
|
731
|
+
const url = buildUrl(transformed);
|
|
732
|
+
return { opts: transformed, url };
|
|
733
|
+
};
|
|
734
|
+
const request = async (options) => {
|
|
735
|
+
const { opts, url } = await beforeRequest(options);
|
|
736
|
+
const requestInit = {
|
|
737
|
+
redirect: "follow",
|
|
738
|
+
...opts,
|
|
739
|
+
body: getValidRequestBody(opts)
|
|
740
|
+
};
|
|
741
|
+
let request2 = new Request(url, requestInit);
|
|
742
|
+
for (const fn of interceptors.request.fns) {
|
|
743
|
+
if (fn) {
|
|
744
|
+
request2 = await fn(request2, opts);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
const _fetch = opts.fetch;
|
|
748
|
+
let response;
|
|
749
|
+
try {
|
|
750
|
+
response = await _fetch(request2);
|
|
751
|
+
} catch (error2) {
|
|
752
|
+
let finalError2 = error2;
|
|
753
|
+
for (const fn of interceptors.error.fns) {
|
|
754
|
+
if (fn) {
|
|
755
|
+
finalError2 = await fn(error2, void 0, request2, opts);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
finalError2 = finalError2 || {};
|
|
759
|
+
if (opts.throwOnError) {
|
|
760
|
+
throw finalError2;
|
|
761
|
+
}
|
|
762
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
763
|
+
error: finalError2,
|
|
764
|
+
request: request2,
|
|
765
|
+
response: void 0
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
for (const fn of interceptors.response.fns) {
|
|
769
|
+
if (fn) {
|
|
770
|
+
response = await fn(response, request2, opts);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
const result = {
|
|
774
|
+
request: request2,
|
|
775
|
+
response
|
|
776
|
+
};
|
|
777
|
+
if (response.ok) {
|
|
778
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
779
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
780
|
+
let emptyData;
|
|
781
|
+
switch (parseAs) {
|
|
782
|
+
case "arrayBuffer":
|
|
783
|
+
case "blob":
|
|
784
|
+
case "text":
|
|
785
|
+
emptyData = await response[parseAs]();
|
|
786
|
+
break;
|
|
787
|
+
case "formData":
|
|
788
|
+
emptyData = new FormData();
|
|
789
|
+
break;
|
|
790
|
+
case "stream":
|
|
791
|
+
emptyData = response.body;
|
|
792
|
+
break;
|
|
793
|
+
case "json":
|
|
794
|
+
default:
|
|
795
|
+
emptyData = {};
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
799
|
+
data: emptyData,
|
|
800
|
+
...result
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
let data;
|
|
804
|
+
switch (parseAs) {
|
|
805
|
+
case "arrayBuffer":
|
|
806
|
+
case "blob":
|
|
807
|
+
case "formData":
|
|
808
|
+
case "text":
|
|
809
|
+
data = await response[parseAs]();
|
|
810
|
+
break;
|
|
811
|
+
case "json": {
|
|
812
|
+
const text = await response.text();
|
|
813
|
+
data = text ? JSON.parse(text) : {};
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
case "stream":
|
|
817
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
818
|
+
data: response.body,
|
|
819
|
+
...result
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
if (parseAs === "json") {
|
|
823
|
+
data = applyResponseCaseTransforms(data);
|
|
824
|
+
if (opts.responseValidator) {
|
|
825
|
+
await opts.responseValidator(data);
|
|
826
|
+
}
|
|
827
|
+
if (opts.responseTransformer) {
|
|
828
|
+
data = await opts.responseTransformer(data);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return opts.responseStyle === "data" ? data : {
|
|
832
|
+
data,
|
|
833
|
+
...result
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
const textError = await response.text();
|
|
837
|
+
let jsonError;
|
|
838
|
+
try {
|
|
839
|
+
jsonError = JSON.parse(textError);
|
|
840
|
+
} catch {
|
|
841
|
+
}
|
|
842
|
+
const error = jsonError ?? textError;
|
|
843
|
+
let finalError = error;
|
|
844
|
+
for (const fn of interceptors.error.fns) {
|
|
845
|
+
if (fn) {
|
|
846
|
+
finalError = await fn(error, response, request2, opts);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
finalError = finalError || {};
|
|
850
|
+
if (opts.throwOnError) {
|
|
851
|
+
throw finalError;
|
|
852
|
+
}
|
|
853
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
854
|
+
error: finalError,
|
|
855
|
+
...result
|
|
856
|
+
};
|
|
857
|
+
};
|
|
858
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
859
|
+
const makeSseFn = (method) => async (options) => {
|
|
860
|
+
const { opts, url } = await beforeRequest(options);
|
|
861
|
+
return createSseClient({
|
|
862
|
+
...opts,
|
|
863
|
+
body: opts.body,
|
|
864
|
+
headers: opts.headers,
|
|
865
|
+
method,
|
|
866
|
+
onRequest: async (url2, init) => {
|
|
867
|
+
let request2 = new Request(url2, init);
|
|
868
|
+
for (const fn of interceptors.request.fns) {
|
|
869
|
+
if (fn) {
|
|
870
|
+
request2 = await fn(request2, opts);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return request2;
|
|
874
|
+
},
|
|
875
|
+
serializedBody: getValidRequestBody(opts),
|
|
876
|
+
url
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
return {
|
|
880
|
+
buildUrl,
|
|
881
|
+
connect: makeMethodFn("CONNECT"),
|
|
882
|
+
delete: makeMethodFn("DELETE"),
|
|
883
|
+
get: makeMethodFn("GET"),
|
|
884
|
+
getConfig,
|
|
885
|
+
head: makeMethodFn("HEAD"),
|
|
886
|
+
interceptors,
|
|
887
|
+
options: makeMethodFn("OPTIONS"),
|
|
888
|
+
patch: makeMethodFn("PATCH"),
|
|
889
|
+
post: makeMethodFn("POST"),
|
|
890
|
+
put: makeMethodFn("PUT"),
|
|
891
|
+
request,
|
|
892
|
+
setConfig,
|
|
893
|
+
sse: {
|
|
894
|
+
connect: makeSseFn("CONNECT"),
|
|
895
|
+
delete: makeSseFn("DELETE"),
|
|
896
|
+
get: makeSseFn("GET"),
|
|
897
|
+
head: makeSseFn("HEAD"),
|
|
898
|
+
options: makeSseFn("OPTIONS"),
|
|
899
|
+
patch: makeSseFn("PATCH"),
|
|
900
|
+
post: makeSseFn("POST"),
|
|
901
|
+
put: makeSseFn("PUT"),
|
|
902
|
+
trace: makeSseFn("TRACE")
|
|
903
|
+
},
|
|
904
|
+
trace: makeMethodFn("TRACE")
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
// src/generated/client.gen.ts
|
|
909
|
+
var client = createClient(createClientConfig(createConfig({ baseUrl: "/api" })));
|
|
910
|
+
|
|
911
|
+
// src/generated/transformers.gen.ts
|
|
912
|
+
var u64DtoSchemaResponseTransformer = (data) => {
|
|
913
|
+
data = BigInt(data.toString());
|
|
914
|
+
return data;
|
|
915
|
+
};
|
|
916
|
+
var tileStakeDtoSchemaResponseTransformer = (data) => {
|
|
917
|
+
data.stake = u64DtoSchemaResponseTransformer(data.stake);
|
|
918
|
+
return data;
|
|
919
|
+
};
|
|
920
|
+
var roundDtoSchemaResponseTransformer = (data) => {
|
|
921
|
+
data.deployedBtcAmount = u64DtoSchemaResponseTransformer(data.deployedBtcAmount);
|
|
922
|
+
data.deployedPendingUsdAmount = u64DtoSchemaResponseTransformer(data.deployedPendingUsdAmount);
|
|
923
|
+
data.deployedUsdAmount = u64DtoSchemaResponseTransformer(data.deployedUsdAmount);
|
|
924
|
+
data.deployedUsdOnWinningTileAmount = u64DtoSchemaResponseTransformer(data.deployedUsdOnWinningTileAmount);
|
|
925
|
+
data.strikeBonusBtc = u64DtoSchemaResponseTransformer(data.strikeBonusBtc);
|
|
926
|
+
data.strikeBonusUsd = u64DtoSchemaResponseTransformer(data.strikeBonusUsd);
|
|
927
|
+
data.tileStakes = data.tileStakes.map((item) => tileStakeDtoSchemaResponseTransformer(item));
|
|
928
|
+
return data;
|
|
929
|
+
};
|
|
930
|
+
var strikeJackpotDtoSchemaResponseTransformer = (data) => {
|
|
931
|
+
data.btcAmount = u64DtoSchemaResponseTransformer(data.btcAmount);
|
|
932
|
+
data.pendingUsdAmount = u64DtoSchemaResponseTransformer(data.pendingUsdAmount);
|
|
933
|
+
data.usdAmount = u64DtoSchemaResponseTransformer(data.usdAmount);
|
|
934
|
+
return data;
|
|
935
|
+
};
|
|
936
|
+
var boardDtoSchemaResponseTransformer = (data) => {
|
|
937
|
+
if (data.activeRound) {
|
|
938
|
+
data.activeRound = roundDtoSchemaResponseTransformer(data.activeRound);
|
|
939
|
+
}
|
|
940
|
+
data.currentSlot = u64DtoSchemaResponseTransformer(data.currentSlot);
|
|
941
|
+
data.endSlot = u64DtoSchemaResponseTransformer(data.endSlot);
|
|
942
|
+
if (data.previousRound) {
|
|
943
|
+
data.previousRound = roundDtoSchemaResponseTransformer(data.previousRound);
|
|
944
|
+
}
|
|
945
|
+
data.startSlot = u64DtoSchemaResponseTransformer(data.startSlot);
|
|
946
|
+
data.strike = strikeJackpotDtoSchemaResponseTransformer(data.strike);
|
|
947
|
+
return data;
|
|
948
|
+
};
|
|
949
|
+
var getBoardResponseTransformer = async (data) => {
|
|
950
|
+
data.data = boardDtoSchemaResponseTransformer(data.data);
|
|
951
|
+
return data;
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// src/generated/zod.gen.ts
|
|
955
|
+
var z = __toESM(require("zod"), 1);
|
|
956
|
+
var zI128Dto = z.string();
|
|
957
|
+
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
|
+
var zInternalErrorCodeErrorBody = z.object({
|
|
959
|
+
code: z.enum(["internal_error"])
|
|
960
|
+
});
|
|
961
|
+
var zPubkeyDto = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
|
|
962
|
+
var zRoundStateDto = z.enum([
|
|
963
|
+
"active",
|
|
964
|
+
"revealed",
|
|
965
|
+
"settled",
|
|
966
|
+
"finished"
|
|
967
|
+
]);
|
|
968
|
+
var zU128Dto = z.string();
|
|
969
|
+
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" });
|
|
970
|
+
var zStrikeJackpotDto = z.object({
|
|
971
|
+
btcAmount: zU64Dto,
|
|
972
|
+
lastTriggerRoundId: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
973
|
+
pendingUsdAmount: zU64Dto,
|
|
974
|
+
usdAmount: zU64Dto
|
|
975
|
+
});
|
|
976
|
+
var zTileStakeDto = z.object({
|
|
977
|
+
deployCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
978
|
+
stake: zU64Dto
|
|
979
|
+
});
|
|
980
|
+
var zRoundDto = z.object({
|
|
981
|
+
address: zPubkeyDto,
|
|
982
|
+
deployedBtcAmount: zU64Dto,
|
|
983
|
+
deployedPendingUsdAmount: zU64Dto,
|
|
984
|
+
deployedUsdAmount: zU64Dto,
|
|
985
|
+
deployedUsdOnWinningTileAmount: zU64Dto,
|
|
986
|
+
id: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
987
|
+
minersCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
988
|
+
revealedMinersCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
989
|
+
settledMinersCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
990
|
+
state: zRoundStateDto,
|
|
991
|
+
strikeBonusBtc: zU64Dto,
|
|
992
|
+
strikeBonusUsd: zU64Dto,
|
|
993
|
+
tileStakes: z.array(zTileStakeDto),
|
|
994
|
+
winnersCount: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
995
|
+
winningTile: z.optional(z.union([
|
|
996
|
+
z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
997
|
+
z.null()
|
|
998
|
+
]))
|
|
999
|
+
});
|
|
1000
|
+
var zBoardDto = z.object({
|
|
1001
|
+
activeRound: z.optional(z.union([
|
|
1002
|
+
z.null(),
|
|
1003
|
+
zRoundDto
|
|
1004
|
+
])),
|
|
1005
|
+
address: zPubkeyDto,
|
|
1006
|
+
currentSlot: zU64Dto,
|
|
1007
|
+
endSlot: zU64Dto,
|
|
1008
|
+
previousRound: z.optional(z.union([
|
|
1009
|
+
z.null(),
|
|
1010
|
+
zRoundDto
|
|
1011
|
+
])),
|
|
1012
|
+
roundDuration: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1013
|
+
roundId: z.int().gte(0).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }),
|
|
1014
|
+
startSlot: zU64Dto,
|
|
1015
|
+
strike: zStrikeJackpotDto
|
|
1016
|
+
});
|
|
1017
|
+
var zGetBoardData = z.object({
|
|
1018
|
+
body: z.optional(z.never()),
|
|
1019
|
+
path: z.optional(z.never()),
|
|
1020
|
+
query: z.optional(z.never())
|
|
1021
|
+
});
|
|
1022
|
+
var zGetBoardResponse = z.object({
|
|
1023
|
+
data: zBoardDto
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
// src/generated/sdk.gen.ts
|
|
1027
|
+
var HeyApiClient = class {
|
|
1028
|
+
client;
|
|
1029
|
+
constructor(args) {
|
|
1030
|
+
this.client = args?.client ?? client;
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
var HeyApiRegistry = class {
|
|
1034
|
+
defaultKey = "default";
|
|
1035
|
+
instances = /* @__PURE__ */ new Map();
|
|
1036
|
+
get(key) {
|
|
1037
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
1038
|
+
if (!instance) {
|
|
1039
|
+
throw new Error(`No SDK client found. Create one with "new SatrushBackendSdk()" to fix this error.`);
|
|
1040
|
+
}
|
|
1041
|
+
return instance;
|
|
1042
|
+
}
|
|
1043
|
+
set(value, key) {
|
|
1044
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
var SatrushBackendSdk = class _SatrushBackendSdk extends HeyApiClient {
|
|
1048
|
+
static __registry = new HeyApiRegistry();
|
|
1049
|
+
constructor(args) {
|
|
1050
|
+
super(args);
|
|
1051
|
+
_SatrushBackendSdk.__registry.set(this, args?.key);
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Request board
|
|
1055
|
+
*/
|
|
1056
|
+
getBoard(options) {
|
|
1057
|
+
return (options?.client ?? this.client).get({
|
|
1058
|
+
requestValidator: async (data) => await zGetBoardData.parseAsync(data),
|
|
1059
|
+
responseTransformer: getBoardResponseTransformer,
|
|
1060
|
+
responseValidator: async (data) => await zGetBoardResponse.parseAsync(data),
|
|
1061
|
+
url: "/v1/board",
|
|
1062
|
+
...options
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// src/generated/types.gen.ts
|
|
1068
|
+
var RoundStateDto = {
|
|
1069
|
+
ACTIVE: "active",
|
|
1070
|
+
REVEALED: "revealed",
|
|
1071
|
+
SETTLED: "settled",
|
|
1072
|
+
FINISHED: "finished"
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
// src/error.ts
|
|
1076
|
+
var SatrushBackendSdkError = class extends Error {
|
|
1077
|
+
cause;
|
|
1078
|
+
status;
|
|
1079
|
+
constructor(message, status, cause) {
|
|
1080
|
+
super(message);
|
|
1081
|
+
this.name = "SatrushSdkError";
|
|
1082
|
+
this.status = status;
|
|
1083
|
+
if (cause !== void 0) {
|
|
1084
|
+
this.cause = cause;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
var satrushSdkErrorInterceptor = (error, response) => {
|
|
1089
|
+
const status = response?.status ?? 0;
|
|
1090
|
+
const message = status ? `HTTP ${status}` : "Network error";
|
|
1091
|
+
return new SatrushBackendSdkError(message, status, error);
|
|
1092
|
+
};
|
|
1093
|
+
var isSatrushSdkError = (error) => error instanceof SatrushBackendSdkError;
|
|
1094
|
+
|
|
1095
|
+
// src/utils/unwrap.ts
|
|
1096
|
+
function unwrapData(data) {
|
|
1097
|
+
if (data && typeof data === "object" && "data" in data && Object.keys(data).length === 1) {
|
|
1098
|
+
return data.data;
|
|
1099
|
+
}
|
|
1100
|
+
return data;
|
|
1101
|
+
}
|
|
1102
|
+
async function unwrap(promise) {
|
|
1103
|
+
const res = await promise;
|
|
1104
|
+
if (res && typeof res === "object" && "response" in res) {
|
|
1105
|
+
const sdkRes = res;
|
|
1106
|
+
if ("error" in sdkRes && sdkRes.error !== void 0) {
|
|
1107
|
+
throw new SatrushBackendSdkError(String(sdkRes.error), sdkRes.response?.status ?? 0, sdkRes.error);
|
|
1108
|
+
}
|
|
1109
|
+
if ("data" in sdkRes) {
|
|
1110
|
+
return unwrapData(sdkRes.data);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return unwrapData(res);
|
|
1114
|
+
}
|
|
1115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1116
|
+
0 && (module.exports = {
|
|
1117
|
+
RoundStateDto,
|
|
1118
|
+
SatrushBackendSdk,
|
|
1119
|
+
SatrushBackendSdkError,
|
|
1120
|
+
createClient,
|
|
1121
|
+
createSseClient,
|
|
1122
|
+
isSatrushSdkError,
|
|
1123
|
+
satrushSdkErrorInterceptor,
|
|
1124
|
+
unwrap,
|
|
1125
|
+
zBoardDto,
|
|
1126
|
+
zGetBoardData,
|
|
1127
|
+
zGetBoardResponse,
|
|
1128
|
+
zI128Dto,
|
|
1129
|
+
zI64Dto,
|
|
1130
|
+
zInternalErrorCodeErrorBody,
|
|
1131
|
+
zPubkeyDto,
|
|
1132
|
+
zRoundDto,
|
|
1133
|
+
zRoundStateDto,
|
|
1134
|
+
zStrikeJackpotDto,
|
|
1135
|
+
zTileStakeDto,
|
|
1136
|
+
zU128Dto,
|
|
1137
|
+
zU64Dto
|
|
1138
|
+
});
|