wapi-client 0.9.4 → 0.9.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.
@@ -61,7 +61,7 @@ var import_base_client = require('./base-client.cjs');
61
61
  var import_connection = require('./connection/connection.enums.cjs');
62
62
  var import__ = require('../index.cjs');
63
63
  var _a;
64
- var CLIENT_VERSION = (_a = '0.9.4') != null ? _a : "";
64
+ var CLIENT_VERSION = (_a = '0.9.6') != null ? _a : "";
65
65
  function createWsClient(opts) {
66
66
  const initialConnection = createConnection(opts);
67
67
  return new WsClient(initialConnection, opts);
@@ -31,7 +31,7 @@ import {
31
31
  } from "./connection/connection.enums";
32
32
  import { WapiClientType } from "../index";
33
33
  var _a;
34
- var CLIENT_VERSION = (_a = '0.9.4') != null ? _a : "";
34
+ var CLIENT_VERSION = (_a = '0.9.6') != null ? _a : "";
35
35
  function createWsClient(opts) {
36
36
  const initialConnection = createConnection(opts);
37
37
  return new WsClient(initialConnection, opts);
package/dist/client.cjs CHANGED
@@ -66,7 +66,7 @@ var import_errors = require('./lib/errors.cjs');
66
66
  var import_fns = require('./fns/index.cjs');
67
67
  var import_import_data = require('./fns/import-data/import-data.guards.cjs');
68
68
  var _a;
69
- var CLIENT_VERSION = (_a = '0.9.4') != null ? _a : "";
69
+ var CLIENT_VERSION = (_a = '0.9.6') != null ? _a : "";
70
70
  var Client = class {
71
71
  /**
72
72
  * @internal
package/dist/client.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  isImportDataFnInput
51
51
  } from "./fns/import-data/import-data.guards";
52
52
  var _a;
53
- var CLIENT_VERSION = (_a = '0.9.4') != null ? _a : "";
53
+ var CLIENT_VERSION = (_a = '0.9.6') != null ? _a : "";
54
54
  var Client = class {
55
55
  /**
56
56
  * @internal
@@ -54,6 +54,7 @@ __export(errors_exports, {
54
54
  getError: () => getError
55
55
  });
56
56
  module.exports = __toCommonJS(errors_exports);
57
+ var import_debug = require('./debug.cjs');
57
58
  var ERROR_GROUPS = {
58
59
  JSONRPC: {
59
60
  min: -32700,
@@ -420,6 +421,11 @@ var ERROR_GROUPS = {
420
421
  message: "TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
421
422
  description: `Withdrawals are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'withdrawal' requires reverse_withdrawal option to be true.`
422
423
  },
424
+ TR_UNIQUE_IDENTIFIER: {
425
+ code: -19115,
426
+ message: "TR_UNIQUE_IDENTIFIER",
427
+ description: `The identifier for Transfer object must be unique`
428
+ },
423
429
  TRG_SINGLE_PENDING_TR_CANT_RV: {
424
430
  code: -19200,
425
431
  message: "TRG_SINGLE_PENDING_TR_CANT_RV",
@@ -439,6 +445,26 @@ var ERROR_GROUPS = {
439
445
  code: -19203,
440
446
  message: "TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
441
447
  description: `TransferGroup includes Transfer.type = 'withdrawal', thus for extra validation the reverse_withdrawal option must be set true`
448
+ },
449
+ TRG_UNIQUE_IDENTIFIER: {
450
+ code: -19204,
451
+ message: "TRG_UNIQUE_IDENTIFIER",
452
+ description: `The identifier for TransferGroup object must be unique`
453
+ },
454
+ TOKEN_UNIQUE_FOREIGN: {
455
+ code: -19300,
456
+ message: "TOKEN_UNIQUE_FOREIGN",
457
+ description: `The foreign for Token object must be unique`
458
+ },
459
+ WALLET_UNIQUE_FOREIGN: {
460
+ code: -19400,
461
+ message: "WALLET_UNIQUE_FOREIGN",
462
+ description: `The foreign for Wallet object must be unique`
463
+ },
464
+ UNIQUE_CONSTRAINT: {
465
+ code: -19500,
466
+ message: "UNIQUE_CONSTRAINT",
467
+ description: `Insert violates unique constraint`
442
468
  }
443
469
  }
444
470
  },
@@ -479,9 +505,9 @@ var WAPIError = class extends Error {
479
505
  var _a;
480
506
  super(message);
481
507
  const errorType = (_a = ERRORS[type]) != null ? _a : ERRORS.INTERNAL_SERVER_ERROR;
482
- this.type = ERRORS[type] ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
483
- this.code = code || errorType.code;
484
- this.message = message || errorType.message;
508
+ this.type = type != null ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
509
+ this.code = code != null ? code : errorType.code;
510
+ this.message = message != null ? message : errorType.message;
485
511
  this.data = __spreadValues({
486
512
  description: errorType.description
487
513
  }, data && typeof data === "object" ? data : { error: data });
@@ -495,11 +521,12 @@ var WAPIError = class extends Error {
495
521
  }
496
522
  };
497
523
  var JSONRPCError = class extends WAPIError {
498
- constructor(type, data, message) {
524
+ constructor(type, data, message, code) {
499
525
  super({
500
526
  type,
501
527
  message,
502
- data
528
+ data,
529
+ code
503
530
  });
504
531
  }
505
532
  static get group() {
@@ -510,11 +537,12 @@ var JSONRPCError = class extends WAPIError {
510
537
  }
511
538
  };
512
539
  var StreamError = class extends WAPIError {
513
- constructor(type, data, message) {
540
+ constructor(type, data, message, code) {
514
541
  super({
515
542
  type,
516
543
  message,
517
- data
544
+ data,
545
+ code
518
546
  });
519
547
  }
520
548
  static get group() {
@@ -525,11 +553,12 @@ var StreamError = class extends WAPIError {
525
553
  }
526
554
  };
527
555
  var InputError = class extends WAPIError {
528
- constructor(type, data, message) {
556
+ constructor(type, data, message, code) {
529
557
  super({
530
558
  type,
531
559
  message,
532
- data
560
+ data,
561
+ code
533
562
  });
534
563
  }
535
564
  static get group() {
@@ -540,11 +569,12 @@ var InputError = class extends WAPIError {
540
569
  }
541
570
  };
542
571
  var ConfigError = class extends WAPIError {
543
- constructor(type, data, message) {
572
+ constructor(type, data, message, code) {
544
573
  super({
545
574
  type,
546
575
  message,
547
- data
576
+ data,
577
+ code
548
578
  });
549
579
  }
550
580
  static get group() {
@@ -555,11 +585,12 @@ var ConfigError = class extends WAPIError {
555
585
  }
556
586
  };
557
587
  var AuthError = class extends WAPIError {
558
- constructor(type, data, message) {
588
+ constructor(type, data, message, code) {
559
589
  super({
560
590
  type,
561
591
  message,
562
- data
592
+ data,
593
+ code
563
594
  });
564
595
  }
565
596
  static get group() {
@@ -570,11 +601,12 @@ var AuthError = class extends WAPIError {
570
601
  }
571
602
  };
572
603
  var ConstraintError = class extends WAPIError {
573
- constructor(type, data, message) {
604
+ constructor(type, data, message, code) {
574
605
  super({
575
606
  type,
576
607
  message,
577
- data
608
+ data,
609
+ code
578
610
  });
579
611
  }
580
612
  static get group() {
@@ -646,8 +678,11 @@ var ERROR_CODE_TO_TYPE = Object.fromEntries(
646
678
  function categorizeErrorCode(code) {
647
679
  const type = ERROR_CODE_TO_TYPE[code];
648
680
  if (!type) {
681
+ const group2 = Object.entries(ERROR_GROUPS).find(
682
+ ([key, group3]) => code >= group3.min && code <= group3.max
683
+ );
649
684
  return {
650
- group: void 0,
685
+ group: group2 == null ? void 0 : group2[0],
651
686
  type: void 0
652
687
  };
653
688
  }
@@ -667,8 +702,15 @@ function categorizeErrorCode(code) {
667
702
  };
668
703
  }
669
704
  function getError({ code, message, data }) {
670
- const { group, type } = categorizeErrorCode(code);
705
+ let { group, type } = categorizeErrorCode(code);
671
706
  message = message && message !== type ? message : ERRORS[type].description;
707
+ let novelCode = void 0;
708
+ if (group && group !== "JSONRPC" && type === void 0) {
709
+ (0, import_debug.debugLog)("Novel error from server", code, message, data);
710
+ type = message;
711
+ novelCode = code;
712
+ message = typeof data === "object" && "description" in data && typeof data.description === "string" ? data.description : message;
713
+ }
672
714
  switch (group) {
673
715
  case "JSONRPC":
674
716
  return new JSONRPCError(
@@ -680,31 +722,36 @@ function getError({ code, message, data }) {
680
722
  return new AuthError(
681
723
  type,
682
724
  data,
683
- message
725
+ message,
726
+ novelCode
684
727
  );
685
728
  case "CONFIG":
686
729
  return new ConfigError(
687
730
  type,
688
731
  data,
689
- message
732
+ message,
733
+ novelCode
690
734
  );
691
735
  case "CONSTRAINT":
692
736
  return new ConstraintError(
693
737
  type,
694
738
  data,
695
- message
739
+ message,
740
+ novelCode
696
741
  );
697
742
  case "INPUT":
698
743
  return new InputError(
699
744
  type,
700
745
  data,
701
- message
746
+ message,
747
+ novelCode
702
748
  );
703
749
  case "STREAM":
704
750
  return new StreamError(
705
751
  type,
706
752
  data,
707
- message
753
+ message,
754
+ novelCode
708
755
  );
709
756
  default:
710
757
  return new WAPIError({
@@ -16,6 +16,7 @@ var __spreadValues = (a, b) => {
16
16
  };
17
17
 
18
18
  // src/lib/errors.ts
19
+ import { debugLog } from "./debug.browser.js";
19
20
  var ERROR_GROUPS = {
20
21
  JSONRPC: {
21
22
  min: -32700,
@@ -382,6 +383,11 @@ var ERROR_GROUPS = {
382
383
  message: "TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
383
384
  description: `Withdrawals are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'withdrawal' requires reverse_withdrawal option to be true.`
384
385
  },
386
+ TR_UNIQUE_IDENTIFIER: {
387
+ code: -19115,
388
+ message: "TR_UNIQUE_IDENTIFIER",
389
+ description: `The identifier for Transfer object must be unique`
390
+ },
385
391
  TRG_SINGLE_PENDING_TR_CANT_RV: {
386
392
  code: -19200,
387
393
  message: "TRG_SINGLE_PENDING_TR_CANT_RV",
@@ -401,6 +407,26 @@ var ERROR_GROUPS = {
401
407
  code: -19203,
402
408
  message: "TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
403
409
  description: `TransferGroup includes Transfer.type = 'withdrawal', thus for extra validation the reverse_withdrawal option must be set true`
410
+ },
411
+ TRG_UNIQUE_IDENTIFIER: {
412
+ code: -19204,
413
+ message: "TRG_UNIQUE_IDENTIFIER",
414
+ description: `The identifier for TransferGroup object must be unique`
415
+ },
416
+ TOKEN_UNIQUE_FOREIGN: {
417
+ code: -19300,
418
+ message: "TOKEN_UNIQUE_FOREIGN",
419
+ description: `The foreign for Token object must be unique`
420
+ },
421
+ WALLET_UNIQUE_FOREIGN: {
422
+ code: -19400,
423
+ message: "WALLET_UNIQUE_FOREIGN",
424
+ description: `The foreign for Wallet object must be unique`
425
+ },
426
+ UNIQUE_CONSTRAINT: {
427
+ code: -19500,
428
+ message: "UNIQUE_CONSTRAINT",
429
+ description: `Insert violates unique constraint`
404
430
  }
405
431
  }
406
432
  },
@@ -441,9 +467,9 @@ var WAPIError = class extends Error {
441
467
  var _a;
442
468
  super(message);
443
469
  const errorType = (_a = ERRORS[type]) != null ? _a : ERRORS.INTERNAL_SERVER_ERROR;
444
- this.type = ERRORS[type] ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
445
- this.code = code || errorType.code;
446
- this.message = message || errorType.message;
470
+ this.type = type != null ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
471
+ this.code = code != null ? code : errorType.code;
472
+ this.message = message != null ? message : errorType.message;
447
473
  this.data = __spreadValues({
448
474
  description: errorType.description
449
475
  }, data && typeof data === "object" ? data : { error: data });
@@ -457,11 +483,12 @@ var WAPIError = class extends Error {
457
483
  }
458
484
  };
459
485
  var JSONRPCError = class extends WAPIError {
460
- constructor(type, data, message) {
486
+ constructor(type, data, message, code) {
461
487
  super({
462
488
  type,
463
489
  message,
464
- data
490
+ data,
491
+ code
465
492
  });
466
493
  }
467
494
  static get group() {
@@ -472,11 +499,12 @@ var JSONRPCError = class extends WAPIError {
472
499
  }
473
500
  };
474
501
  var StreamError = class extends WAPIError {
475
- constructor(type, data, message) {
502
+ constructor(type, data, message, code) {
476
503
  super({
477
504
  type,
478
505
  message,
479
- data
506
+ data,
507
+ code
480
508
  });
481
509
  }
482
510
  static get group() {
@@ -487,11 +515,12 @@ var StreamError = class extends WAPIError {
487
515
  }
488
516
  };
489
517
  var InputError = class extends WAPIError {
490
- constructor(type, data, message) {
518
+ constructor(type, data, message, code) {
491
519
  super({
492
520
  type,
493
521
  message,
494
- data
522
+ data,
523
+ code
495
524
  });
496
525
  }
497
526
  static get group() {
@@ -502,11 +531,12 @@ var InputError = class extends WAPIError {
502
531
  }
503
532
  };
504
533
  var ConfigError = class extends WAPIError {
505
- constructor(type, data, message) {
534
+ constructor(type, data, message, code) {
506
535
  super({
507
536
  type,
508
537
  message,
509
- data
538
+ data,
539
+ code
510
540
  });
511
541
  }
512
542
  static get group() {
@@ -517,11 +547,12 @@ var ConfigError = class extends WAPIError {
517
547
  }
518
548
  };
519
549
  var AuthError = class extends WAPIError {
520
- constructor(type, data, message) {
550
+ constructor(type, data, message, code) {
521
551
  super({
522
552
  type,
523
553
  message,
524
- data
554
+ data,
555
+ code
525
556
  });
526
557
  }
527
558
  static get group() {
@@ -532,11 +563,12 @@ var AuthError = class extends WAPIError {
532
563
  }
533
564
  };
534
565
  var ConstraintError = class extends WAPIError {
535
- constructor(type, data, message) {
566
+ constructor(type, data, message, code) {
536
567
  super({
537
568
  type,
538
569
  message,
539
- data
570
+ data,
571
+ code
540
572
  });
541
573
  }
542
574
  static get group() {
@@ -608,8 +640,11 @@ var ERROR_CODE_TO_TYPE = Object.fromEntries(
608
640
  function categorizeErrorCode(code) {
609
641
  const type = ERROR_CODE_TO_TYPE[code];
610
642
  if (!type) {
643
+ const group2 = Object.entries(ERROR_GROUPS).find(
644
+ ([key, group3]) => code >= group3.min && code <= group3.max
645
+ );
611
646
  return {
612
- group: void 0,
647
+ group: group2 == null ? void 0 : group2[0],
613
648
  type: void 0
614
649
  };
615
650
  }
@@ -629,8 +664,15 @@ function categorizeErrorCode(code) {
629
664
  };
630
665
  }
631
666
  function getError({ code, message, data }) {
632
- const { group, type } = categorizeErrorCode(code);
667
+ let { group, type } = categorizeErrorCode(code);
633
668
  message = message && message !== type ? message : ERRORS[type].description;
669
+ let novelCode = void 0;
670
+ if (group && group !== "JSONRPC" && type === void 0) {
671
+ debugLog("Novel error from server", code, message, data);
672
+ type = message;
673
+ novelCode = code;
674
+ message = typeof data === "object" && "description" in data && typeof data.description === "string" ? data.description : message;
675
+ }
634
676
  switch (group) {
635
677
  case "JSONRPC":
636
678
  return new JSONRPCError(
@@ -642,31 +684,36 @@ function getError({ code, message, data }) {
642
684
  return new AuthError(
643
685
  type,
644
686
  data,
645
- message
687
+ message,
688
+ novelCode
646
689
  );
647
690
  case "CONFIG":
648
691
  return new ConfigError(
649
692
  type,
650
693
  data,
651
- message
694
+ message,
695
+ novelCode
652
696
  );
653
697
  case "CONSTRAINT":
654
698
  return new ConstraintError(
655
699
  type,
656
700
  data,
657
- message
701
+ message,
702
+ novelCode
658
703
  );
659
704
  case "INPUT":
660
705
  return new InputError(
661
706
  type,
662
707
  data,
663
- message
708
+ message,
709
+ novelCode
664
710
  );
665
711
  case "STREAM":
666
712
  return new StreamError(
667
713
  type,
668
714
  data,
669
- message
715
+ message,
716
+ novelCode
670
717
  );
671
718
  default:
672
719
  return new WAPIError({
@@ -54,6 +54,7 @@ __export(errors_exports, {
54
54
  getError: () => getError
55
55
  });
56
56
  module.exports = __toCommonJS(errors_exports);
57
+ var import_debug = require('./debug.cjs');
57
58
  var ERROR_GROUPS = {
58
59
  JSONRPC: {
59
60
  min: -32700,
@@ -420,6 +421,11 @@ var ERROR_GROUPS = {
420
421
  message: "TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
421
422
  description: `Withdrawals are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'withdrawal' requires reverse_withdrawal option to be true.`
422
423
  },
424
+ TR_UNIQUE_IDENTIFIER: {
425
+ code: -19115,
426
+ message: "TR_UNIQUE_IDENTIFIER",
427
+ description: `The identifier for Transfer object must be unique`
428
+ },
423
429
  TRG_SINGLE_PENDING_TR_CANT_RV: {
424
430
  code: -19200,
425
431
  message: "TRG_SINGLE_PENDING_TR_CANT_RV",
@@ -439,6 +445,26 @@ var ERROR_GROUPS = {
439
445
  code: -19203,
440
446
  message: "TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",
441
447
  description: `TransferGroup includes Transfer.type = 'withdrawal', thus for extra validation the reverse_withdrawal option must be set true`
448
+ },
449
+ TRG_UNIQUE_IDENTIFIER: {
450
+ code: -19204,
451
+ message: "TRG_UNIQUE_IDENTIFIER",
452
+ description: `The identifier for TransferGroup object must be unique`
453
+ },
454
+ TOKEN_UNIQUE_FOREIGN: {
455
+ code: -19300,
456
+ message: "TOKEN_UNIQUE_FOREIGN",
457
+ description: `The foreign for Token object must be unique`
458
+ },
459
+ WALLET_UNIQUE_FOREIGN: {
460
+ code: -19400,
461
+ message: "WALLET_UNIQUE_FOREIGN",
462
+ description: `The foreign for Wallet object must be unique`
463
+ },
464
+ UNIQUE_CONSTRAINT: {
465
+ code: -19500,
466
+ message: "UNIQUE_CONSTRAINT",
467
+ description: `Insert violates unique constraint`
442
468
  }
443
469
  }
444
470
  },
@@ -479,9 +505,9 @@ var WAPIError = class extends Error {
479
505
  var _a;
480
506
  super(message);
481
507
  const errorType = (_a = ERRORS[type]) != null ? _a : ERRORS.INTERNAL_SERVER_ERROR;
482
- this.type = ERRORS[type] ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
483
- this.code = code || errorType.code;
484
- this.message = message || errorType.message;
508
+ this.type = type != null ? type : ERROR_TYPES.INTERNAL_SERVER_ERROR;
509
+ this.code = code != null ? code : errorType.code;
510
+ this.message = message != null ? message : errorType.message;
485
511
  this.data = __spreadValues({
486
512
  description: errorType.description
487
513
  }, data && typeof data === "object" ? data : { error: data });
@@ -495,11 +521,12 @@ var WAPIError = class extends Error {
495
521
  }
496
522
  };
497
523
  var JSONRPCError = class extends WAPIError {
498
- constructor(type, data, message) {
524
+ constructor(type, data, message, code) {
499
525
  super({
500
526
  type,
501
527
  message,
502
- data
528
+ data,
529
+ code
503
530
  });
504
531
  }
505
532
  static get group() {
@@ -510,11 +537,12 @@ var JSONRPCError = class extends WAPIError {
510
537
  }
511
538
  };
512
539
  var StreamError = class extends WAPIError {
513
- constructor(type, data, message) {
540
+ constructor(type, data, message, code) {
514
541
  super({
515
542
  type,
516
543
  message,
517
- data
544
+ data,
545
+ code
518
546
  });
519
547
  }
520
548
  static get group() {
@@ -525,11 +553,12 @@ var StreamError = class extends WAPIError {
525
553
  }
526
554
  };
527
555
  var InputError = class extends WAPIError {
528
- constructor(type, data, message) {
556
+ constructor(type, data, message, code) {
529
557
  super({
530
558
  type,
531
559
  message,
532
- data
560
+ data,
561
+ code
533
562
  });
534
563
  }
535
564
  static get group() {
@@ -540,11 +569,12 @@ var InputError = class extends WAPIError {
540
569
  }
541
570
  };
542
571
  var ConfigError = class extends WAPIError {
543
- constructor(type, data, message) {
572
+ constructor(type, data, message, code) {
544
573
  super({
545
574
  type,
546
575
  message,
547
- data
576
+ data,
577
+ code
548
578
  });
549
579
  }
550
580
  static get group() {
@@ -555,11 +585,12 @@ var ConfigError = class extends WAPIError {
555
585
  }
556
586
  };
557
587
  var AuthError = class extends WAPIError {
558
- constructor(type, data, message) {
588
+ constructor(type, data, message, code) {
559
589
  super({
560
590
  type,
561
591
  message,
562
- data
592
+ data,
593
+ code
563
594
  });
564
595
  }
565
596
  static get group() {
@@ -570,11 +601,12 @@ var AuthError = class extends WAPIError {
570
601
  }
571
602
  };
572
603
  var ConstraintError = class extends WAPIError {
573
- constructor(type, data, message) {
604
+ constructor(type, data, message, code) {
574
605
  super({
575
606
  type,
576
607
  message,
577
- data
608
+ data,
609
+ code
578
610
  });
579
611
  }
580
612
  static get group() {
@@ -646,8 +678,11 @@ var ERROR_CODE_TO_TYPE = Object.fromEntries(
646
678
  function categorizeErrorCode(code) {
647
679
  const type = ERROR_CODE_TO_TYPE[code];
648
680
  if (!type) {
681
+ const group2 = Object.entries(ERROR_GROUPS).find(
682
+ ([key, group3]) => code >= group3.min && code <= group3.max
683
+ );
649
684
  return {
650
- group: void 0,
685
+ group: group2 == null ? void 0 : group2[0],
651
686
  type: void 0
652
687
  };
653
688
  }
@@ -667,8 +702,15 @@ function categorizeErrorCode(code) {
667
702
  };
668
703
  }
669
704
  function getError({ code, message, data }) {
670
- const { group, type } = categorizeErrorCode(code);
705
+ let { group, type } = categorizeErrorCode(code);
671
706
  message = message && message !== type ? message : ERRORS[type].description;
707
+ let novelCode = void 0;
708
+ if (group && group !== "JSONRPC" && type === void 0) {
709
+ (0, import_debug.debugLog)("Novel error from server", code, message, data);
710
+ type = message;
711
+ novelCode = code;
712
+ message = typeof data === "object" && "description" in data && typeof data.description === "string" ? data.description : message;
713
+ }
672
714
  switch (group) {
673
715
  case "JSONRPC":
674
716
  return new JSONRPCError(
@@ -680,31 +722,36 @@ function getError({ code, message, data }) {
680
722
  return new AuthError(
681
723
  type,
682
724
  data,
683
- message
725
+ message,
726
+ novelCode
684
727
  );
685
728
  case "CONFIG":
686
729
  return new ConfigError(
687
730
  type,
688
731
  data,
689
- message
732
+ message,
733
+ novelCode
690
734
  );
691
735
  case "CONSTRAINT":
692
736
  return new ConstraintError(
693
737
  type,
694
738
  data,
695
- message
739
+ message,
740
+ novelCode
696
741
  );
697
742
  case "INPUT":
698
743
  return new InputError(
699
744
  type,
700
745
  data,
701
- message
746
+ message,
747
+ novelCode
702
748
  );
703
749
  case "STREAM":
704
750
  return new StreamError(
705
751
  type,
706
752
  data,
707
- message
753
+ message,
754
+ novelCode
708
755
  );
709
756
  default:
710
757
  return new WAPIError({