@orion-js/helpers 3.0.0-alpha.9 → 3.0.36
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/LICENSE +1 -1
- package/jest.config.js +6 -2
- package/lib/Errors/OrionError.d.ts +13 -0
- package/lib/Errors/OrionError.js +10 -0
- package/lib/Errors/PermissionsError.d.ts +4 -0
- package/lib/Errors/PermissionsError.js +24 -0
- package/lib/Errors/UserError.d.ts +4 -0
- package/lib/Errors/UserError.js +25 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +9 -1
- package/package.json +8 -5
package/LICENSE
CHANGED
package/jest.config.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface OrionErrorInformation {
|
|
2
|
+
error: string;
|
|
3
|
+
message: string;
|
|
4
|
+
extra: any;
|
|
5
|
+
}
|
|
6
|
+
export declare class OrionError extends Error {
|
|
7
|
+
isOrionError: boolean;
|
|
8
|
+
isUserError: boolean;
|
|
9
|
+
isPermissionsError: boolean;
|
|
10
|
+
code: string;
|
|
11
|
+
extra: any;
|
|
12
|
+
getInfo: () => OrionErrorInformation;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const OrionError_1 = require("./OrionError");
|
|
4
|
+
class PermissionsError extends OrionError_1.OrionError {
|
|
5
|
+
constructor(permissionErrorType, extra = {}) {
|
|
6
|
+
// Calling parent constructor of base Error class.
|
|
7
|
+
const message = extra.message || `Client is not allowed to perform this action [${permissionErrorType}]`;
|
|
8
|
+
super(message);
|
|
9
|
+
Error.captureStackTrace(this, this.constructor);
|
|
10
|
+
this.isOrionError = true;
|
|
11
|
+
this.isPermissionsError = true;
|
|
12
|
+
this.code = 'PermissionsError';
|
|
13
|
+
this.extra = extra;
|
|
14
|
+
this.getInfo = () => {
|
|
15
|
+
return {
|
|
16
|
+
...extra,
|
|
17
|
+
error: 'PermissionsError',
|
|
18
|
+
message,
|
|
19
|
+
type: permissionErrorType
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = PermissionsError;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const OrionError_1 = require("./OrionError");
|
|
4
|
+
class UserError extends OrionError_1.OrionError {
|
|
5
|
+
constructor(code, message, extra) {
|
|
6
|
+
if (!message && code) {
|
|
7
|
+
message = code;
|
|
8
|
+
code = 'error';
|
|
9
|
+
}
|
|
10
|
+
super(message);
|
|
11
|
+
Error.captureStackTrace(this, this.constructor);
|
|
12
|
+
this.isOrionError = true;
|
|
13
|
+
this.isUserError = true;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.extra = extra;
|
|
16
|
+
this.getInfo = () => {
|
|
17
|
+
return {
|
|
18
|
+
error: code,
|
|
19
|
+
message,
|
|
20
|
+
extra
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = UserError;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ import sleep from './sleep';
|
|
|
2
2
|
import hashObject from './hashObject';
|
|
3
3
|
import generateId from './generateId';
|
|
4
4
|
import createMap from './createMap';
|
|
5
|
-
|
|
5
|
+
import { OrionError, OrionErrorInformation } from './Errors/OrionError';
|
|
6
|
+
import PermissionsError from './Errors/PermissionsError';
|
|
7
|
+
import UserError from './Errors/UserError';
|
|
8
|
+
import createMapArray from './createMapArray';
|
|
9
|
+
export { createMap, createMapArray, generateId, hashObject, sleep, OrionError, PermissionsError, UserError, OrionErrorInformation };
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sleep = exports.hashObject = exports.generateId = exports.createMap = void 0;
|
|
6
|
+
exports.UserError = exports.PermissionsError = exports.OrionError = exports.sleep = exports.hashObject = exports.generateId = exports.createMapArray = exports.createMap = void 0;
|
|
7
7
|
const sleep_1 = __importDefault(require("./sleep"));
|
|
8
8
|
exports.sleep = sleep_1.default;
|
|
9
9
|
const hashObject_1 = __importDefault(require("./hashObject"));
|
|
@@ -12,3 +12,11 @@ const generateId_1 = __importDefault(require("./generateId"));
|
|
|
12
12
|
exports.generateId = generateId_1.default;
|
|
13
13
|
const createMap_1 = __importDefault(require("./createMap"));
|
|
14
14
|
exports.createMap = createMap_1.default;
|
|
15
|
+
const OrionError_1 = require("./Errors/OrionError");
|
|
16
|
+
Object.defineProperty(exports, "OrionError", { enumerable: true, get: function () { return OrionError_1.OrionError; } });
|
|
17
|
+
const PermissionsError_1 = __importDefault(require("./Errors/PermissionsError"));
|
|
18
|
+
exports.PermissionsError = PermissionsError_1.default;
|
|
19
|
+
const UserError_1 = __importDefault(require("./Errors/UserError"));
|
|
20
|
+
exports.UserError = UserError_1.default;
|
|
21
|
+
const createMapArray_1 = __importDefault(require("./createMapArray"));
|
|
22
|
+
exports.createMapArray = createMapArray_1.default;
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/helpers",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.36",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "exit 0",
|
|
9
9
|
"prepare": "yarn run build",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"clean": "rm -rf ./lib",
|
|
11
|
+
"build": "yarn run clean && tsc",
|
|
12
|
+
"watch": "tsc -w",
|
|
13
|
+
"upgrade-interactive": "yarn upgrade-interactive"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
14
|
-
"object-hash": "^2.
|
|
16
|
+
"object-hash": "^2.2.0"
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
19
|
+
"@shelf/jest-mongodb": "^2.1.0",
|
|
17
20
|
"@types/jest": "^27.0.2",
|
|
18
21
|
"typescript": "^4.4.4"
|
|
19
22
|
},
|
|
20
23
|
"publishConfig": {
|
|
21
24
|
"access": "public"
|
|
22
25
|
},
|
|
23
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7c921dbbf0ec679df743b9278abbf15cfcbac6ce"
|
|
24
27
|
}
|