@tiboli/types 0.0.11 → 0.0.12
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/cjs/classes/errors.class.js +50 -0
- package/dist/cjs/classes/index.js +9 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/types/utility.type.js +2 -0
- package/dist/esm/classes/errors.class.js +43 -0
- package/dist/esm/classes/errors.class.js.map +1 -0
- package/dist/esm/classes/index.js +2 -0
- package/dist/esm/classes/index.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utility.type.js +2 -0
- package/dist/esm/types/utility.type.js.map +1 -0
- package/dist/types/classes/errors.class.d.ts +26 -0
- package/dist/types/classes/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/utility.type.d.ts +9 -0
- package/package.json +2 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalServerError = exports.MalformedRequestError = exports.NotFoundError = exports.HttpError = exports.BaseError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Defines the Base Error class for handling Errors.
|
|
6
|
+
* @param {string} message Error message. Should be representing to the error
|
|
7
|
+
* @param {ErrorParameters} options Parameters for the Error, like cause and context.
|
|
8
|
+
* @returns {undefined}
|
|
9
|
+
*/
|
|
10
|
+
class BaseError extends Error {
|
|
11
|
+
context;
|
|
12
|
+
constructor(message, options = {}) {
|
|
13
|
+
const { cause, context } = options;
|
|
14
|
+
super(message, { cause });
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
this.context = context;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BaseError = BaseError;
|
|
20
|
+
class HttpError extends BaseError {
|
|
21
|
+
statusCode;
|
|
22
|
+
descriptorString;
|
|
23
|
+
constructor(message, status, descriptor, options = {}) {
|
|
24
|
+
super(message, options);
|
|
25
|
+
this.statusCode = status;
|
|
26
|
+
this.descriptorString = descriptor;
|
|
27
|
+
}
|
|
28
|
+
toResponse() {
|
|
29
|
+
return this.descriptorString;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.HttpError = HttpError;
|
|
33
|
+
class NotFoundError extends HttpError {
|
|
34
|
+
constructor(message, options = {}) {
|
|
35
|
+
super(message, 404, 'Entity not found', options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.NotFoundError = NotFoundError;
|
|
39
|
+
class MalformedRequestError extends HttpError {
|
|
40
|
+
constructor(message, options = {}) {
|
|
41
|
+
super(message, 400, 'Malformed Request', options);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.MalformedRequestError = MalformedRequestError;
|
|
45
|
+
class InternalServerError extends HttpError {
|
|
46
|
+
constructor(message, options = {}) {
|
|
47
|
+
super(message, 500, 'Internal Server Error', options);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.InternalServerError = InternalServerError;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalServerError = exports.MalformedRequestError = exports.NotFoundError = exports.HttpError = exports.BaseError = void 0;
|
|
4
|
+
var errors_class_js_1 = require("./errors.class.js");
|
|
5
|
+
Object.defineProperty(exports, "BaseError", { enumerable: true, get: function () { return errors_class_js_1.BaseError; } });
|
|
6
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_class_js_1.HttpError; } });
|
|
7
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_class_js_1.NotFoundError; } });
|
|
8
|
+
Object.defineProperty(exports, "MalformedRequestError", { enumerable: true, get: function () { return errors_class_js_1.MalformedRequestError; } });
|
|
9
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return errors_class_js_1.InternalServerError; } });
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./schemas"), exports);
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./classes"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the Base Error class for handling Errors.
|
|
3
|
+
* @param {string} message Error message. Should be representing to the error
|
|
4
|
+
* @param {ErrorParameters} options Parameters for the Error, like cause and context.
|
|
5
|
+
* @returns {undefined}
|
|
6
|
+
*/
|
|
7
|
+
export class BaseError extends Error {
|
|
8
|
+
context;
|
|
9
|
+
constructor(message, options = {}) {
|
|
10
|
+
const { cause, context } = options;
|
|
11
|
+
super(message, { cause });
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
this.context = context;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class HttpError extends BaseError {
|
|
17
|
+
statusCode;
|
|
18
|
+
descriptorString;
|
|
19
|
+
constructor(message, status, descriptor, options = {}) {
|
|
20
|
+
super(message, options);
|
|
21
|
+
this.statusCode = status;
|
|
22
|
+
this.descriptorString = descriptor;
|
|
23
|
+
}
|
|
24
|
+
toResponse() {
|
|
25
|
+
return this.descriptorString;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class NotFoundError extends HttpError {
|
|
29
|
+
constructor(message, options = {}) {
|
|
30
|
+
super(message, 404, 'Entity not found', options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class MalformedRequestError extends HttpError {
|
|
34
|
+
constructor(message, options = {}) {
|
|
35
|
+
super(message, 400, 'Malformed Request', options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class InternalServerError extends HttpError {
|
|
39
|
+
constructor(message, options = {}) {
|
|
40
|
+
super(message, 500, 'Internal Server Error', options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=errors.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.class.js","sourceRoot":"","sources":["../../../src/classes/errors.class.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnB,OAAO,CAAY;IAEnC,YAAY,OAAe,EAAE,UAA2B,EAAE;QACzD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAEnC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAElC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAED,MAAM,OAAO,SAAU,SAAQ,SAAS;IACvB,UAAU,CAAS;IACnB,gBAAgB,CAAS;IAEzC,YACC,OAAe,EACf,MAAc,EACd,UAAkB,EAClB,UAA2B,EAAE;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;IACpC,CAAC;IACM,UAAU;QAChB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;CACD;AACD,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC3C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACzD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACD;AACD,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IACnD,YAAY,OAAe,EAAE,UAA2B,EAAE;QACzD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IACjD,YAAY,OAAe,EAAE,UAA2B,EAAE;QACzD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.type.js","sourceRoot":"","sources":["../../../src/types/utility.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ErrorParameters, Jsonable } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the Base Error class for handling Errors.
|
|
4
|
+
* @param {string} message Error message. Should be representing to the error
|
|
5
|
+
* @param {ErrorParameters} options Parameters for the Error, like cause and context.
|
|
6
|
+
* @returns {undefined}
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseError extends Error {
|
|
9
|
+
readonly context?: Jsonable;
|
|
10
|
+
constructor(message: string, options?: ErrorParameters);
|
|
11
|
+
}
|
|
12
|
+
export declare class HttpError extends BaseError {
|
|
13
|
+
readonly statusCode: number;
|
|
14
|
+
readonly descriptorString: string;
|
|
15
|
+
constructor(message: string, status: number, descriptor: string, options?: ErrorParameters);
|
|
16
|
+
toResponse(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class NotFoundError extends HttpError {
|
|
19
|
+
constructor(message: string, options?: ErrorParameters);
|
|
20
|
+
}
|
|
21
|
+
export declare class MalformedRequestError extends HttpError {
|
|
22
|
+
constructor(message: string, options?: ErrorParameters);
|
|
23
|
+
}
|
|
24
|
+
export declare class InternalServerError extends HttpError {
|
|
25
|
+
constructor(message: string, options?: ErrorParameters);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseError, HttpError, NotFoundError, MalformedRequestError, InternalServerError, } from './errors.class.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { CopyAttributes, CopyCreationAttributes, CopyUpdateAttributes } from './
|
|
|
3
3
|
export { CustomerAttributes, CustomerCreationAttributes, CustomerUpdateAttributes, } from './customer.type';
|
|
4
4
|
export { GroupAttributes, GroupCreationAttributes, GroupUpdateAttributes } from './group.types';
|
|
5
5
|
export { LoanAttributes, LoanCreationAttributes, LoanUpdateAttributes } from './loan.type';
|
|
6
|
+
export { Jsonable, ErrorParameters } from './utility.type.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiboli/types",
|
|
3
3
|
"scope": "@tiboli",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.12",
|
|
5
5
|
"description": "Typedefinitions for Tiboli",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiboli",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dev": "tsx watch -r tsconfig-paths/register src",
|
|
46
46
|
"prepare": "husky",
|
|
47
47
|
"lint": "eslint --max-warnings=0 .",
|
|
48
|
+
"lint:fix": "eslint --max-warnings=0 --fix .",
|
|
48
49
|
"lint:staged": "lint-staged",
|
|
49
50
|
"test": "jest --passWithNoTests"
|
|
50
51
|
},
|