@sereel/sdk 0.1.5 → 0.1.6

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/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 instanceof Error && error.name === "AbortError") {
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
  }
@@ -209,53 +234,349 @@ function isString(value) {
209
234
  function isNullableString(value) {
210
235
  return typeof value === "string" || value === null;
211
236
  }
237
+ function isOptionalNullableString(value) {
238
+ return typeof value === "string" || value === null || value === void 0;
239
+ }
212
240
  function isFiniteNumber(value) {
213
241
  return typeof value === "number" && Number.isFinite(value);
214
242
  }
215
243
  function isBoolean(value) {
216
244
  return typeof value === "boolean";
217
245
  }
218
- function isProspectus(value) {
219
- return isRecord(value) && isString(value.name) && isString(value.url);
246
+ var ValidationContext = class {
247
+ failures = [];
248
+ check(condition, path, expected, received) {
249
+ if (!condition) {
250
+ this.failures.push({ path, expected, received });
251
+ }
252
+ return condition;
253
+ }
254
+ };
255
+ function asRecord(value) {
256
+ return isRecord(value) ? value : void 0;
220
257
  }
221
- function isTokenPartner(value) {
222
- return isRecord(value) && isString(value.partner_name) && isString(value.partner_logo) && isString(value.partner_role);
258
+ function isProspectus(value, ctx, path) {
259
+ const v = asRecord(value);
260
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
261
+ ctx.check(isString(v.name), `${path}.name`, "string", v.name);
262
+ ctx.check(isString(v.url), `${path}.url`, "string", v.url);
263
+ return true;
223
264
  }
224
- function isRuleSummary(value) {
225
- return isRecord(value) && isString(value.rule_address) && isString(value.rule_type);
265
+ function isTokenPartner(value, ctx, path) {
266
+ const v = asRecord(value);
267
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
268
+ ctx.check(
269
+ isString(v.partner_name),
270
+ `${path}.partner_name`,
271
+ "string",
272
+ v.partner_name
273
+ );
274
+ ctx.check(
275
+ isString(v.partner_logo),
276
+ `${path}.partner_logo`,
277
+ "string",
278
+ v.partner_logo
279
+ );
280
+ ctx.check(
281
+ isString(v.partner_role),
282
+ `${path}.partner_role`,
283
+ "string",
284
+ v.partner_role
285
+ );
286
+ return true;
226
287
  }
227
- function isRuleEngineSummary(value) {
228
- return isRecord(value) && isString(value.name) && isString(value.rule_engine_address) && Array.isArray(value.rules) && value.rules.every(isRuleSummary);
288
+ function isRuleSummary(value, ctx, path) {
289
+ const v = asRecord(value);
290
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
291
+ ctx.check(
292
+ isString(v.rule_address),
293
+ `${path}.rule_address`,
294
+ "string",
295
+ v.rule_address
296
+ );
297
+ ctx.check(
298
+ isString(v.rule_type),
299
+ `${path}.rule_type`,
300
+ "string",
301
+ v.rule_type
302
+ );
303
+ return true;
229
304
  }
230
- function isSecurityDetails(value) {
231
- if (!isRecord(value)) return false;
232
- const hasRequiredStrings = isString(value.token_address) && isString(value.token_name) && isString(value.token_symbol) && isString(value.token_decimal) && isString(value.network_id) && isString(value.token_type) && isString(value.admin);
233
- if (!hasRequiredStrings) return false;
234
- if (!isNullableString(value.icon_url)) return false;
235
- if (!isNullableString(value.created_at)) return false;
236
- if (value.prospectus !== null && value.prospectus !== void 0) {
237
- if (!isProspectus(value.prospectus)) return false;
305
+ function isRuleEngineSummary(value, ctx, path) {
306
+ const v = asRecord(value);
307
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
308
+ ctx.check(isString(v.name), `${path}.name`, "string", v.name);
309
+ ctx.check(
310
+ isString(v.rule_engine_address),
311
+ `${path}.rule_engine_address`,
312
+ "string",
313
+ v.rule_engine_address
314
+ );
315
+ const rulesOk = ctx.check(
316
+ Array.isArray(v.rules),
317
+ `${path}.rules`,
318
+ "array",
319
+ v.rules
320
+ );
321
+ if (rulesOk) {
322
+ v.rules.forEach(
323
+ (rule, i) => isRuleSummary(rule, ctx, `${path}.rules[${i}]`)
324
+ );
238
325
  }
239
- if (value.partners !== null && value.partners !== void 0) {
240
- if (!Array.isArray(value.partners) || !value.partners.every(isTokenPartner))
241
- return false;
326
+ return true;
327
+ }
328
+ function isSecurityDetails(value, ctx, path) {
329
+ const v = asRecord(value);
330
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
331
+ ctx.check(
332
+ isString(v.token_address),
333
+ `${path}.token_address`,
334
+ "string",
335
+ v.token_address
336
+ );
337
+ ctx.check(
338
+ isString(v.token_name),
339
+ `${path}.token_name`,
340
+ "string",
341
+ v.token_name
342
+ );
343
+ ctx.check(
344
+ isString(v.token_symbol),
345
+ `${path}.token_symbol`,
346
+ "string",
347
+ v.token_symbol
348
+ );
349
+ ctx.check(
350
+ isString(v.token_decimal),
351
+ `${path}.token_decimal`,
352
+ "string",
353
+ v.token_decimal
354
+ );
355
+ ctx.check(
356
+ isString(v.network_id),
357
+ `${path}.network_id`,
358
+ "string",
359
+ v.network_id
360
+ );
361
+ ctx.check(
362
+ isString(v.token_type),
363
+ `${path}.token_type`,
364
+ "string",
365
+ v.token_type
366
+ );
367
+ ctx.check(isString(v.admin), `${path}.admin`, "string", v.admin);
368
+ ctx.check(
369
+ isNullableString(v.icon_url),
370
+ `${path}.icon_url`,
371
+ "string | null",
372
+ v.icon_url
373
+ );
374
+ ctx.check(
375
+ isNullableString(v.created_at),
376
+ `${path}.created_at`,
377
+ "string | null",
378
+ v.created_at
379
+ );
380
+ if (v.prospectus !== null && v.prospectus !== void 0) {
381
+ isProspectus(v.prospectus, ctx, `${path}.prospectus`);
382
+ }
383
+ if (v.partners !== null && v.partners !== void 0) {
384
+ const partnersOk = ctx.check(
385
+ Array.isArray(v.partners),
386
+ `${path}.partners`,
387
+ "array",
388
+ v.partners
389
+ );
390
+ if (partnersOk) {
391
+ v.partners.forEach(
392
+ (partner, i) => isTokenPartner(partner, ctx, `${path}.partners[${i}]`)
393
+ );
394
+ }
242
395
  }
243
- if (value.rule_engine !== null && value.rule_engine !== void 0) {
244
- if (!isRuleEngineSummary(value.rule_engine)) return false;
396
+ if (v.rule_engine !== null && v.rule_engine !== void 0) {
397
+ isRuleEngineSummary(v.rule_engine, ctx, `${path}.rule_engine`);
245
398
  }
246
399
  return true;
247
400
  }
248
- function isIssuerSummary(value) {
249
- return isRecord(value) && isString(value.id) && isString(value.legal_name) && isNullableString(value.display_name) && isString(value.jurisdiction) && isNullableString(value.website) && isNullableString(value.logo_url);
401
+ function isIssuerSummary(value, ctx, path) {
402
+ const v = asRecord(value);
403
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
404
+ ctx.check(isString(v.id), `${path}.id`, "string", v.id);
405
+ ctx.check(
406
+ isString(v.legal_name),
407
+ `${path}.legal_name`,
408
+ "string",
409
+ v.legal_name
410
+ );
411
+ ctx.check(
412
+ isNullableString(v.display_name),
413
+ `${path}.display_name`,
414
+ "string | null",
415
+ v.display_name
416
+ );
417
+ ctx.check(
418
+ isString(v.jurisdiction),
419
+ `${path}.jurisdiction`,
420
+ "string",
421
+ v.jurisdiction
422
+ );
423
+ ctx.check(
424
+ isNullableString(v.website),
425
+ `${path}.website`,
426
+ "string | null",
427
+ v.website
428
+ );
429
+ ctx.check(
430
+ isNullableString(v.logo_url),
431
+ `${path}.logo_url`,
432
+ "string | null",
433
+ v.logo_url
434
+ );
435
+ return true;
250
436
  }
251
- function isNativeCurrency(value) {
252
- return isRecord(value) && isString(value.symbol) && isString(value.name) && isFiniteNumber(value.decimals);
437
+ function isNativeCurrency(value, ctx, path) {
438
+ const v = asRecord(value);
439
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
440
+ ctx.check(isString(v.symbol), `${path}.symbol`, "string", v.symbol);
441
+ ctx.check(isString(v.name), `${path}.name`, "string", v.name);
442
+ ctx.check(
443
+ isFiniteNumber(v.decimals),
444
+ `${path}.decimals`,
445
+ "finite number",
446
+ v.decimals
447
+ );
448
+ return true;
253
449
  }
254
- function isNetworkDetails(value) {
255
- return isRecord(value) && isString(value.network_id) && isString(value.name) && isString(value.family) && (isFiniteNumber(value.chain_id) || value.chain_id === null) && isNativeCurrency(value.native_currency) && isString(value.rpc_endpoint) && Array.isArray(value.explorer_urls) && value.explorer_urls.every(isString) && isBoolean(value.can_deploy_cmtat_token) && isBoolean(value.can_deploy_trex_token) && isBoolean(value.is_testnet) && isBoolean(value.is_supported);
450
+ function isNetworkDetails(value, ctx, path) {
451
+ const v = asRecord(value);
452
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
453
+ ctx.check(
454
+ isString(v.network_id),
455
+ `${path}.network_id`,
456
+ "string",
457
+ v.network_id
458
+ );
459
+ ctx.check(isString(v.name), `${path}.name`, "string", v.name);
460
+ ctx.check(isString(v.family), `${path}.family`, "string", v.family);
461
+ ctx.check(
462
+ isFiniteNumber(v.chain_id) || v.chain_id === null,
463
+ `${path}.chain_id`,
464
+ "number | null",
465
+ v.chain_id
466
+ );
467
+ isNativeCurrency(v.native_currency, ctx, `${path}.native_currency`);
468
+ ctx.check(
469
+ isString(v.rpc_endpoint),
470
+ `${path}.rpc_endpoint`,
471
+ "string",
472
+ v.rpc_endpoint
473
+ );
474
+ const explorerOk = ctx.check(
475
+ Array.isArray(v.explorer_urls),
476
+ `${path}.explorer_urls`,
477
+ "string[]",
478
+ v.explorer_urls
479
+ );
480
+ if (explorerOk) {
481
+ v.explorer_urls.forEach(
482
+ (url, i) => ctx.check(
483
+ isString(url),
484
+ `${path}.explorer_urls[${i}]`,
485
+ "string",
486
+ url
487
+ )
488
+ );
489
+ }
490
+ ctx.check(
491
+ isBoolean(v.can_deploy_cmtat_token),
492
+ `${path}.can_deploy_cmtat_token`,
493
+ "boolean",
494
+ v.can_deploy_cmtat_token
495
+ );
496
+ ctx.check(
497
+ isBoolean(v.can_deploy_trex_token),
498
+ `${path}.can_deploy_trex_token`,
499
+ "boolean",
500
+ v.can_deploy_trex_token
501
+ );
502
+ ctx.check(
503
+ isBoolean(v.is_testnet),
504
+ `${path}.is_testnet`,
505
+ "boolean",
506
+ v.is_testnet
507
+ );
508
+ ctx.check(
509
+ isBoolean(v.is_supported),
510
+ `${path}.is_supported`,
511
+ "boolean",
512
+ v.is_supported
513
+ );
514
+ return true;
256
515
  }
257
- function isFundConfig(value) {
258
- return isRecord(value) && isString(value.nav_staleness_threshold) && isString(value.min_subscription) && isString(value.min_redemption) && isString(value.entry_fee_bps) && isString(value.exit_fee_bps) && isFiniteNumber(value.dealing_mode) && isString(value.redemption_gate_bps) && isString(value.protocol_subscription_fee_bps) && isString(value.protocol_fee_recipient) && isString(value.management_fee_bps_per_annum);
516
+ function isFundConfig(value, ctx, path) {
517
+ const v = asRecord(value);
518
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
519
+ ctx.check(
520
+ isString(v.nav_staleness_threshold),
521
+ `${path}.nav_staleness_threshold`,
522
+ "string",
523
+ v.nav_staleness_threshold
524
+ );
525
+ ctx.check(
526
+ isString(v.min_subscription),
527
+ `${path}.min_subscription`,
528
+ "string",
529
+ v.min_subscription
530
+ );
531
+ ctx.check(
532
+ isString(v.min_redemption),
533
+ `${path}.min_redemption`,
534
+ "string",
535
+ v.min_redemption
536
+ );
537
+ ctx.check(
538
+ isString(v.entry_fee_bps),
539
+ `${path}.entry_fee_bps`,
540
+ "string",
541
+ v.entry_fee_bps
542
+ );
543
+ ctx.check(
544
+ isString(v.exit_fee_bps),
545
+ `${path}.exit_fee_bps`,
546
+ "string",
547
+ v.exit_fee_bps
548
+ );
549
+ ctx.check(
550
+ isFiniteNumber(v.dealing_mode),
551
+ `${path}.dealing_mode`,
552
+ "finite number",
553
+ v.dealing_mode
554
+ );
555
+ ctx.check(
556
+ isString(v.redemption_gate_bps),
557
+ `${path}.redemption_gate_bps`,
558
+ "string",
559
+ v.redemption_gate_bps
560
+ );
561
+ ctx.check(
562
+ isOptionalNullableString(v.protocol_subscription_fee_bps),
563
+ `${path}.protocol_subscription_fee_bps`,
564
+ "string | null | undefined",
565
+ v.protocol_subscription_fee_bps
566
+ );
567
+ ctx.check(
568
+ isOptionalNullableString(v.protocol_fee_recipient),
569
+ `${path}.protocol_fee_recipient`,
570
+ "string | null | undefined",
571
+ v.protocol_fee_recipient
572
+ );
573
+ ctx.check(
574
+ isString(v.management_fee_bps_per_annum),
575
+ `${path}.management_fee_bps_per_annum`,
576
+ "string",
577
+ v.management_fee_bps_per_annum
578
+ );
579
+ return true;
259
580
  }
260
581
  var ISSUANCE_STATUSES = /* @__PURE__ */ new Set([
261
582
  "OPEN",
@@ -264,30 +585,187 @@ var ISSUANCE_STATUSES = /* @__PURE__ */ new Set([
264
585
  "SETTLED",
265
586
  "CANCELLED"
266
587
  ]);
267
- function isIssuanceStatus(value) {
268
- return isString(value) && ISSUANCE_STATUSES.has(value);
588
+ function isIssuanceStatus(value, ctx, path) {
589
+ return ctx.check(
590
+ isString(value) && ISSUANCE_STATUSES.has(value),
591
+ path,
592
+ `one of ${[...ISSUANCE_STATUSES].join(", ")}`,
593
+ value
594
+ );
595
+ }
596
+ function isBookSummary(value, ctx, path) {
597
+ const v = asRecord(value);
598
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
599
+ ctx.check(
600
+ isString(v.id) || v.id === null,
601
+ `${path}.id`,
602
+ "string | null",
603
+ v.id
604
+ );
605
+ ctx.check(
606
+ isString(v.organization_id),
607
+ `${path}.organization_id`,
608
+ "string",
609
+ v.organization_id
610
+ );
611
+ ctx.check(
612
+ isNullableString(v.name),
613
+ `${path}.name`,
614
+ "string | null",
615
+ v.name
616
+ );
617
+ ctx.check(
618
+ isNullableString(v.book_type),
619
+ `${path}.book_type`,
620
+ "string | null",
621
+ v.book_type
622
+ );
623
+ ctx.check(
624
+ isString(v.token_address),
625
+ `${path}.token_address`,
626
+ "string",
627
+ v.token_address
628
+ );
629
+ ctx.check(
630
+ isString(v.fund_token),
631
+ `${path}.fund_token`,
632
+ "string",
633
+ v.fund_token
634
+ );
635
+ ctx.check(
636
+ isString(v.network_id),
637
+ `${path}.network_id`,
638
+ "string",
639
+ v.network_id
640
+ );
641
+ ctx.check(
642
+ isOptionalNullableString(v.admin_wallet),
643
+ `${path}.admin_wallet`,
644
+ "string | null | undefined",
645
+ v.admin_wallet
646
+ );
647
+ ctx.check(
648
+ isOptionalNullableString(v.manager_wallet),
649
+ `${path}.manager_wallet`,
650
+ "string | null | undefined",
651
+ v.manager_wallet
652
+ );
653
+ ctx.check(
654
+ isString(v.settlement_token),
655
+ `${path}.settlement_token`,
656
+ "string",
657
+ v.settlement_token
658
+ );
659
+ ctx.check(
660
+ isNullableString(v.factory_address),
661
+ `${path}.factory_address`,
662
+ "string | null",
663
+ v.factory_address
664
+ );
665
+ ctx.check(
666
+ isNullableString(v.deployment_txn_hash),
667
+ `${path}.deployment_txn_hash`,
668
+ "string | null",
669
+ v.deployment_txn_hash
670
+ );
671
+ ctx.check(
672
+ isString(v.order_book_address),
673
+ `${path}.order_book_address`,
674
+ "string",
675
+ v.order_book_address
676
+ );
677
+ ctx.check(
678
+ isString(v.fund_address),
679
+ `${path}.fund_address`,
680
+ "string",
681
+ v.fund_address
682
+ );
683
+ ctx.check(
684
+ isString(v.fund_id),
685
+ `${path}.fund_id`,
686
+ "string",
687
+ v.fund_id
688
+ );
689
+ ctx.check(
690
+ isString(v.initial_nav),
691
+ `${path}.initial_nav`,
692
+ "string",
693
+ v.initial_nav
694
+ );
695
+ isFundConfig(v.fund_config, ctx, `${path}.fund_config`);
696
+ isIssuanceStatus(v.status, ctx, `${path}.status`);
697
+ ctx.check(
698
+ isNullableString(v.created_at),
699
+ `${path}.created_at`,
700
+ "string | null",
701
+ v.created_at
702
+ );
703
+ ctx.check(
704
+ isNullableString(v.updated_at),
705
+ `${path}.updated_at`,
706
+ "string | null",
707
+ v.updated_at
708
+ );
709
+ return true;
269
710
  }
270
- function isBookSummary(value) {
271
- return isRecord(value) && (isString(value.id) || value.id === null) && isString(value.organization_id) && isNullableString(value.name) && isNullableString(value.book_type) && isString(value.token_address) && isString(value.fund_token) && isString(value.network_id) && isString(value.settlement_token) && isNullableString(value.factory_address) && isNullableString(value.deployment_txn_hash) && isString(value.order_book_address) && isString(value.fund_address) && isString(value.fund_id) && isString(value.initial_nav) && isFundConfig(value.fund_config) && isIssuanceStatus(value.status) && isNullableString(value.created_at) && isNullableString(value.updated_at);
711
+ function isAssetRecord(value, ctx, path) {
712
+ const v = asRecord(value);
713
+ if (!ctx.check(v !== void 0, path, "object", value)) return false;
714
+ isSecurityDetails(v.security, ctx, `${path}.security`);
715
+ isIssuerSummary(v.issuer, ctx, `${path}.issuer`);
716
+ const booksOk = ctx.check(
717
+ Array.isArray(v.books),
718
+ `${path}.books`,
719
+ "array",
720
+ v.books
721
+ );
722
+ if (booksOk) {
723
+ v.books.forEach(
724
+ (book, i) => isBookSummary(book, ctx, `${path}.books[${i}]`)
725
+ );
726
+ }
727
+ isNetworkDetails(v.network, ctx, `${path}.network`);
728
+ return true;
272
729
  }
273
- function isAssetRecord(value) {
274
- return isRecord(value) && isSecurityDetails(value.security) && isIssuerSummary(value.issuer) && Array.isArray(value.books) && value.books.every(isBookSummary) && isNetworkDetails(value.network);
730
+ function buildValidationError(value, failures) {
731
+ const summary = failures.slice(0, 5).map(
732
+ (f) => `${f.path}: expected ${f.expected}, got ${JSON.stringify(f.received)}`
733
+ ).join("; ");
734
+ const message = failures.length > 5 ? `Received an invalid SDK response shape (${failures.length} issues). First 5: ${summary}` : `Received an invalid SDK response shape. ${summary}`;
735
+ return new MalformedResponseError(message, {
736
+ details: { failures: failures.slice(0, 20), value }
737
+ });
275
738
  }
276
739
  function validateSdkAssetsResponse(value) {
277
- if (!isRecord(value) || !Array.isArray(value.data) || !isFiniteNumber(value.count) || !value.data.every(isAssetRecord)) {
278
- throw new MalformedResponseError(
279
- "Received an invalid SDK assets response shape.",
280
- { details: value }
740
+ const ctx = new ValidationContext();
741
+ ctx.check(isRecord(value), "<root>", "object", value);
742
+ if (isRecord(value)) {
743
+ ctx.check(Array.isArray(value.data), "<root>.data", "array", value.data);
744
+ ctx.check(
745
+ isFiniteNumber(value.count),
746
+ "<root>.count",
747
+ "finite number",
748
+ value.count
281
749
  );
750
+ if (Array.isArray(value.data)) {
751
+ value.data.forEach(
752
+ (item, i) => isAssetRecord(item, ctx, `<root>.data[${i}]`)
753
+ );
754
+ }
755
+ }
756
+ if (ctx.failures.length > 0) {
757
+ throw buildValidationError(value, ctx.failures);
282
758
  }
283
759
  return value;
284
760
  }
285
761
  function validateSdkAssetResponse(value) {
286
- if (!isRecord(value) || !isAssetRecord(value.data)) {
287
- throw new MalformedResponseError(
288
- "Received an invalid SDK asset response shape.",
289
- { details: value }
290
- );
762
+ const ctx = new ValidationContext();
763
+ ctx.check(isRecord(value), "<root>", "object", value);
764
+ if (isRecord(value)) {
765
+ isAssetRecord(value.data, ctx, "<root>.data");
766
+ }
767
+ if (ctx.failures.length > 0) {
768
+ throw buildValidationError(value, ctx.failures);
291
769
  }
292
770
  return value;
293
771
  }
@@ -328,10 +806,13 @@ function createClient(config) {
328
806
  // Annotate the CommonJS export names for ESM import in node:
329
807
  0 && (module.exports = {
330
808
  ENVIRONMENT_BASE_URLS,
809
+ ForbiddenError,
331
810
  HttpError,
332
811
  InvalidConfigurationError,
333
812
  MalformedResponseError,
813
+ NetworkError,
334
814
  NotFoundError,
815
+ RateLimitError,
335
816
  SereelSdkError,
336
817
  ServerError,
337
818
  TimeoutError,