@sereel/sdk 0.1.5 → 0.2.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 +46 -46
- package/dist/index.cjs +485 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -20
- package/dist/index.d.ts +12 -20
- package/dist/index.js +482 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,10 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ENVIRONMENT_BASE_URLS: () => ENVIRONMENT_BASE_URLS,
|
|
24
|
+
ForbiddenError: () => ForbiddenError,
|
|
24
25
|
HttpError: () => HttpError,
|
|
25
26
|
InvalidConfigurationError: () => InvalidConfigurationError,
|
|
26
27
|
MalformedResponseError: () => MalformedResponseError,
|
|
28
|
+
NetworkError: () => NetworkError,
|
|
27
29
|
NotFoundError: () => NotFoundError,
|
|
30
|
+
RateLimitError: () => RateLimitError,
|
|
28
31
|
SereelSdkError: () => SereelSdkError,
|
|
29
32
|
ServerError: () => ServerError,
|
|
30
33
|
TimeoutError: () => TimeoutError,
|
|
@@ -49,12 +52,18 @@ var SereelSdkError = class extends Error {
|
|
|
49
52
|
};
|
|
50
53
|
var InvalidConfigurationError = class extends SereelSdkError {
|
|
51
54
|
};
|
|
55
|
+
var NetworkError = class extends SereelSdkError {
|
|
56
|
+
};
|
|
52
57
|
var HttpError = class extends SereelSdkError {
|
|
53
58
|
};
|
|
54
59
|
var UnauthorizedError = class extends HttpError {
|
|
55
60
|
};
|
|
61
|
+
var ForbiddenError = class extends HttpError {
|
|
62
|
+
};
|
|
56
63
|
var NotFoundError = class extends HttpError {
|
|
57
64
|
};
|
|
65
|
+
var RateLimitError = class extends HttpError {
|
|
66
|
+
};
|
|
58
67
|
var ServerError = class extends HttpError {
|
|
59
68
|
};
|
|
60
69
|
var TimeoutError = class extends SereelSdkError {
|
|
@@ -159,14 +168,30 @@ function toHttpError(status, body) {
|
|
|
159
168
|
if (status === 401) {
|
|
160
169
|
return new UnauthorizedError(message, options);
|
|
161
170
|
}
|
|
171
|
+
if (status === 403) {
|
|
172
|
+
return new ForbiddenError(message, options);
|
|
173
|
+
}
|
|
162
174
|
if (status === 404) {
|
|
163
175
|
return new NotFoundError(message, options);
|
|
164
176
|
}
|
|
177
|
+
if (status === 429) {
|
|
178
|
+
return new RateLimitError(message, options);
|
|
179
|
+
}
|
|
165
180
|
if (status >= 500) {
|
|
166
181
|
return new ServerError(message, options);
|
|
167
182
|
}
|
|
168
183
|
return new HttpError(message, options);
|
|
169
184
|
}
|
|
185
|
+
function isAbortError(error) {
|
|
186
|
+
return error instanceof Error && (error.name === "AbortError" || error.constructor.name === "AbortError");
|
|
187
|
+
}
|
|
188
|
+
function wrapNetworkError(error) {
|
|
189
|
+
if (error instanceof NetworkError) {
|
|
190
|
+
return error;
|
|
191
|
+
}
|
|
192
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "Network request failed.";
|
|
193
|
+
return new NetworkError(message, { cause: error });
|
|
194
|
+
}
|
|
170
195
|
async function requestJson(config, path, validate) {
|
|
171
196
|
const { signal, cleanup } = createTimeoutSignal(config.timeoutMs);
|
|
172
197
|
try {
|
|
@@ -184,16 +209,16 @@ async function requestJson(config, path, validate) {
|
|
|
184
209
|
}
|
|
185
210
|
return validate(body);
|
|
186
211
|
} catch (error) {
|
|
187
|
-
if (error instanceof HttpError || error instanceof MalformedResponseError) {
|
|
212
|
+
if (error instanceof HttpError || error instanceof MalformedResponseError || error instanceof NetworkError) {
|
|
188
213
|
throw error;
|
|
189
214
|
}
|
|
190
|
-
if (error
|
|
215
|
+
if (isAbortError(error)) {
|
|
191
216
|
throw new TimeoutError(
|
|
192
217
|
`Request timed out after ${config.timeoutMs}ms.`,
|
|
193
218
|
{ cause: error }
|
|
194
219
|
);
|
|
195
220
|
}
|
|
196
|
-
throw error;
|
|
221
|
+
throw wrapNetworkError(error);
|
|
197
222
|
} finally {
|
|
198
223
|
cleanup();
|
|
199
224
|
}
|
|
@@ -215,47 +240,237 @@ function isFiniteNumber(value) {
|
|
|
215
240
|
function isBoolean(value) {
|
|
216
241
|
return typeof value === "boolean";
|
|
217
242
|
}
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
var ValidationContext = class {
|
|
244
|
+
failures = [];
|
|
245
|
+
check(condition, path, expected, received) {
|
|
246
|
+
if (!condition) {
|
|
247
|
+
this.failures.push({ path, expected, received });
|
|
248
|
+
}
|
|
249
|
+
return condition;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
function asRecord(value) {
|
|
253
|
+
return isRecord(value) ? value : void 0;
|
|
220
254
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
255
|
+
function isProspectus(value, ctx, path) {
|
|
256
|
+
const v = asRecord(value);
|
|
257
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
258
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
259
|
+
ctx.check(isString(v.url), `${path}.url`, "string", v.url);
|
|
260
|
+
return true;
|
|
223
261
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
262
|
+
function isTokenPartner(value, ctx, path) {
|
|
263
|
+
const v = asRecord(value);
|
|
264
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
265
|
+
ctx.check(
|
|
266
|
+
isString(v.partner_name),
|
|
267
|
+
`${path}.partner_name`,
|
|
268
|
+
"string",
|
|
269
|
+
v.partner_name
|
|
270
|
+
);
|
|
271
|
+
ctx.check(
|
|
272
|
+
isString(v.partner_logo),
|
|
273
|
+
`${path}.partner_logo`,
|
|
274
|
+
"string",
|
|
275
|
+
v.partner_logo
|
|
276
|
+
);
|
|
277
|
+
ctx.check(
|
|
278
|
+
isString(v.partner_role),
|
|
279
|
+
`${path}.partner_role`,
|
|
280
|
+
"string",
|
|
281
|
+
v.partner_role
|
|
282
|
+
);
|
|
283
|
+
return true;
|
|
226
284
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
285
|
+
function isRuleSummary(value, ctx, path) {
|
|
286
|
+
const v = asRecord(value);
|
|
287
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
288
|
+
ctx.check(
|
|
289
|
+
isString(v.rule_address),
|
|
290
|
+
`${path}.rule_address`,
|
|
291
|
+
"string",
|
|
292
|
+
v.rule_address
|
|
293
|
+
);
|
|
294
|
+
ctx.check(
|
|
295
|
+
isString(v.rule_type),
|
|
296
|
+
`${path}.rule_type`,
|
|
297
|
+
"string",
|
|
298
|
+
v.rule_type
|
|
299
|
+
);
|
|
300
|
+
return true;
|
|
229
301
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
302
|
+
function isRuleEngineSummary(value, ctx, path) {
|
|
303
|
+
const v = asRecord(value);
|
|
304
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
305
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
306
|
+
ctx.check(
|
|
307
|
+
isString(v.rule_engine_address),
|
|
308
|
+
`${path}.rule_engine_address`,
|
|
309
|
+
"string",
|
|
310
|
+
v.rule_engine_address
|
|
311
|
+
);
|
|
312
|
+
const rulesOk = ctx.check(
|
|
313
|
+
Array.isArray(v.rules),
|
|
314
|
+
`${path}.rules`,
|
|
315
|
+
"array",
|
|
316
|
+
v.rules
|
|
317
|
+
);
|
|
318
|
+
if (rulesOk) {
|
|
319
|
+
v.rules.forEach(
|
|
320
|
+
(rule, i) => isRuleSummary(rule, ctx, `${path}.rules[${i}]`)
|
|
321
|
+
);
|
|
245
322
|
}
|
|
246
323
|
return true;
|
|
247
324
|
}
|
|
248
|
-
function isIssuerSummary(value) {
|
|
249
|
-
|
|
325
|
+
function isIssuerSummary(value, ctx, path) {
|
|
326
|
+
const v = asRecord(value);
|
|
327
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
328
|
+
ctx.check(isString(v.id), `${path}.id`, "string", v.id);
|
|
329
|
+
ctx.check(
|
|
330
|
+
isString(v.legal_name),
|
|
331
|
+
`${path}.legal_name`,
|
|
332
|
+
"string",
|
|
333
|
+
v.legal_name
|
|
334
|
+
);
|
|
335
|
+
ctx.check(
|
|
336
|
+
isNullableString(v.display_name),
|
|
337
|
+
`${path}.display_name`,
|
|
338
|
+
"string | null",
|
|
339
|
+
v.display_name
|
|
340
|
+
);
|
|
341
|
+
ctx.check(
|
|
342
|
+
isString(v.jurisdiction),
|
|
343
|
+
`${path}.jurisdiction`,
|
|
344
|
+
"string",
|
|
345
|
+
v.jurisdiction
|
|
346
|
+
);
|
|
347
|
+
ctx.check(
|
|
348
|
+
isNullableString(v.website),
|
|
349
|
+
`${path}.website`,
|
|
350
|
+
"string | null",
|
|
351
|
+
v.website
|
|
352
|
+
);
|
|
353
|
+
ctx.check(
|
|
354
|
+
isNullableString(v.logo_url),
|
|
355
|
+
`${path}.logo_url`,
|
|
356
|
+
"string | null",
|
|
357
|
+
v.logo_url
|
|
358
|
+
);
|
|
359
|
+
return true;
|
|
250
360
|
}
|
|
251
|
-
function isNativeCurrency(value) {
|
|
252
|
-
|
|
361
|
+
function isNativeCurrency(value, ctx, path) {
|
|
362
|
+
const v = asRecord(value);
|
|
363
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
364
|
+
ctx.check(isString(v.symbol), `${path}.symbol`, "string", v.symbol);
|
|
365
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
366
|
+
ctx.check(
|
|
367
|
+
isFiniteNumber(v.decimals),
|
|
368
|
+
`${path}.decimals`,
|
|
369
|
+
"finite number",
|
|
370
|
+
v.decimals
|
|
371
|
+
);
|
|
372
|
+
return true;
|
|
253
373
|
}
|
|
254
|
-
function isNetworkDetails(value) {
|
|
255
|
-
|
|
374
|
+
function isNetworkDetails(value, ctx, path) {
|
|
375
|
+
const v = asRecord(value);
|
|
376
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
377
|
+
ctx.check(
|
|
378
|
+
isString(v.network_id),
|
|
379
|
+
`${path}.network_id`,
|
|
380
|
+
"string",
|
|
381
|
+
v.network_id
|
|
382
|
+
);
|
|
383
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
384
|
+
ctx.check(isString(v.family), `${path}.family`, "string", v.family);
|
|
385
|
+
ctx.check(
|
|
386
|
+
isFiniteNumber(v.chain_id) || v.chain_id === null,
|
|
387
|
+
`${path}.chain_id`,
|
|
388
|
+
"number | null",
|
|
389
|
+
v.chain_id
|
|
390
|
+
);
|
|
391
|
+
isNativeCurrency(v.native_currency, ctx, `${path}.native_currency`);
|
|
392
|
+
ctx.check(
|
|
393
|
+
isString(v.rpc_endpoint),
|
|
394
|
+
`${path}.rpc_endpoint`,
|
|
395
|
+
"string",
|
|
396
|
+
v.rpc_endpoint
|
|
397
|
+
);
|
|
398
|
+
const explorerOk = ctx.check(
|
|
399
|
+
Array.isArray(v.explorer_urls),
|
|
400
|
+
`${path}.explorer_urls`,
|
|
401
|
+
"string[]",
|
|
402
|
+
v.explorer_urls
|
|
403
|
+
);
|
|
404
|
+
if (explorerOk) {
|
|
405
|
+
v.explorer_urls.forEach(
|
|
406
|
+
(url, i) => ctx.check(
|
|
407
|
+
isString(url),
|
|
408
|
+
`${path}.explorer_urls[${i}]`,
|
|
409
|
+
"string",
|
|
410
|
+
url
|
|
411
|
+
)
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
ctx.check(
|
|
415
|
+
isBoolean(v.is_testnet),
|
|
416
|
+
`${path}.is_testnet`,
|
|
417
|
+
"boolean",
|
|
418
|
+
v.is_testnet
|
|
419
|
+
);
|
|
420
|
+
return true;
|
|
256
421
|
}
|
|
257
|
-
function isFundConfig(value) {
|
|
258
|
-
|
|
422
|
+
function isFundConfig(value, ctx, path) {
|
|
423
|
+
const v = asRecord(value);
|
|
424
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
425
|
+
ctx.check(
|
|
426
|
+
isString(v.nav_staleness_threshold),
|
|
427
|
+
`${path}.nav_staleness_threshold`,
|
|
428
|
+
"string",
|
|
429
|
+
v.nav_staleness_threshold
|
|
430
|
+
);
|
|
431
|
+
ctx.check(
|
|
432
|
+
isString(v.min_subscription),
|
|
433
|
+
`${path}.min_subscription`,
|
|
434
|
+
"string",
|
|
435
|
+
v.min_subscription
|
|
436
|
+
);
|
|
437
|
+
ctx.check(
|
|
438
|
+
isString(v.min_redemption),
|
|
439
|
+
`${path}.min_redemption`,
|
|
440
|
+
"string",
|
|
441
|
+
v.min_redemption
|
|
442
|
+
);
|
|
443
|
+
ctx.check(
|
|
444
|
+
isString(v.entry_fee_bps),
|
|
445
|
+
`${path}.entry_fee_bps`,
|
|
446
|
+
"string",
|
|
447
|
+
v.entry_fee_bps
|
|
448
|
+
);
|
|
449
|
+
ctx.check(
|
|
450
|
+
isString(v.exit_fee_bps),
|
|
451
|
+
`${path}.exit_fee_bps`,
|
|
452
|
+
"string",
|
|
453
|
+
v.exit_fee_bps
|
|
454
|
+
);
|
|
455
|
+
ctx.check(
|
|
456
|
+
isFiniteNumber(v.dealing_mode),
|
|
457
|
+
`${path}.dealing_mode`,
|
|
458
|
+
"finite number",
|
|
459
|
+
v.dealing_mode
|
|
460
|
+
);
|
|
461
|
+
ctx.check(
|
|
462
|
+
isString(v.redemption_gate_bps),
|
|
463
|
+
`${path}.redemption_gate_bps`,
|
|
464
|
+
"string",
|
|
465
|
+
v.redemption_gate_bps
|
|
466
|
+
);
|
|
467
|
+
ctx.check(
|
|
468
|
+
isString(v.management_fee_bps_per_annum),
|
|
469
|
+
`${path}.management_fee_bps_per_annum`,
|
|
470
|
+
"string",
|
|
471
|
+
v.management_fee_bps_per_annum
|
|
472
|
+
);
|
|
473
|
+
return true;
|
|
259
474
|
}
|
|
260
475
|
var ISSUANCE_STATUSES = /* @__PURE__ */ new Set([
|
|
261
476
|
"OPEN",
|
|
@@ -264,30 +479,248 @@ var ISSUANCE_STATUSES = /* @__PURE__ */ new Set([
|
|
|
264
479
|
"SETTLED",
|
|
265
480
|
"CANCELLED"
|
|
266
481
|
]);
|
|
267
|
-
function isIssuanceStatus(value) {
|
|
268
|
-
return
|
|
482
|
+
function isIssuanceStatus(value, ctx, path) {
|
|
483
|
+
return ctx.check(
|
|
484
|
+
isString(value) && ISSUANCE_STATUSES.has(value),
|
|
485
|
+
path,
|
|
486
|
+
`one of ${[...ISSUANCE_STATUSES].join(", ")}`,
|
|
487
|
+
value
|
|
488
|
+
);
|
|
269
489
|
}
|
|
270
|
-
function isBookSummary(value) {
|
|
271
|
-
|
|
490
|
+
function isBookSummary(value, ctx, path) {
|
|
491
|
+
const v = asRecord(value);
|
|
492
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
493
|
+
ctx.check(
|
|
494
|
+
isString(v.id) || v.id === null,
|
|
495
|
+
`${path}.id`,
|
|
496
|
+
"string | null",
|
|
497
|
+
v.id
|
|
498
|
+
);
|
|
499
|
+
ctx.check(
|
|
500
|
+
isString(v.organization_id),
|
|
501
|
+
`${path}.organization_id`,
|
|
502
|
+
"string",
|
|
503
|
+
v.organization_id
|
|
504
|
+
);
|
|
505
|
+
ctx.check(
|
|
506
|
+
isNullableString(v.name),
|
|
507
|
+
`${path}.name`,
|
|
508
|
+
"string | null",
|
|
509
|
+
v.name
|
|
510
|
+
);
|
|
511
|
+
ctx.check(
|
|
512
|
+
isNullableString(v.book_type),
|
|
513
|
+
`${path}.book_type`,
|
|
514
|
+
"string | null",
|
|
515
|
+
v.book_type
|
|
516
|
+
);
|
|
517
|
+
ctx.check(
|
|
518
|
+
isString(v.token_address),
|
|
519
|
+
`${path}.token_address`,
|
|
520
|
+
"string",
|
|
521
|
+
v.token_address
|
|
522
|
+
);
|
|
523
|
+
ctx.check(
|
|
524
|
+
isString(v.network_id),
|
|
525
|
+
`${path}.network_id`,
|
|
526
|
+
"string",
|
|
527
|
+
v.network_id
|
|
528
|
+
);
|
|
529
|
+
ctx.check(
|
|
530
|
+
isString(v.settlement_token),
|
|
531
|
+
`${path}.settlement_token`,
|
|
532
|
+
"string",
|
|
533
|
+
v.settlement_token
|
|
534
|
+
);
|
|
535
|
+
ctx.check(
|
|
536
|
+
isString(v.order_book_address),
|
|
537
|
+
`${path}.order_book_address`,
|
|
538
|
+
"string",
|
|
539
|
+
v.order_book_address
|
|
540
|
+
);
|
|
541
|
+
ctx.check(
|
|
542
|
+
isString(v.fund_address),
|
|
543
|
+
`${path}.fund_address`,
|
|
544
|
+
"string",
|
|
545
|
+
v.fund_address
|
|
546
|
+
);
|
|
547
|
+
ctx.check(
|
|
548
|
+
isString(v.fund_id),
|
|
549
|
+
`${path}.fund_id`,
|
|
550
|
+
"string",
|
|
551
|
+
v.fund_id
|
|
552
|
+
);
|
|
553
|
+
ctx.check(
|
|
554
|
+
isString(v.initial_nav),
|
|
555
|
+
`${path}.initial_nav`,
|
|
556
|
+
"string",
|
|
557
|
+
v.initial_nav
|
|
558
|
+
);
|
|
559
|
+
isFundConfig(v.fund_config, ctx, `${path}.fund_config`);
|
|
560
|
+
isIssuanceStatus(v.status, ctx, `${path}.status`);
|
|
561
|
+
ctx.check(
|
|
562
|
+
isNullableString(v.created_at),
|
|
563
|
+
`${path}.created_at`,
|
|
564
|
+
"string | null",
|
|
565
|
+
v.created_at
|
|
566
|
+
);
|
|
567
|
+
return true;
|
|
272
568
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
569
|
+
function isSecurityDetails(value, ctx, path) {
|
|
570
|
+
const v = asRecord(value);
|
|
571
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
572
|
+
ctx.check(
|
|
573
|
+
isString(v.token_address),
|
|
574
|
+
`${path}.token_address`,
|
|
575
|
+
"string",
|
|
576
|
+
v.token_address
|
|
577
|
+
);
|
|
578
|
+
ctx.check(
|
|
579
|
+
isString(v.token_name),
|
|
580
|
+
`${path}.token_name`,
|
|
581
|
+
"string",
|
|
582
|
+
v.token_name
|
|
583
|
+
);
|
|
584
|
+
ctx.check(
|
|
585
|
+
isString(v.token_symbol),
|
|
586
|
+
`${path}.token_symbol`,
|
|
587
|
+
"string",
|
|
588
|
+
v.token_symbol
|
|
589
|
+
);
|
|
590
|
+
ctx.check(
|
|
591
|
+
isString(v.token_decimal),
|
|
592
|
+
`${path}.token_decimal`,
|
|
593
|
+
"string",
|
|
594
|
+
v.token_decimal
|
|
595
|
+
);
|
|
596
|
+
ctx.check(
|
|
597
|
+
isString(v.network_id),
|
|
598
|
+
`${path}.network_id`,
|
|
599
|
+
"string",
|
|
600
|
+
v.network_id
|
|
601
|
+
);
|
|
602
|
+
ctx.check(
|
|
603
|
+
isString(v.token_type),
|
|
604
|
+
`${path}.token_type`,
|
|
605
|
+
"string",
|
|
606
|
+
v.token_type
|
|
607
|
+
);
|
|
608
|
+
ctx.check(isString(v.admin), `${path}.admin`, "string", v.admin);
|
|
609
|
+
ctx.check(
|
|
610
|
+
isNullableString(v.icon_url),
|
|
611
|
+
`${path}.icon_url`,
|
|
612
|
+
"string | null",
|
|
613
|
+
v.icon_url
|
|
614
|
+
);
|
|
615
|
+
ctx.check(
|
|
616
|
+
isNullableString(v.created_at),
|
|
617
|
+
`${path}.created_at`,
|
|
618
|
+
"string | null",
|
|
619
|
+
v.created_at
|
|
620
|
+
);
|
|
621
|
+
if (v.prospectus !== null && v.prospectus !== void 0) {
|
|
622
|
+
isProspectus(v.prospectus, ctx, `${path}.prospectus`);
|
|
623
|
+
}
|
|
624
|
+
if (v.issuer !== null && v.issuer !== void 0) {
|
|
625
|
+
isIssuerSummary(v.issuer, ctx, `${path}.issuer`);
|
|
626
|
+
}
|
|
627
|
+
if (v.book !== null && v.book !== void 0) {
|
|
628
|
+
isBookSummary(v.book, ctx, `${path}.book`);
|
|
629
|
+
}
|
|
630
|
+
if (v.partners !== null && v.partners !== void 0) {
|
|
631
|
+
const partnersOk = ctx.check(
|
|
632
|
+
Array.isArray(v.partners),
|
|
633
|
+
`${path}.partners`,
|
|
634
|
+
"array",
|
|
635
|
+
v.partners
|
|
636
|
+
);
|
|
637
|
+
if (partnersOk) {
|
|
638
|
+
v.partners.forEach(
|
|
639
|
+
(partner, i) => isTokenPartner(partner, ctx, `${path}.partners[${i}]`)
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
if (v.rule_engine !== null && v.rule_engine !== void 0) {
|
|
644
|
+
isRuleEngineSummary(v.rule_engine, ctx, `${path}.rule_engine`);
|
|
645
|
+
}
|
|
646
|
+
isNetworkDetails(v.network, ctx, `${path}.network`);
|
|
647
|
+
if (v.trex_claim_topics !== null && v.trex_claim_topics !== void 0) {
|
|
648
|
+
const topicsOk = ctx.check(
|
|
649
|
+
Array.isArray(v.trex_claim_topics),
|
|
650
|
+
`${path}.trex_claim_topics`,
|
|
651
|
+
"number[]",
|
|
652
|
+
v.trex_claim_topics
|
|
653
|
+
);
|
|
654
|
+
if (topicsOk) {
|
|
655
|
+
v.trex_claim_topics.forEach(
|
|
656
|
+
(topic, i) => ctx.check(
|
|
657
|
+
isFiniteNumber(topic),
|
|
658
|
+
`${path}.trex_claim_topics[${i}]`,
|
|
659
|
+
"finite number",
|
|
660
|
+
topic
|
|
661
|
+
)
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (v.trex_issuers !== null && v.trex_issuers !== void 0) {
|
|
666
|
+
const issuersOk = ctx.check(
|
|
667
|
+
Array.isArray(v.trex_issuers),
|
|
668
|
+
`${path}.trex_issuers`,
|
|
669
|
+
"string[]",
|
|
670
|
+
v.trex_issuers
|
|
671
|
+
);
|
|
672
|
+
if (issuersOk) {
|
|
673
|
+
v.trex_issuers.forEach(
|
|
674
|
+
(issuer, i) => ctx.check(
|
|
675
|
+
isString(issuer),
|
|
676
|
+
`${path}.trex_issuers[${i}]`,
|
|
677
|
+
"string",
|
|
678
|
+
issuer
|
|
679
|
+
)
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
function buildValidationError(value, failures) {
|
|
686
|
+
const summary = failures.slice(0, 5).map(
|
|
687
|
+
(f) => `${f.path}: expected ${f.expected}, got ${JSON.stringify(f.received)}`
|
|
688
|
+
).join("; ");
|
|
689
|
+
const message = failures.length > 5 ? `Received an invalid SDK response shape (${failures.length} issues). First 5: ${summary}` : `Received an invalid SDK response shape. ${summary}`;
|
|
690
|
+
return new MalformedResponseError(message, {
|
|
691
|
+
details: { failures: failures.slice(0, 20), value }
|
|
692
|
+
});
|
|
275
693
|
}
|
|
276
694
|
function validateSdkAssetsResponse(value) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
695
|
+
const ctx = new ValidationContext();
|
|
696
|
+
ctx.check(isRecord(value), "<root>", "object", value);
|
|
697
|
+
if (isRecord(value)) {
|
|
698
|
+
ctx.check(Array.isArray(value.data), "<root>.data", "array", value.data);
|
|
699
|
+
ctx.check(
|
|
700
|
+
isFiniteNumber(value.count),
|
|
701
|
+
"<root>.count",
|
|
702
|
+
"finite number",
|
|
703
|
+
value.count
|
|
281
704
|
);
|
|
705
|
+
if (Array.isArray(value.data)) {
|
|
706
|
+
value.data.forEach(
|
|
707
|
+
(item, i) => isSecurityDetails(item, ctx, `<root>.data[${i}]`)
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (ctx.failures.length > 0) {
|
|
712
|
+
throw buildValidationError(value, ctx.failures);
|
|
282
713
|
}
|
|
283
714
|
return value;
|
|
284
715
|
}
|
|
285
716
|
function validateSdkAssetResponse(value) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
717
|
+
const ctx = new ValidationContext();
|
|
718
|
+
ctx.check(isRecord(value), "<root>", "object", value);
|
|
719
|
+
if (isRecord(value)) {
|
|
720
|
+
isSecurityDetails(value.data, ctx, "<root>.data");
|
|
721
|
+
}
|
|
722
|
+
if (ctx.failures.length > 0) {
|
|
723
|
+
throw buildValidationError(value, ctx.failures);
|
|
291
724
|
}
|
|
292
725
|
return value;
|
|
293
726
|
}
|
|
@@ -328,10 +761,13 @@ function createClient(config) {
|
|
|
328
761
|
// Annotate the CommonJS export names for ESM import in node:
|
|
329
762
|
0 && (module.exports = {
|
|
330
763
|
ENVIRONMENT_BASE_URLS,
|
|
764
|
+
ForbiddenError,
|
|
331
765
|
HttpError,
|
|
332
766
|
InvalidConfigurationError,
|
|
333
767
|
MalformedResponseError,
|
|
768
|
+
NetworkError,
|
|
334
769
|
NotFoundError,
|
|
770
|
+
RateLimitError,
|
|
335
771
|
SereelSdkError,
|
|
336
772
|
ServerError,
|
|
337
773
|
TimeoutError,
|