New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@keepfy/error-extractor

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keepfy/error-extractor - npm Package Compare versions

Comparing version

to
1.2.2

3

lib/error.d.ts

@@ -1,4 +0,5 @@

import { AllErrorTypes, ExtractMessageFromError, GraphQLErrors } from './types';
import { AllErrorTypes, BackendErrorsWithProperties, ExtractMessageFromError, GraphQLErrors } from './types';
export declare const fromGraphQLError: (graphQLErrors: GraphQLErrors[]) => AllErrorTypes;
export declare const fromApollo: ExtractMessageFromError;
export declare const fromResponse: ({ graphQLErrors, networkError }: import("apollo-link-error").ErrorResponse) => AllErrorTypes;
export declare const extractProperties: <T extends "ENTITY_IS_STILL_REFERENCED">(error: GraphQLErrors) => BackendErrorsWithProperties[T];

@@ -72,1 +72,2 @@ const typeFromMessage = message => {

});
export const extractProperties = (error) => error.properties;

@@ -1,4 +0,4 @@

export { fromApollo, fromResponse } from './error';
export { fromApollo, fromResponse, extractProperties } from './error';
export { getSuggestion, suggestionFromGraphQLError } from './suggestions';
export { forwardToSentry } from './sentry-handler';
export * from './types';

@@ -1,3 +0,3 @@

export { fromApollo, fromResponse } from './error';
export { fromApollo, fromResponse, extractProperties } from './error';
export { getSuggestion, suggestionFromGraphQLError } from './suggestions';
export { forwardToSentry } from './sentry-handler';
const typeToCapture = [
'UNKNOWN_ERROR',
'SCHEMA_UNKNOWN_FIELD'
'SCHEMA_UNKNOWN_FIELD',
'INVALID_SUBSCRIPTION',
'INVALID_INPUT'
];

@@ -5,0 +7,0 @@ const captureGQLErrors = (sentry, gqlErrors, operationName) => {

@@ -1,3 +0,4 @@

import { AllErrorTypes, GraphQLErrors } from './types';
export declare const getSuggestion: (code: AllErrorTypes) => (import("./types").MessageSuggestion & {
import { GraphQLErrors, SuggestionsMap } from './types';
export declare const getSuggestion: <T extends import("./types").AllErrorTypes = import("./types").AllErrorTypes>(code: T) => SuggestionsMap[T];
export declare const suggestionFromGraphQLError: (graphQLErrors: GraphQLErrors[]) => (import("./types").MessageSuggestion & {
type: "SERVICE_OFFLINE";

@@ -19,22 +20,13 @@ }) | (import("./types").MessageSuggestion & {

}) | (import("./types").MessageSuggestion & {
type: "BUSINESS_ERROR";
});
export declare const suggestionFromGraphQLError: (graphQLErrors: GraphQLErrors[]) => (import("./types").MessageSuggestion & {
type: "SERVICE_OFFLINE";
type: "INVALID_SUBSCRIPTION";
}) | (import("./types").MessageSuggestion & {
type: "CONNECTION_FAILED";
type: "ENTITY_NOT_FOUND";
}) | (import("./types").MessageSuggestion & {
type: "UNKNOWN_ERROR";
type: "INVALID_INPUT";
}) | (import("./types").MessageSuggestion & {
type: "EMAIL_NOT_CONFIRMED";
type: "INTERNAL_SERVER_ERROR";
}) | (import("./types").MessageSuggestion & {
type: "EMAIL_ALREADY_EXISTS";
type: "BUSINESS_ERROR";
}) | (import("./types").MessageSuggestion & {
type: "SCHEMA_UNKNOWN_FIELD";
}) | (import("./types").MessageSuggestion & {
type: "AUTHENTICATION_FAILED";
}) | (import("./types").MessageSuggestion & {
type: "FORBIDDEN";
}) | (import("./types").MessageSuggestion & {
type: "BUSINESS_ERROR";
type: "ENTITY_IS_STILL_REFERENCED";
});
import { fromGraphQLError } from './error';
const unknownError = {
title: 'Erro desconhecido',
message: 'Erro não identificado, contate o administrador'
};
const suggestions = {

@@ -20,4 +24,3 @@ SERVICE_OFFLINE: {

type: 'UNKNOWN_ERROR',
title: 'Erro desconhecido',
message: 'Erro não identificado, contate o administrador'
...unknownError
},

@@ -48,5 +51,29 @@ BUSINESS_ERROR: {

message: 'Você não possui permissão para realizar esta ação.'
},
ENTITY_NOT_FOUND: {
type: 'ENTITY_NOT_FOUND',
title: 'Entidade não encontrada',
message: 'Tente novamente'
},
INTERNAL_SERVER_ERROR: {
type: 'INTERNAL_SERVER_ERROR',
...unknownError
},
INVALID_INPUT: {
type: 'INVALID_INPUT',
title: 'Campo inválido',
message: 'Um ou mais campos inválidos'
},
INVALID_SUBSCRIPTION: {
type: 'INVALID_SUBSCRIPTION',
title: 'Plano não existente',
message: 'Esta conta não possui um plano vinculado, contate o administrador'
},
ENTITY_IS_STILL_REFERENCED: {
type: 'ENTITY_IS_STILL_REFERENCED',
title: 'Entidade referênciada',
message: 'Não é possivel realizar a operação, entidade ainda possui vínculos'
}
};
export const getSuggestion = (code) => suggestions[code] || suggestions[code];
export const getSuggestion = (code) => suggestions[code];
export const suggestionFromGraphQLError = (graphQLErrors) => {

@@ -62,6 +89,6 @@ const type = fromGraphQLError(graphQLErrors);

// See error.ts extract from apollo fn
if (error.code === 'BUSINESS_ERROR') {
if (message) {
return {
...extracted,
message: message
message
};

@@ -68,0 +95,0 @@ }

import { ErrorResponse } from 'apollo-link-error';
import { ApolloError } from 'apollo-client';
export declare type ClientErrorTypes = 'SERVICE_OFFLINE' | 'CONNECTION_FAILED' | 'UNKNOWN_ERROR' | 'EMAIL_NOT_CONFIRMED' | 'EMAIL_ALREADY_EXISTS' | 'SCHEMA_UNKNOWN_FIELD';
export declare type BackEndErrorTypes = 'AUTHENTICATION_FAILED' | 'FORBIDDEN' | 'BUSINESS_ERROR';
export declare type BackendErrorsWithProperties = {
ENTITY_IS_STILL_REFERENCED: {
primaryKey: {
[index: string]: string;
};
entity: string;
referencedBy: string;
};
};
export declare type BackEndErrorTypes = 'AUTHENTICATION_FAILED' | 'FORBIDDEN' | 'INVALID_SUBSCRIPTION' | 'ENTITY_NOT_FOUND' | 'INVALID_INPUT' | 'INTERNAL_SERVER_ERROR' | 'BUSINESS_ERROR' | keyof BackendErrorsWithProperties;
export declare type AllErrorTypes = ClientErrorTypes | BackEndErrorTypes;

@@ -6,0 +15,0 @@ export declare type MessageSuggestion = {

{
"name": "@keepfy/error-extractor",
"version": "1.2.1",
"version": "1.2.2",
"description": "An error extractor package for keepfy frontend apps",

@@ -5,0 +5,0 @@ "main": "lib/index.js",