@native-systems/utility 1.0.0 → 1.0.1
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.js +40 -38
- package/dist/index.d.ts +1 -5
- package/dist/index.esm.js +40 -38
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -618,6 +618,35 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
618
618
|
return PgException;
|
|
619
619
|
})(_wrap_native_super(Error));
|
|
620
620
|
|
|
621
|
+
function _class_call_check(instance, Constructor) {
|
|
622
|
+
if (!(instance instanceof Constructor)) {
|
|
623
|
+
throw new TypeError('Cannot call a class as a function');
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function _defineProperties(target, props) {
|
|
627
|
+
for (var i = 0; i < props.length; i++) {
|
|
628
|
+
var descriptor = props[i];
|
|
629
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
630
|
+
descriptor.configurable = true;
|
|
631
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
632
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
636
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
637
|
+
return Constructor;
|
|
638
|
+
}
|
|
639
|
+
function _instanceof(left, right) {
|
|
640
|
+
if (
|
|
641
|
+
right != null &&
|
|
642
|
+
typeof Symbol !== 'undefined' &&
|
|
643
|
+
right[Symbol.hasInstance]
|
|
644
|
+
) {
|
|
645
|
+
return !!right[Symbol.hasInstance](left);
|
|
646
|
+
} else {
|
|
647
|
+
return left instanceof right;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
621
650
|
var statusMap = {
|
|
622
651
|
100: 'Continue',
|
|
623
652
|
101: 'Switching Protocols',
|
|
@@ -668,48 +697,21 @@ var statusMap = {
|
|
|
668
697
|
504: 'Gateway Timeout',
|
|
669
698
|
505: 'HTTP Version Not Supported',
|
|
670
699
|
};
|
|
671
|
-
function getHttpStatusText(statusCode) {
|
|
672
|
-
var statusText = statusMap[statusCode];
|
|
673
|
-
if (!statusText) {
|
|
674
|
-
return 'Error';
|
|
675
|
-
}
|
|
676
|
-
return statusText;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
function _class_call_check(instance, Constructor) {
|
|
680
|
-
if (!(instance instanceof Constructor)) {
|
|
681
|
-
throw new TypeError('Cannot call a class as a function');
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
function _defineProperties(target, props) {
|
|
685
|
-
for (var i = 0; i < props.length; i++) {
|
|
686
|
-
var descriptor = props[i];
|
|
687
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
688
|
-
descriptor.configurable = true;
|
|
689
|
-
if ('value' in descriptor) descriptor.writable = true;
|
|
690
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
694
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
695
|
-
return Constructor;
|
|
696
|
-
}
|
|
697
|
-
function _instanceof(left, right) {
|
|
698
|
-
if (
|
|
699
|
-
right != null &&
|
|
700
|
-
typeof Symbol !== 'undefined' &&
|
|
701
|
-
right[Symbol.hasInstance]
|
|
702
|
-
) {
|
|
703
|
-
return !!right[Symbol.hasInstance](left);
|
|
704
|
-
} else {
|
|
705
|
-
return left instanceof right;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
700
|
var Exceptions = /*#__PURE__*/ (function () {
|
|
709
701
|
function Exceptions() {
|
|
710
702
|
_class_call_check(this, Exceptions);
|
|
711
703
|
}
|
|
712
704
|
_create_class(Exceptions, null, [
|
|
705
|
+
{
|
|
706
|
+
key: 'getHttpStatusText',
|
|
707
|
+
value: function getHttpStatusText(statusCode) {
|
|
708
|
+
var statusText = statusMap[statusCode];
|
|
709
|
+
if (!statusText) {
|
|
710
|
+
return 'Error';
|
|
711
|
+
}
|
|
712
|
+
return statusText;
|
|
713
|
+
},
|
|
714
|
+
},
|
|
713
715
|
{
|
|
714
716
|
key: 'transformPgError',
|
|
715
717
|
value: function transformPgError(error) {
|
|
@@ -752,7 +754,7 @@ var Exceptions = /*#__PURE__*/ (function () {
|
|
|
752
754
|
{
|
|
753
755
|
status: _error.code,
|
|
754
756
|
message: _error.message,
|
|
755
|
-
error: getHttpStatusText(_error.code),
|
|
757
|
+
error: this.getHttpStatusText(_error.code),
|
|
756
758
|
},
|
|
757
759
|
_error.code
|
|
758
760
|
);
|
package/dist/index.d.ts
CHANGED
|
@@ -588,14 +588,10 @@ declare module "@native-systems/utility" {
|
|
|
588
588
|
export { PgException };
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
-
declare module "@native-systems/utility" {
|
|
592
|
-
function getHttpStatusText(statusCode: number): string;
|
|
593
|
-
export { getHttpStatusText };
|
|
594
|
-
}
|
|
595
|
-
|
|
596
591
|
declare module "@native-systems/utility" {
|
|
597
592
|
import { HttpException } from "@nestjs/common";
|
|
598
593
|
class Exceptions {
|
|
594
|
+
private static getHttpStatusText;
|
|
599
595
|
/**
|
|
600
596
|
* Evaluates a thrown postgres error object, which is then sanitized into an appropriate NativeError object.
|
|
601
597
|
* @param error a postgres error that, for example is from a rejected promise.
|
package/dist/index.esm.js
CHANGED
|
@@ -616,6 +616,35 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
616
616
|
return PgException;
|
|
617
617
|
})(_wrap_native_super(Error));
|
|
618
618
|
|
|
619
|
+
function _class_call_check(instance, Constructor) {
|
|
620
|
+
if (!(instance instanceof Constructor)) {
|
|
621
|
+
throw new TypeError('Cannot call a class as a function');
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function _defineProperties(target, props) {
|
|
625
|
+
for (var i = 0; i < props.length; i++) {
|
|
626
|
+
var descriptor = props[i];
|
|
627
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
628
|
+
descriptor.configurable = true;
|
|
629
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
630
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
634
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
635
|
+
return Constructor;
|
|
636
|
+
}
|
|
637
|
+
function _instanceof(left, right) {
|
|
638
|
+
if (
|
|
639
|
+
right != null &&
|
|
640
|
+
typeof Symbol !== 'undefined' &&
|
|
641
|
+
right[Symbol.hasInstance]
|
|
642
|
+
) {
|
|
643
|
+
return !!right[Symbol.hasInstance](left);
|
|
644
|
+
} else {
|
|
645
|
+
return left instanceof right;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
619
648
|
var statusMap = {
|
|
620
649
|
100: 'Continue',
|
|
621
650
|
101: 'Switching Protocols',
|
|
@@ -666,48 +695,21 @@ var statusMap = {
|
|
|
666
695
|
504: 'Gateway Timeout',
|
|
667
696
|
505: 'HTTP Version Not Supported',
|
|
668
697
|
};
|
|
669
|
-
function getHttpStatusText(statusCode) {
|
|
670
|
-
var statusText = statusMap[statusCode];
|
|
671
|
-
if (!statusText) {
|
|
672
|
-
return 'Error';
|
|
673
|
-
}
|
|
674
|
-
return statusText;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
function _class_call_check(instance, Constructor) {
|
|
678
|
-
if (!(instance instanceof Constructor)) {
|
|
679
|
-
throw new TypeError('Cannot call a class as a function');
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
function _defineProperties(target, props) {
|
|
683
|
-
for (var i = 0; i < props.length; i++) {
|
|
684
|
-
var descriptor = props[i];
|
|
685
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
686
|
-
descriptor.configurable = true;
|
|
687
|
-
if ('value' in descriptor) descriptor.writable = true;
|
|
688
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
692
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
693
|
-
return Constructor;
|
|
694
|
-
}
|
|
695
|
-
function _instanceof(left, right) {
|
|
696
|
-
if (
|
|
697
|
-
right != null &&
|
|
698
|
-
typeof Symbol !== 'undefined' &&
|
|
699
|
-
right[Symbol.hasInstance]
|
|
700
|
-
) {
|
|
701
|
-
return !!right[Symbol.hasInstance](left);
|
|
702
|
-
} else {
|
|
703
|
-
return left instanceof right;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
698
|
var Exceptions = /*#__PURE__*/ (function () {
|
|
707
699
|
function Exceptions() {
|
|
708
700
|
_class_call_check(this, Exceptions);
|
|
709
701
|
}
|
|
710
702
|
_create_class(Exceptions, null, [
|
|
703
|
+
{
|
|
704
|
+
key: 'getHttpStatusText',
|
|
705
|
+
value: function getHttpStatusText(statusCode) {
|
|
706
|
+
var statusText = statusMap[statusCode];
|
|
707
|
+
if (!statusText) {
|
|
708
|
+
return 'Error';
|
|
709
|
+
}
|
|
710
|
+
return statusText;
|
|
711
|
+
},
|
|
712
|
+
},
|
|
711
713
|
{
|
|
712
714
|
key: 'transformPgError',
|
|
713
715
|
value: function transformPgError(error) {
|
|
@@ -750,7 +752,7 @@ var Exceptions = /*#__PURE__*/ (function () {
|
|
|
750
752
|
{
|
|
751
753
|
status: _error.code,
|
|
752
754
|
message: _error.message,
|
|
753
|
-
error: getHttpStatusText(_error.code),
|
|
755
|
+
error: this.getHttpStatusText(_error.code),
|
|
754
756
|
},
|
|
755
757
|
_error.code
|
|
756
758
|
);
|