@twilio/flex-plugins-utils-exception 5.0.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2018, Twilio, Inc. <help@twilio.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ ![npm](https://img.shields.io/npm/v/flex-plugins-utils-exception.svg?style=square)
2
+ ![npm](https://img.shields.io/npm/dt/flex-plugins-utils-exception.svg?style=square)
3
+ [![NpmLicense](https://img.shields.io/npm/l/flex-plugins-utils-exception.svg?style=square)](../../LICENSE)
4
+
5
+ # Flex Plugin Utils Exception
6
+
7
+ Exception error classes
@@ -0,0 +1,4 @@
1
+ export { default as TwilioError } from './lib/TwilioError';
2
+ export { default as TwilioApiError } from './lib/TwilioApiError';
3
+ export { default as NotImplementedError } from './lib/NotImplementedError';
4
+ export { default as TwilioCliError } from './lib/TwilioCliError';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /* eslint-disable import/no-unused-modules */
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TwilioCliError = exports.NotImplementedError = exports.TwilioApiError = exports.TwilioError = void 0;
8
+ var TwilioError_1 = require("./lib/TwilioError");
9
+ Object.defineProperty(exports, "TwilioError", { enumerable: true, get: function () { return __importDefault(TwilioError_1).default; } });
10
+ var TwilioApiError_1 = require("./lib/TwilioApiError");
11
+ Object.defineProperty(exports, "TwilioApiError", { enumerable: true, get: function () { return __importDefault(TwilioApiError_1).default; } });
12
+ var NotImplementedError_1 = require("./lib/NotImplementedError");
13
+ Object.defineProperty(exports, "NotImplementedError", { enumerable: true, get: function () { return __importDefault(NotImplementedError_1).default; } });
14
+ var TwilioCliError_1 = require("./lib/TwilioCliError");
15
+ Object.defineProperty(exports, "TwilioCliError", { enumerable: true, get: function () { return __importDefault(TwilioCliError_1).default; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA6C;;;;;;AAE7C,iDAA2D;AAAlD,2HAAA,OAAO,OAAe;AAC/B,uDAAiE;AAAxD,iIAAA,OAAO,OAAkB;AAClC,iEAA2E;AAAlE,2IAAA,OAAO,OAAuB;AACvC,uDAAiE;AAAxD,iIAAA,OAAO,OAAkB"}
@@ -0,0 +1,4 @@
1
+ import TwilioCliError from './TwilioCliError';
2
+ export default class NotImplementedError extends TwilioCliError {
3
+ constructor();
4
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var TwilioCliError_1 = __importDefault(require("./TwilioCliError"));
22
+ var NotImplementedError = /** @class */ (function (_super) {
23
+ __extends(NotImplementedError, _super);
24
+ function NotImplementedError() {
25
+ var _this = _super.call(this, 'Abstract method must be implemented') || this;
26
+ Object.setPrototypeOf(_this, NotImplementedError.prototype);
27
+ return _this;
28
+ }
29
+ return NotImplementedError;
30
+ }(TwilioCliError_1.default));
31
+ exports.default = NotImplementedError;
32
+ //# sourceMappingURL=NotImplementedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotImplementedError.js","sourceRoot":"","sources":["../../src/lib/NotImplementedError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oEAA8C;AAE9C;IAAiD,uCAAc;IAC7D;QAAA,YACE,kBAAM,qCAAqC,CAAC,SAG7C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;;IAC7D,CAAC;IACH,0BAAC;AAAD,CAAC,AAND,CAAiD,wBAAc,GAM9D"}
@@ -0,0 +1,13 @@
1
+ import TwilioError from './TwilioError';
2
+ /**
3
+ *w
4
+ * A Twilio REST API Error response
5
+ * @link https://www.twilio.com/docs/usage/twilios-response#response-formats-exceptions
6
+ */
7
+ export default class TwilioApiError extends TwilioError {
8
+ readonly code: number;
9
+ readonly message: string;
10
+ readonly moreInfo?: string;
11
+ readonly status: number;
12
+ constructor(code: number, message: string, status: number, moreInfo?: string);
13
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var TwilioError_1 = __importDefault(require("./TwilioError"));
22
+ /**
23
+ *w
24
+ * A Twilio REST API Error response
25
+ * @link https://www.twilio.com/docs/usage/twilios-response#response-formats-exceptions
26
+ */
27
+ var TwilioApiError = /** @class */ (function (_super) {
28
+ __extends(TwilioApiError, _super);
29
+ function TwilioApiError(code, message, status, moreInfo) {
30
+ var _this = _super.call(this, message) || this;
31
+ _this.code = code;
32
+ _this.message = message;
33
+ _this.moreInfo = moreInfo;
34
+ _this.status = status;
35
+ Object.setPrototypeOf(_this, TwilioApiError.prototype);
36
+ return _this;
37
+ }
38
+ return TwilioApiError;
39
+ }(TwilioError_1.default));
40
+ exports.default = TwilioApiError;
41
+ //# sourceMappingURL=TwilioApiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwilioApiError.js","sourceRoot":"","sources":["../../src/lib/TwilioApiError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAwC;AAExC;;;;GAIG;AACH;IAA4C,kCAAW;IASrD,wBAAY,IAAY,EAAE,OAAe,EAAE,MAAc,EAAE,QAAiB;QAA5E,YACE,kBAAM,OAAO,CAAC,SAQf;QANC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;;IACxD,CAAC;IACH,qBAAC;AAAD,CAAC,AAnBD,CAA4C,qBAAW,GAmBtD"}
@@ -0,0 +1,4 @@
1
+ import TwilioError from './TwilioError';
2
+ export default class TwilioCliError extends TwilioError {
3
+ constructor(msg?: string);
4
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var TwilioError_1 = __importDefault(require("./TwilioError"));
22
+ var TwilioCliError = /** @class */ (function (_super) {
23
+ __extends(TwilioCliError, _super);
24
+ function TwilioCliError(msg) {
25
+ var _this = _super.call(this, msg) || this;
26
+ Object.setPrototypeOf(_this, TwilioCliError.prototype);
27
+ return _this;
28
+ }
29
+ return TwilioCliError;
30
+ }(TwilioError_1.default));
31
+ exports.default = TwilioCliError;
32
+ //# sourceMappingURL=TwilioCliError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwilioCliError.js","sourceRoot":"","sources":["../../src/lib/TwilioCliError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAwC;AAExC;IAA4C,kCAAW;IACrD,wBAAY,GAAY;QAAxB,YACE,kBAAM,GAAG,CAAC,SAGX;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;;IACxD,CAAC;IACH,qBAAC;AAAD,CAAC,AAND,CAA4C,qBAAW,GAMtD"}
@@ -0,0 +1,12 @@
1
+ export declare type Constructable<T> = new (...args: any[]) => T;
2
+ /**
3
+ * Base class for all errors generated by the script
4
+ */
5
+ export default class TwilioError extends Error {
6
+ constructor(msg?: string);
7
+ /**
8
+ * Returns whether this is the instance of the passed class
9
+ * @param klass the error class to test for
10
+ */
11
+ instanceOf: <T extends Error>(klass: Constructable<T>) => boolean;
12
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ /**
19
+ * Base class for all errors generated by the script
20
+ */
21
+ var TwilioError = /** @class */ (function (_super) {
22
+ __extends(TwilioError, _super);
23
+ function TwilioError(msg) {
24
+ var _this = _super.call(this, msg) || this;
25
+ /**
26
+ * Returns whether this is the instance of the passed class
27
+ * @param klass the error class to test for
28
+ */
29
+ _this.instanceOf = function (klass) {
30
+ // eslint-disable-next-line consistent-this, @typescript-eslint/no-this-alias
31
+ var instance = _this;
32
+ while (instance && instance !== Object.prototype) {
33
+ if (!instance || !instance.constructor || !instance.constructor.name) {
34
+ return false;
35
+ }
36
+ if (klass.name === instance.constructor.name) {
37
+ return true;
38
+ }
39
+ instance = Object.getPrototypeOf(instance);
40
+ }
41
+ return false;
42
+ };
43
+ Object.setPrototypeOf(_this, TwilioError.prototype);
44
+ return _this;
45
+ }
46
+ return TwilioError;
47
+ }(Error));
48
+ exports.default = TwilioError;
49
+ //# sourceMappingURL=TwilioError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwilioError.js","sourceRoot":"","sources":["../../src/lib/TwilioError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA;;GAEG;AACH;IAAyC,+BAAK;IAC5C,qBAAY,GAAY;QAAxB,YACE,kBAAM,GAAG,CAAC,SAGX;QAED;;;WAGG;QACI,gBAAU,GAAG,UAAkB,KAAuB;YAC3D,6EAA6E;YAC7E,IAAI,QAAQ,GAAG,KAAI,CAAC;YACpB,OAAO,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAAC,SAAS,EAAE;gBAChD,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE;oBACpE,OAAO,KAAK,CAAC;iBACd;gBAED,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE;oBAC5C,OAAO,IAAI,CAAC;iBACb;gBAED,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;aAC5C;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;QAvBA,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;;IACrD,CAAC;IAuBH,kBAAC;AAAD,CAAC,AA5BD,CAAyC,KAAK,GA4B7C"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@twilio/flex-plugins-utils-exception",
3
+ "version": "5.0.0-beta.0",
4
+ "description": "Flex Plugins Exceptions",
5
+ "keywords": [
6
+ "flex",
7
+ "flex plugins",
8
+ "flex plugins exception"
9
+ ],
10
+ "homepage": "https://github.com/twilio/flex-plugin-builder",
11
+ "bugs": {
12
+ "url": "https://github.com/twilio/flex-plugin-builder/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/twilio/flex-plugin-builder.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Flex Runtime <flex-runtime@twilio.com>",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "directories": {
23
+ "lib": "src",
24
+ "test": "__tests__"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "scripts": {
30
+ "prebuild": "npm run clean",
31
+ "build": "cd ../.. && tsc -p \"packages/flex-plugins-utils-exception/tsconfig.json\"",
32
+ "clean": "rm -rf dist",
33
+ "lint": "eslint --ext ts src/",
34
+ "lint:fix": "npm run lint -- --fix",
35
+ "test": "cd ../.. && jest packages/flex-plugins-utils-exception --color",
36
+ "test:watch": "cd ../.. && jest packages/flex-plugins-utils-exception --watch --color"
37
+ },
38
+ "gitHead": "137c66675998127e94a04a267a9b504451390306"
39
+ }