@native-systems/utility 1.1.0 → 1.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/dist/index.cjs +72 -167
- package/dist/index.d.ts +73 -21
- package/dist/index.esm.js +72 -167
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var common = require('@nestjs/common');
|
|
4
|
-
|
|
5
3
|
var PostgresError = /*#__PURE__*/ (function (PostgresError) {
|
|
6
4
|
PostgresError['SUCCESSFUL_COMPLETION'] = '00000';
|
|
7
5
|
PostgresError['WARNING'] = '01000';
|
|
@@ -318,7 +316,7 @@ function _construct$1(Parent, args, Class) {
|
|
|
318
316
|
}
|
|
319
317
|
return _construct$1.apply(null, arguments);
|
|
320
318
|
}
|
|
321
|
-
function _define_property$
|
|
319
|
+
function _define_property$3(obj, key, value) {
|
|
322
320
|
if (key in obj) {
|
|
323
321
|
Object.defineProperty(obj, key, {
|
|
324
322
|
value: value,
|
|
@@ -422,7 +420,7 @@ var NativeException = /*#__PURE__*/ (function (Error1) {
|
|
|
422
420
|
_class_call_check$4(this, NativeException);
|
|
423
421
|
var _this;
|
|
424
422
|
(_this = _call_super$1(this, NativeException, [message])),
|
|
425
|
-
_define_property$
|
|
423
|
+
_define_property$3(_this, 'code', void 0);
|
|
426
424
|
_this.name = 'NativeError';
|
|
427
425
|
_this.code = code;
|
|
428
426
|
return _this;
|
|
@@ -484,7 +482,7 @@ function _create_class$3(Constructor, protoProps, staticProps) {
|
|
|
484
482
|
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
485
483
|
return Constructor;
|
|
486
484
|
}
|
|
487
|
-
function _define_property$
|
|
485
|
+
function _define_property$2(obj, key, value) {
|
|
488
486
|
if (key in obj) {
|
|
489
487
|
Object.defineProperty(obj, key, {
|
|
490
488
|
value: value,
|
|
@@ -584,8 +582,8 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
584
582
|
_class_call_check$3(this, PgException);
|
|
585
583
|
var _this;
|
|
586
584
|
(_this = _call_super(this, PgException, [message])),
|
|
587
|
-
_define_property$
|
|
588
|
-
_define_property$
|
|
585
|
+
_define_property$2(_this, 'err', void 0),
|
|
586
|
+
_define_property$2(_this, 'specific', void 0);
|
|
589
587
|
_this.name = 'PgError';
|
|
590
588
|
_this.err = err;
|
|
591
589
|
_this.specific = specific;
|
|
@@ -633,156 +631,10 @@ function _defineProperties$2(target, props) {
|
|
|
633
631
|
}
|
|
634
632
|
}
|
|
635
633
|
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
636
|
-
if (
|
|
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
|
-
}
|
|
650
|
-
var statusMap = {
|
|
651
|
-
100: 'Continue',
|
|
652
|
-
101: 'Switching Protocols',
|
|
653
|
-
102: 'Processing',
|
|
654
|
-
103: 'Early Hints',
|
|
655
|
-
200: 'OK',
|
|
656
|
-
201: 'Created',
|
|
657
|
-
202: 'Accepted',
|
|
658
|
-
203: 'Non-Authoritative Information',
|
|
659
|
-
204: 'No Content',
|
|
660
|
-
205: 'Reset Content',
|
|
661
|
-
206: 'Partial Content',
|
|
662
|
-
300: 'Multiple Choices',
|
|
663
|
-
301: 'Moved Permanently',
|
|
664
|
-
302: 'Found',
|
|
665
|
-
303: 'See Other',
|
|
666
|
-
304: 'Not Modified',
|
|
667
|
-
307: 'Temporary Redirect',
|
|
668
|
-
308: 'Permanent Redirect',
|
|
669
|
-
400: 'Bad Request',
|
|
670
|
-
401: 'Unauthorized',
|
|
671
|
-
402: 'Payment Required',
|
|
672
|
-
403: 'Forbidden',
|
|
673
|
-
404: 'Not Found',
|
|
674
|
-
405: 'Method Not Allowed',
|
|
675
|
-
406: 'Not Acceptable',
|
|
676
|
-
407: 'Proxy Authentication Required',
|
|
677
|
-
408: 'Request Timeout',
|
|
678
|
-
409: 'Conflict',
|
|
679
|
-
410: 'Gone',
|
|
680
|
-
411: 'Length Required',
|
|
681
|
-
412: 'Precondition Failed',
|
|
682
|
-
413: 'Payload Too Large',
|
|
683
|
-
414: 'URI Too Long',
|
|
684
|
-
415: 'Unsupported Media Type',
|
|
685
|
-
416: 'Requested Range Not Satisfiable',
|
|
686
|
-
417: 'Expectation Failed',
|
|
687
|
-
418: "I'm a Teapot",
|
|
688
|
-
421: 'Misdirected Request',
|
|
689
|
-
422: 'Unprocessable Entity',
|
|
690
|
-
424: 'Failed Dependency',
|
|
691
|
-
428: 'Precondition Required',
|
|
692
|
-
429: 'Too Many Requests',
|
|
693
|
-
500: 'Internal Server Error',
|
|
694
|
-
501: 'Not Implemented',
|
|
695
|
-
502: 'Bad Gateway',
|
|
696
|
-
503: 'Service Unavailable',
|
|
697
|
-
504: 'Gateway Timeout',
|
|
698
|
-
505: 'HTTP Version Not Supported',
|
|
699
|
-
};
|
|
700
|
-
var Exceptions = /*#__PURE__*/ (function () {
|
|
701
|
-
function Exceptions() {
|
|
702
|
-
_class_call_check$2(this, Exceptions);
|
|
703
|
-
}
|
|
704
|
-
_create_class$2(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
|
-
},
|
|
715
|
-
{
|
|
716
|
-
key: 'transformPgError',
|
|
717
|
-
value: function transformPgError(error) {
|
|
718
|
-
var httpStatus;
|
|
719
|
-
var errMsg = null;
|
|
720
|
-
switch (error.getStatus()) {
|
|
721
|
-
case PostgresError.FOREIGN_KEY_VIOLATION:
|
|
722
|
-
httpStatus = common.HttpStatus.NOT_FOUND;
|
|
723
|
-
errMsg = error.getSpecificMessage(
|
|
724
|
-
PostgresError.FOREIGN_KEY_VIOLATION
|
|
725
|
-
);
|
|
726
|
-
break;
|
|
727
|
-
case PostgresError.UNIQUE_VIOLATION:
|
|
728
|
-
httpStatus = common.HttpStatus.CONFLICT;
|
|
729
|
-
errMsg = error.getSpecificMessage(PostgresError.UNIQUE_VIOLATION);
|
|
730
|
-
break;
|
|
731
|
-
case PostgresError.INVALID_TEXT_REPRESENTATION:
|
|
732
|
-
httpStatus = common.HttpStatus.BAD_REQUEST;
|
|
733
|
-
errMsg = error.getSpecificMessage(
|
|
734
|
-
PostgresError.INVALID_TEXT_REPRESENTATION
|
|
735
|
-
);
|
|
736
|
-
break;
|
|
737
|
-
default:
|
|
738
|
-
httpStatus = common.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
739
|
-
}
|
|
740
|
-
return new NativeException(
|
|
741
|
-
httpStatus,
|
|
742
|
-
errMsg !== null && errMsg !== void 0 ? errMsg : error.message
|
|
743
|
-
);
|
|
744
|
-
},
|
|
745
|
-
},
|
|
746
|
-
{
|
|
747
|
-
key: 'toHttpException',
|
|
748
|
-
value: function toHttpException(error) {
|
|
749
|
-
var _error = error;
|
|
750
|
-
if (_instanceof(_error, PgException)) {
|
|
751
|
-
_error = this.transformPgError(_error);
|
|
752
|
-
}
|
|
753
|
-
return new common.HttpException(
|
|
754
|
-
{
|
|
755
|
-
status: _error.code,
|
|
756
|
-
message: _error.message,
|
|
757
|
-
error: this.getHttpStatusText(_error.code),
|
|
758
|
-
},
|
|
759
|
-
_error.code
|
|
760
|
-
);
|
|
761
|
-
},
|
|
762
|
-
},
|
|
763
|
-
]);
|
|
764
|
-
return Exceptions;
|
|
765
|
-
})();
|
|
766
|
-
|
|
767
|
-
function _class_call_check$1(instance, Constructor) {
|
|
768
|
-
if (!(instance instanceof Constructor)) {
|
|
769
|
-
throw new TypeError('Cannot call a class as a function');
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
function _defineProperties$1(target, props) {
|
|
773
|
-
for (var i = 0; i < props.length; i++) {
|
|
774
|
-
var descriptor = props[i];
|
|
775
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
776
|
-
descriptor.configurable = true;
|
|
777
|
-
if ('value' in descriptor) descriptor.writable = true;
|
|
778
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
782
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
634
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
783
635
|
return Constructor;
|
|
784
636
|
}
|
|
785
|
-
function _define_property(obj, key, value) {
|
|
637
|
+
function _define_property$1(obj, key, value) {
|
|
786
638
|
if (key in obj) {
|
|
787
639
|
Object.defineProperty(obj, key, {
|
|
788
640
|
value: value,
|
|
@@ -810,10 +662,10 @@ var NO_OP = function (_message) {
|
|
|
810
662
|
};
|
|
811
663
|
var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
812
664
|
function ConsoleLogger(options) {
|
|
813
|
-
_class_call_check$
|
|
814
|
-
_define_property(this, 'log', void 0);
|
|
815
|
-
_define_property(this, 'warn', void 0);
|
|
816
|
-
_define_property(this, 'error', void 0);
|
|
665
|
+
_class_call_check$2(this, ConsoleLogger);
|
|
666
|
+
_define_property$1(this, 'log', void 0);
|
|
667
|
+
_define_property$1(this, 'warn', void 0);
|
|
668
|
+
_define_property$1(this, 'error', void 0);
|
|
817
669
|
var level = (options || {}).level;
|
|
818
670
|
this.error = console.error.bind(console);
|
|
819
671
|
this.warn = NO_OP;
|
|
@@ -828,7 +680,7 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
828
680
|
break;
|
|
829
681
|
}
|
|
830
682
|
}
|
|
831
|
-
_create_class$
|
|
683
|
+
_create_class$2(ConsoleLogger, [
|
|
832
684
|
{
|
|
833
685
|
key: 'disable',
|
|
834
686
|
value: function disable() {
|
|
@@ -864,12 +716,12 @@ var logger = new ConsoleLogger({
|
|
|
864
716
|
level: LOG_LEVEL,
|
|
865
717
|
});
|
|
866
718
|
|
|
867
|
-
function _class_call_check(instance, Constructor) {
|
|
719
|
+
function _class_call_check$1(instance, Constructor) {
|
|
868
720
|
if (!(instance instanceof Constructor)) {
|
|
869
721
|
throw new TypeError('Cannot call a class as a function');
|
|
870
722
|
}
|
|
871
723
|
}
|
|
872
|
-
function _defineProperties(target, props) {
|
|
724
|
+
function _defineProperties$1(target, props) {
|
|
873
725
|
for (var i = 0; i < props.length; i++) {
|
|
874
726
|
var descriptor = props[i];
|
|
875
727
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -878,15 +730,15 @@ function _defineProperties(target, props) {
|
|
|
878
730
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
879
731
|
}
|
|
880
732
|
}
|
|
881
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
882
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
733
|
+
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
734
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
883
735
|
return Constructor;
|
|
884
736
|
}
|
|
885
737
|
var HttpHandler = /*#__PURE__*/ (function () {
|
|
886
738
|
function HttpHandler() {
|
|
887
|
-
_class_call_check(this, HttpHandler);
|
|
739
|
+
_class_call_check$1(this, HttpHandler);
|
|
888
740
|
}
|
|
889
|
-
_create_class(HttpHandler, null, [
|
|
741
|
+
_create_class$1(HttpHandler, null, [
|
|
890
742
|
{
|
|
891
743
|
key: 'response',
|
|
892
744
|
value: function response(response) {
|
|
@@ -930,7 +782,60 @@ var HttpHandler = /*#__PURE__*/ (function () {
|
|
|
930
782
|
return HttpHandler;
|
|
931
783
|
})();
|
|
932
784
|
|
|
933
|
-
|
|
785
|
+
function _class_call_check(instance, Constructor) {
|
|
786
|
+
if (!(instance instanceof Constructor)) {
|
|
787
|
+
throw new TypeError('Cannot call a class as a function');
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function _defineProperties(target, props) {
|
|
791
|
+
for (var i = 0; i < props.length; i++) {
|
|
792
|
+
var descriptor = props[i];
|
|
793
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
794
|
+
descriptor.configurable = true;
|
|
795
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
796
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
800
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
801
|
+
return Constructor;
|
|
802
|
+
}
|
|
803
|
+
function _define_property(obj, key, value) {
|
|
804
|
+
if (key in obj) {
|
|
805
|
+
Object.defineProperty(obj, key, {
|
|
806
|
+
value: value,
|
|
807
|
+
enumerable: true,
|
|
808
|
+
configurable: true,
|
|
809
|
+
writable: true,
|
|
810
|
+
});
|
|
811
|
+
} else {
|
|
812
|
+
obj[key] = value;
|
|
813
|
+
}
|
|
814
|
+
return obj;
|
|
815
|
+
}
|
|
816
|
+
var CookieHelper = /*#__PURE__*/ (function () {
|
|
817
|
+
function CookieHelper() {
|
|
818
|
+
_class_call_check(this, CookieHelper);
|
|
819
|
+
}
|
|
820
|
+
_create_class(CookieHelper, null, [
|
|
821
|
+
{
|
|
822
|
+
key: 'isProduction',
|
|
823
|
+
value: function isProduction() {
|
|
824
|
+
return process.env.NODE_ENV === 'production';
|
|
825
|
+
},
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
key: 'getCookieName',
|
|
829
|
+
value: function getCookieName(name) {
|
|
830
|
+
return this.isProduction() ? this.cookieSecurePrefix + name : name;
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
]);
|
|
834
|
+
return CookieHelper;
|
|
835
|
+
})();
|
|
836
|
+
_define_property(CookieHelper, 'cookieSecurePrefix', '__Secure-');
|
|
837
|
+
|
|
838
|
+
exports.CookieHelper = CookieHelper;
|
|
934
839
|
exports.HttpHandler = HttpHandler;
|
|
935
840
|
exports.NativeException = NativeException;
|
|
936
841
|
exports.PgException = PgException;
|
package/dist/index.d.ts
CHANGED
|
@@ -542,7 +542,59 @@ declare module "@native-systems/utility" {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
declare module "@native-systems/utility" {
|
|
545
|
-
|
|
545
|
+
export enum HttpStatus {
|
|
546
|
+
CONTINUE = 100,
|
|
547
|
+
SWITCHING_PROTOCOLS = 101,
|
|
548
|
+
PROCESSING = 102,
|
|
549
|
+
EARLYHINTS = 103,
|
|
550
|
+
OK = 200,
|
|
551
|
+
CREATED = 201,
|
|
552
|
+
ACCEPTED = 202,
|
|
553
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
554
|
+
NO_CONTENT = 204,
|
|
555
|
+
RESET_CONTENT = 205,
|
|
556
|
+
PARTIAL_CONTENT = 206,
|
|
557
|
+
AMBIGUOUS = 300,
|
|
558
|
+
MOVED_PERMANENTLY = 301,
|
|
559
|
+
FOUND = 302,
|
|
560
|
+
SEE_OTHER = 303,
|
|
561
|
+
NOT_MODIFIED = 304,
|
|
562
|
+
TEMPORARY_REDIRECT = 307,
|
|
563
|
+
PERMANENT_REDIRECT = 308,
|
|
564
|
+
BAD_REQUEST = 400,
|
|
565
|
+
UNAUTHORIZED = 401,
|
|
566
|
+
PAYMENT_REQUIRED = 402,
|
|
567
|
+
FORBIDDEN = 403,
|
|
568
|
+
NOT_FOUND = 404,
|
|
569
|
+
METHOD_NOT_ALLOWED = 405,
|
|
570
|
+
NOT_ACCEPTABLE = 406,
|
|
571
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
572
|
+
REQUEST_TIMEOUT = 408,
|
|
573
|
+
CONFLICT = 409,
|
|
574
|
+
GONE = 410,
|
|
575
|
+
LENGTH_REQUIRED = 411,
|
|
576
|
+
PRECONDITION_FAILED = 412,
|
|
577
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
578
|
+
URI_TOO_LONG = 414,
|
|
579
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
580
|
+
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
581
|
+
EXPECTATION_FAILED = 417,
|
|
582
|
+
I_AM_A_TEAPOT = 418,
|
|
583
|
+
MISDIRECTED = 421,
|
|
584
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
585
|
+
FAILED_DEPENDENCY = 424,
|
|
586
|
+
PRECONDITION_REQUIRED = 428,
|
|
587
|
+
TOO_MANY_REQUESTS = 429,
|
|
588
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
589
|
+
NOT_IMPLEMENTED = 501,
|
|
590
|
+
BAD_GATEWAY = 502,
|
|
591
|
+
SERVICE_UNAVAILABLE = 503,
|
|
592
|
+
GATEWAY_TIMEOUT = 504,
|
|
593
|
+
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
declare module "@native-systems/utility" {
|
|
546
598
|
/**
|
|
547
599
|
* Custom exception object used by Native Systems, which extends the Error interface
|
|
548
600
|
* and adds the 'code' attribute, to be able to provide an additional httpStatus.
|
|
@@ -588,26 +640,6 @@ declare module "@native-systems/utility" {
|
|
|
588
640
|
export { PgException };
|
|
589
641
|
}
|
|
590
642
|
|
|
591
|
-
declare module "@native-systems/utility" {
|
|
592
|
-
import { HttpException } from "@nestjs/common";
|
|
593
|
-
class Exceptions {
|
|
594
|
-
private static getHttpStatusText;
|
|
595
|
-
/**
|
|
596
|
-
* Evaluates a thrown postgres error object, which is then sanitized into an appropriate NativeError object.
|
|
597
|
-
* @param error a postgres error that, for example is from a rejected promise.
|
|
598
|
-
* @returns {NativeException} a NativeError object with either a concrete reason or a generic error message.
|
|
599
|
-
*/
|
|
600
|
-
private static transformPgError;
|
|
601
|
-
/**
|
|
602
|
-
* Transforms an exception instance into a HttpException instance and returns it.
|
|
603
|
-
* @param error {PgException | NativeException} An error object of one of those instances.
|
|
604
|
-
* @returns {HttpException} The transformed exception, modeled into a HttpException instance.
|
|
605
|
-
*/
|
|
606
|
-
static toHttpException(error: PgException | NativeException): HttpException;
|
|
607
|
-
}
|
|
608
|
-
export { Exceptions };
|
|
609
|
-
}
|
|
610
|
-
|
|
611
643
|
declare module "@native-systems/utility" {
|
|
612
644
|
type LogLevel = 'log' | 'warn' | 'error';
|
|
613
645
|
interface LogFn {
|
|
@@ -670,3 +702,23 @@ declare module "@native-systems/utility" {
|
|
|
670
702
|
}
|
|
671
703
|
export { HttpHandler };
|
|
672
704
|
}
|
|
705
|
+
|
|
706
|
+
declare module "@native-systems/utility" {
|
|
707
|
+
/**
|
|
708
|
+
* Class with functions to determine if cookies should have the __Secure prefix applied or not.
|
|
709
|
+
* This is determined based on if the project is running in production or not, as __Secure cookies doesn't work in
|
|
710
|
+
* a dev environment.
|
|
711
|
+
*/
|
|
712
|
+
class CookieHelper {
|
|
713
|
+
private static readonly cookieSecurePrefix;
|
|
714
|
+
private static isProduction;
|
|
715
|
+
/**
|
|
716
|
+
* Returns the cookie name with either the secure prefix or as it was provided, based on the mode the project runs in.
|
|
717
|
+
* If the project is in production, return with __Secure- prefix otherwise return as it is.
|
|
718
|
+
* @param name {string} The base name of the cookie without any additional prefix.
|
|
719
|
+
* @returns {string} The potentially altered cookie name.
|
|
720
|
+
*/
|
|
721
|
+
static getCookieName(name: string): string;
|
|
722
|
+
}
|
|
723
|
+
export { CookieHelper };
|
|
724
|
+
}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { HttpStatus, HttpException } from '@nestjs/common';
|
|
2
|
-
|
|
3
1
|
var PostgresError = /*#__PURE__*/ (function (PostgresError) {
|
|
4
2
|
PostgresError['SUCCESSFUL_COMPLETION'] = '00000';
|
|
5
3
|
PostgresError['WARNING'] = '01000';
|
|
@@ -316,7 +314,7 @@ function _construct$1(Parent, args, Class) {
|
|
|
316
314
|
}
|
|
317
315
|
return _construct$1.apply(null, arguments);
|
|
318
316
|
}
|
|
319
|
-
function _define_property$
|
|
317
|
+
function _define_property$3(obj, key, value) {
|
|
320
318
|
if (key in obj) {
|
|
321
319
|
Object.defineProperty(obj, key, {
|
|
322
320
|
value: value,
|
|
@@ -420,7 +418,7 @@ var NativeException = /*#__PURE__*/ (function (Error1) {
|
|
|
420
418
|
_class_call_check$4(this, NativeException);
|
|
421
419
|
var _this;
|
|
422
420
|
(_this = _call_super$1(this, NativeException, [message])),
|
|
423
|
-
_define_property$
|
|
421
|
+
_define_property$3(_this, 'code', void 0);
|
|
424
422
|
_this.name = 'NativeError';
|
|
425
423
|
_this.code = code;
|
|
426
424
|
return _this;
|
|
@@ -482,7 +480,7 @@ function _create_class$3(Constructor, protoProps, staticProps) {
|
|
|
482
480
|
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
483
481
|
return Constructor;
|
|
484
482
|
}
|
|
485
|
-
function _define_property$
|
|
483
|
+
function _define_property$2(obj, key, value) {
|
|
486
484
|
if (key in obj) {
|
|
487
485
|
Object.defineProperty(obj, key, {
|
|
488
486
|
value: value,
|
|
@@ -582,8 +580,8 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
582
580
|
_class_call_check$3(this, PgException);
|
|
583
581
|
var _this;
|
|
584
582
|
(_this = _call_super(this, PgException, [message])),
|
|
585
|
-
_define_property$
|
|
586
|
-
_define_property$
|
|
583
|
+
_define_property$2(_this, 'err', void 0),
|
|
584
|
+
_define_property$2(_this, 'specific', void 0);
|
|
587
585
|
_this.name = 'PgError';
|
|
588
586
|
_this.err = err;
|
|
589
587
|
_this.specific = specific;
|
|
@@ -631,156 +629,10 @@ function _defineProperties$2(target, props) {
|
|
|
631
629
|
}
|
|
632
630
|
}
|
|
633
631
|
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
634
|
-
if (
|
|
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
|
-
}
|
|
648
|
-
var statusMap = {
|
|
649
|
-
100: 'Continue',
|
|
650
|
-
101: 'Switching Protocols',
|
|
651
|
-
102: 'Processing',
|
|
652
|
-
103: 'Early Hints',
|
|
653
|
-
200: 'OK',
|
|
654
|
-
201: 'Created',
|
|
655
|
-
202: 'Accepted',
|
|
656
|
-
203: 'Non-Authoritative Information',
|
|
657
|
-
204: 'No Content',
|
|
658
|
-
205: 'Reset Content',
|
|
659
|
-
206: 'Partial Content',
|
|
660
|
-
300: 'Multiple Choices',
|
|
661
|
-
301: 'Moved Permanently',
|
|
662
|
-
302: 'Found',
|
|
663
|
-
303: 'See Other',
|
|
664
|
-
304: 'Not Modified',
|
|
665
|
-
307: 'Temporary Redirect',
|
|
666
|
-
308: 'Permanent Redirect',
|
|
667
|
-
400: 'Bad Request',
|
|
668
|
-
401: 'Unauthorized',
|
|
669
|
-
402: 'Payment Required',
|
|
670
|
-
403: 'Forbidden',
|
|
671
|
-
404: 'Not Found',
|
|
672
|
-
405: 'Method Not Allowed',
|
|
673
|
-
406: 'Not Acceptable',
|
|
674
|
-
407: 'Proxy Authentication Required',
|
|
675
|
-
408: 'Request Timeout',
|
|
676
|
-
409: 'Conflict',
|
|
677
|
-
410: 'Gone',
|
|
678
|
-
411: 'Length Required',
|
|
679
|
-
412: 'Precondition Failed',
|
|
680
|
-
413: 'Payload Too Large',
|
|
681
|
-
414: 'URI Too Long',
|
|
682
|
-
415: 'Unsupported Media Type',
|
|
683
|
-
416: 'Requested Range Not Satisfiable',
|
|
684
|
-
417: 'Expectation Failed',
|
|
685
|
-
418: "I'm a Teapot",
|
|
686
|
-
421: 'Misdirected Request',
|
|
687
|
-
422: 'Unprocessable Entity',
|
|
688
|
-
424: 'Failed Dependency',
|
|
689
|
-
428: 'Precondition Required',
|
|
690
|
-
429: 'Too Many Requests',
|
|
691
|
-
500: 'Internal Server Error',
|
|
692
|
-
501: 'Not Implemented',
|
|
693
|
-
502: 'Bad Gateway',
|
|
694
|
-
503: 'Service Unavailable',
|
|
695
|
-
504: 'Gateway Timeout',
|
|
696
|
-
505: 'HTTP Version Not Supported',
|
|
697
|
-
};
|
|
698
|
-
var Exceptions = /*#__PURE__*/ (function () {
|
|
699
|
-
function Exceptions() {
|
|
700
|
-
_class_call_check$2(this, Exceptions);
|
|
701
|
-
}
|
|
702
|
-
_create_class$2(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
|
-
},
|
|
713
|
-
{
|
|
714
|
-
key: 'transformPgError',
|
|
715
|
-
value: function transformPgError(error) {
|
|
716
|
-
var httpStatus;
|
|
717
|
-
var errMsg = null;
|
|
718
|
-
switch (error.getStatus()) {
|
|
719
|
-
case PostgresError.FOREIGN_KEY_VIOLATION:
|
|
720
|
-
httpStatus = HttpStatus.NOT_FOUND;
|
|
721
|
-
errMsg = error.getSpecificMessage(
|
|
722
|
-
PostgresError.FOREIGN_KEY_VIOLATION
|
|
723
|
-
);
|
|
724
|
-
break;
|
|
725
|
-
case PostgresError.UNIQUE_VIOLATION:
|
|
726
|
-
httpStatus = HttpStatus.CONFLICT;
|
|
727
|
-
errMsg = error.getSpecificMessage(PostgresError.UNIQUE_VIOLATION);
|
|
728
|
-
break;
|
|
729
|
-
case PostgresError.INVALID_TEXT_REPRESENTATION:
|
|
730
|
-
httpStatus = HttpStatus.BAD_REQUEST;
|
|
731
|
-
errMsg = error.getSpecificMessage(
|
|
732
|
-
PostgresError.INVALID_TEXT_REPRESENTATION
|
|
733
|
-
);
|
|
734
|
-
break;
|
|
735
|
-
default:
|
|
736
|
-
httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
737
|
-
}
|
|
738
|
-
return new NativeException(
|
|
739
|
-
httpStatus,
|
|
740
|
-
errMsg !== null && errMsg !== void 0 ? errMsg : error.message
|
|
741
|
-
);
|
|
742
|
-
},
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
key: 'toHttpException',
|
|
746
|
-
value: function toHttpException(error) {
|
|
747
|
-
var _error = error;
|
|
748
|
-
if (_instanceof(_error, PgException)) {
|
|
749
|
-
_error = this.transformPgError(_error);
|
|
750
|
-
}
|
|
751
|
-
return new HttpException(
|
|
752
|
-
{
|
|
753
|
-
status: _error.code,
|
|
754
|
-
message: _error.message,
|
|
755
|
-
error: this.getHttpStatusText(_error.code),
|
|
756
|
-
},
|
|
757
|
-
_error.code
|
|
758
|
-
);
|
|
759
|
-
},
|
|
760
|
-
},
|
|
761
|
-
]);
|
|
762
|
-
return Exceptions;
|
|
763
|
-
})();
|
|
764
|
-
|
|
765
|
-
function _class_call_check$1(instance, Constructor) {
|
|
766
|
-
if (!(instance instanceof Constructor)) {
|
|
767
|
-
throw new TypeError('Cannot call a class as a function');
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
function _defineProperties$1(target, props) {
|
|
771
|
-
for (var i = 0; i < props.length; i++) {
|
|
772
|
-
var descriptor = props[i];
|
|
773
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
774
|
-
descriptor.configurable = true;
|
|
775
|
-
if ('value' in descriptor) descriptor.writable = true;
|
|
776
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
780
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
632
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
781
633
|
return Constructor;
|
|
782
634
|
}
|
|
783
|
-
function _define_property(obj, key, value) {
|
|
635
|
+
function _define_property$1(obj, key, value) {
|
|
784
636
|
if (key in obj) {
|
|
785
637
|
Object.defineProperty(obj, key, {
|
|
786
638
|
value: value,
|
|
@@ -808,10 +660,10 @@ var NO_OP = function (_message) {
|
|
|
808
660
|
};
|
|
809
661
|
var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
810
662
|
function ConsoleLogger(options) {
|
|
811
|
-
_class_call_check$
|
|
812
|
-
_define_property(this, 'log', void 0);
|
|
813
|
-
_define_property(this, 'warn', void 0);
|
|
814
|
-
_define_property(this, 'error', void 0);
|
|
663
|
+
_class_call_check$2(this, ConsoleLogger);
|
|
664
|
+
_define_property$1(this, 'log', void 0);
|
|
665
|
+
_define_property$1(this, 'warn', void 0);
|
|
666
|
+
_define_property$1(this, 'error', void 0);
|
|
815
667
|
var level = (options || {}).level;
|
|
816
668
|
this.error = console.error.bind(console);
|
|
817
669
|
this.warn = NO_OP;
|
|
@@ -826,7 +678,7 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
826
678
|
break;
|
|
827
679
|
}
|
|
828
680
|
}
|
|
829
|
-
_create_class$
|
|
681
|
+
_create_class$2(ConsoleLogger, [
|
|
830
682
|
{
|
|
831
683
|
key: 'disable',
|
|
832
684
|
value: function disable() {
|
|
@@ -862,12 +714,12 @@ var logger = new ConsoleLogger({
|
|
|
862
714
|
level: LOG_LEVEL,
|
|
863
715
|
});
|
|
864
716
|
|
|
865
|
-
function _class_call_check(instance, Constructor) {
|
|
717
|
+
function _class_call_check$1(instance, Constructor) {
|
|
866
718
|
if (!(instance instanceof Constructor)) {
|
|
867
719
|
throw new TypeError('Cannot call a class as a function');
|
|
868
720
|
}
|
|
869
721
|
}
|
|
870
|
-
function _defineProperties(target, props) {
|
|
722
|
+
function _defineProperties$1(target, props) {
|
|
871
723
|
for (var i = 0; i < props.length; i++) {
|
|
872
724
|
var descriptor = props[i];
|
|
873
725
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -876,15 +728,15 @@ function _defineProperties(target, props) {
|
|
|
876
728
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
877
729
|
}
|
|
878
730
|
}
|
|
879
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
880
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
731
|
+
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
732
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
881
733
|
return Constructor;
|
|
882
734
|
}
|
|
883
735
|
var HttpHandler = /*#__PURE__*/ (function () {
|
|
884
736
|
function HttpHandler() {
|
|
885
|
-
_class_call_check(this, HttpHandler);
|
|
737
|
+
_class_call_check$1(this, HttpHandler);
|
|
886
738
|
}
|
|
887
|
-
_create_class(HttpHandler, null, [
|
|
739
|
+
_create_class$1(HttpHandler, null, [
|
|
888
740
|
{
|
|
889
741
|
key: 'response',
|
|
890
742
|
value: function response(response) {
|
|
@@ -928,8 +780,61 @@ var HttpHandler = /*#__PURE__*/ (function () {
|
|
|
928
780
|
return HttpHandler;
|
|
929
781
|
})();
|
|
930
782
|
|
|
783
|
+
function _class_call_check(instance, Constructor) {
|
|
784
|
+
if (!(instance instanceof Constructor)) {
|
|
785
|
+
throw new TypeError('Cannot call a class as a function');
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function _defineProperties(target, props) {
|
|
789
|
+
for (var i = 0; i < props.length; i++) {
|
|
790
|
+
var descriptor = props[i];
|
|
791
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
792
|
+
descriptor.configurable = true;
|
|
793
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
794
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
798
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
799
|
+
return Constructor;
|
|
800
|
+
}
|
|
801
|
+
function _define_property(obj, key, value) {
|
|
802
|
+
if (key in obj) {
|
|
803
|
+
Object.defineProperty(obj, key, {
|
|
804
|
+
value: value,
|
|
805
|
+
enumerable: true,
|
|
806
|
+
configurable: true,
|
|
807
|
+
writable: true,
|
|
808
|
+
});
|
|
809
|
+
} else {
|
|
810
|
+
obj[key] = value;
|
|
811
|
+
}
|
|
812
|
+
return obj;
|
|
813
|
+
}
|
|
814
|
+
var CookieHelper = /*#__PURE__*/ (function () {
|
|
815
|
+
function CookieHelper() {
|
|
816
|
+
_class_call_check(this, CookieHelper);
|
|
817
|
+
}
|
|
818
|
+
_create_class(CookieHelper, null, [
|
|
819
|
+
{
|
|
820
|
+
key: 'isProduction',
|
|
821
|
+
value: function isProduction() {
|
|
822
|
+
return process.env.NODE_ENV === 'production';
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
key: 'getCookieName',
|
|
827
|
+
value: function getCookieName(name) {
|
|
828
|
+
return this.isProduction() ? this.cookieSecurePrefix + name : name;
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
]);
|
|
832
|
+
return CookieHelper;
|
|
833
|
+
})();
|
|
834
|
+
_define_property(CookieHelper, 'cookieSecurePrefix', '__Secure-');
|
|
835
|
+
|
|
931
836
|
export {
|
|
932
|
-
|
|
837
|
+
CookieHelper,
|
|
933
838
|
HttpHandler,
|
|
934
839
|
NativeException,
|
|
935
840
|
PgException,
|