@integration-app/sdk
Advanced tools
Comparing version 0.1.44 to 0.1.45
@@ -12,9 +12,7 @@ export declare enum ErrorType { | ||
NOT_AUTHENTICATED = "not_authenticated", | ||
ACCESS_DENIED = "access_denied", | ||
CONNECTION_NOT_FOUND = "connection_not_found", | ||
CONNECTION_IS_DEFUNCT = "connection_is_defunct" | ||
ACCESS_DENIED = "access_denied" | ||
} | ||
export declare class BaseErrorData { | ||
type: ErrorType; | ||
key?: ErrorKey; | ||
key?: string; | ||
message: string; | ||
@@ -33,2 +31,6 @@ helpText?: string; | ||
} | ||
export declare enum ConnectionErrorKey { | ||
CONNECTION_IS_DEFUNCT = "connection_is_defunct", | ||
ACCESS_TOKEN_EXPIRED = "access_token_expired" | ||
} | ||
export declare class ConnectionErrorData extends BaseErrorData { | ||
@@ -54,9 +56,5 @@ connectionKey: string; | ||
} | ||
export declare class ConnectionNotFoundErrorData extends BadRequestErrorData { | ||
connectionId: string; | ||
constructor(data: any); | ||
} | ||
export declare type ErrorData = BadRequestErrorData | InternalErrorData | ConnectionErrorData | EndpointErrorData; | ||
declare class EngineErrorOptions { | ||
key?: ErrorKey; | ||
key?: string; | ||
helpText?: string; | ||
@@ -85,7 +83,4 @@ helpLink?: string; | ||
} | ||
declare class ConnectionNotFoundErrorOptions extends EngineErrorOptions { | ||
connectionId?: string; | ||
} | ||
export declare class EngineError extends Error { | ||
key: ErrorKey; | ||
key: string; | ||
helpText?: string; | ||
@@ -128,8 +123,4 @@ helpLink?: string; | ||
} | ||
export declare class ConnectionNotFoundError extends BadRequestError { | ||
connectionId?: string; | ||
constructor(message: any, options?: ConnectionNotFoundErrorOptions); | ||
} | ||
export declare function getErrorFromData(data: any): InternalError | BadRequestError | FlowRunError | EndpointError | ConnectionError; | ||
export declare function extractEngineErrorData(error: Error): InternalErrorData | EndpointErrorData | ConnectionErrorData | FlowConfigurationErrorData | FlowRunErrorData | BadRequestErrorData; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractEngineErrorData = exports.getErrorFromData = exports.ConnectionNotFoundError = exports.NotAuthenticatedError = exports.NotFoundError = exports.ConnectionError = exports.EndpointError = exports.FlowRunError = exports.FlowConfigurationError = exports.BadRequestError = exports.InternalError = exports.EngineError = exports.ConnectionNotFoundErrorData = exports.BadRequestErrorData = exports.FlowRunErrorData = exports.FlowConfigurationErrorData = exports.ConnectionErrorData = exports.EndpointErrorData = exports.InternalErrorData = exports.BaseErrorData = exports.ErrorKey = exports.ErrorType = void 0; | ||
exports.extractEngineErrorData = exports.getErrorFromData = exports.NotAuthenticatedError = exports.NotFoundError = exports.ConnectionError = exports.EndpointError = exports.FlowRunError = exports.FlowConfigurationError = exports.BadRequestError = exports.InternalError = exports.EngineError = exports.BadRequestErrorData = exports.FlowRunErrorData = exports.FlowConfigurationErrorData = exports.ConnectionErrorData = exports.ConnectionErrorKey = exports.EndpointErrorData = exports.InternalErrorData = exports.BaseErrorData = exports.ErrorKey = exports.ErrorType = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -20,4 +20,2 @@ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); | ||
ErrorKey["ACCESS_DENIED"] = "access_denied"; | ||
ErrorKey["CONNECTION_NOT_FOUND"] = "connection_not_found"; | ||
ErrorKey["CONNECTION_IS_DEFUNCT"] = "connection_is_defunct"; | ||
})(ErrorKey = exports.ErrorKey || (exports.ErrorKey = {})); | ||
@@ -60,2 +58,7 @@ class BaseErrorData { | ||
exports.EndpointErrorData = EndpointErrorData; | ||
var ConnectionErrorKey; | ||
(function (ConnectionErrorKey) { | ||
ConnectionErrorKey["CONNECTION_IS_DEFUNCT"] = "connection_is_defunct"; | ||
ConnectionErrorKey["ACCESS_TOKEN_EXPIRED"] = "access_token_expired"; | ||
})(ConnectionErrorKey = exports.ConnectionErrorKey || (exports.ConnectionErrorKey = {})); | ||
class ConnectionErrorData extends BaseErrorData { | ||
@@ -97,9 +100,2 @@ constructor(data) { | ||
exports.BadRequestErrorData = BadRequestErrorData; | ||
class ConnectionNotFoundErrorData extends BadRequestErrorData { | ||
constructor(data) { | ||
super(data); | ||
this.connectionId = data.connectionId; | ||
} | ||
} | ||
exports.ConnectionNotFoundErrorData = ConnectionNotFoundErrorData; | ||
class EngineErrorOptions { | ||
@@ -117,4 +113,2 @@ } | ||
} | ||
class ConnectionNotFoundErrorOptions extends EngineErrorOptions { | ||
} | ||
class EngineError extends Error { | ||
@@ -186,18 +180,6 @@ constructor(message, options = {}) { | ||
exports.NotAuthenticatedError = NotAuthenticatedError; | ||
class ConnectionNotFoundError extends BadRequestError { | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
this.key = ErrorKey.CONNECTION_NOT_FOUND; | ||
this.connectionId = options.connectionId; | ||
} | ||
} | ||
exports.ConnectionNotFoundError = ConnectionNotFoundError; | ||
function getErrorFromData(data) { | ||
if (!lodash_1.default.isPlainObject(data) || !data.type) | ||
return null; | ||
if (data.type === ErrorType.BAD_REQUEST && | ||
data.key === ErrorKey.CONNECTION_NOT_FOUND) { | ||
return new ConnectionNotFoundError(data.message, data); | ||
} | ||
else if (data.type === ErrorType.CONNECTION) { | ||
if (data.type === ErrorType.CONNECTION) { | ||
return new ConnectionError(data.message, data); | ||
@@ -226,13 +208,3 @@ } | ||
function extractEngineErrorData(error) { | ||
if (error instanceof ConnectionNotFoundError) { | ||
return new ConnectionNotFoundErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionId: error.connectionId, | ||
}); | ||
} | ||
else if (error instanceof FlowConfigurationError) { | ||
if (error instanceof FlowConfigurationError) { | ||
return new FlowConfigurationErrorData({ | ||
@@ -239,0 +211,0 @@ message: error.message, |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.1.44", | ||
"version": "0.1.45", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,4 +16,2 @@ import _ from 'lodash' | ||
ACCESS_DENIED = 'access_denied', | ||
CONNECTION_NOT_FOUND = 'connection_not_found', | ||
CONNECTION_IS_DEFUNCT = 'connection_is_defunct', | ||
} | ||
@@ -23,3 +21,3 @@ | ||
public type: ErrorType | ||
public key?: ErrorKey | ||
public key?: string | ||
public message: string | ||
@@ -65,2 +63,7 @@ public helpText?: string | ||
export enum ConnectionErrorKey { | ||
CONNECTION_IS_DEFUNCT = 'connection_is_defunct', | ||
ACCESS_TOKEN_EXPIRED = 'access_token_expired', | ||
} | ||
export class ConnectionErrorData extends BaseErrorData { | ||
@@ -114,11 +117,2 @@ public connectionKey: string | ||
export class ConnectionNotFoundErrorData extends BadRequestErrorData { | ||
public connectionId: string | ||
constructor(data) { | ||
super(data) | ||
this.connectionId = data.connectionId | ||
} | ||
} | ||
export type ErrorData = | ||
@@ -131,3 +125,3 @@ | BadRequestErrorData | ||
class EngineErrorOptions { | ||
public key?: ErrorKey | ||
public key?: string | ||
public helpText?: string | ||
@@ -162,8 +156,4 @@ public helpLink?: string | ||
class ConnectionNotFoundErrorOptions extends EngineErrorOptions { | ||
public connectionId?: string | ||
} | ||
export class EngineError extends Error { | ||
public key: ErrorKey | ||
public key: string | ||
public helpText?: string | ||
@@ -251,21 +241,6 @@ public helpLink?: string | ||
export class ConnectionNotFoundError extends BadRequestError { | ||
public connectionId?: string | ||
constructor(message, options: ConnectionNotFoundErrorOptions = {}) { | ||
super(message, options) | ||
this.key = ErrorKey.CONNECTION_NOT_FOUND | ||
this.connectionId = options.connectionId | ||
} | ||
} | ||
export function getErrorFromData(data: any) { | ||
if (!_.isPlainObject(data) || !data.type) return null | ||
if ( | ||
data.type === ErrorType.BAD_REQUEST && | ||
data.key === ErrorKey.CONNECTION_NOT_FOUND | ||
) { | ||
return new ConnectionNotFoundError(data.message, data) | ||
} else if (data.type === ErrorType.CONNECTION) { | ||
if (data.type === ErrorType.CONNECTION) { | ||
return new ConnectionError(data.message, data) | ||
@@ -288,12 +263,3 @@ } else if (data.type === ErrorType.ENDPOINT) { | ||
export function extractEngineErrorData(error: Error) { | ||
if (error instanceof ConnectionNotFoundError) { | ||
return new ConnectionNotFoundErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionId: error.connectionId, | ||
}) | ||
} else if (error instanceof FlowConfigurationError) { | ||
if (error instanceof FlowConfigurationError) { | ||
return new FlowConfigurationErrorData({ | ||
@@ -300,0 +266,0 @@ message: error.message, |
Sorry, the diff of this file is not supported yet
980782
11605