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