@aircall/exception
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -11,8 +11,8 @@ declare abstract class Exception extends Error { | ||
interface Schema$8 { | ||
interface Schema$b { | ||
path: string; | ||
} | ||
declare abstract class FieldException extends Exception { | ||
path: Schema$8['path']; | ||
constructor({ path }: Schema$8, message?: string); | ||
path: Schema$b['path']; | ||
constructor({ path }: Schema$b, message?: string); | ||
toJSON(): { | ||
@@ -27,3 +27,3 @@ path: string; | ||
type StringValidation = 'phoneNumber' | 'email' | 'url' | 'emoji' | 'uuid' | 'regex' | 'cuid' | 'cuid2' | 'ulid' | 'datetime' | 'ip'; | ||
interface Schema$7 { | ||
interface Schema$a { | ||
path: string; | ||
@@ -45,4 +45,4 @@ validation: StringValidation; | ||
code: string; | ||
validation: Schema$7['validation']; | ||
constructor({ validation, path }: Schema$7, message?: string); | ||
validation: Schema$a['validation']; | ||
constructor({ validation, path }: Schema$a, message?: string); | ||
toJSON(): { | ||
@@ -65,3 +65,3 @@ validation: StringValidation; | ||
*/ | ||
interface Schema$6 { | ||
interface Schema$9 { | ||
path: string; | ||
@@ -74,5 +74,5 @@ received: string; | ||
code: string; | ||
received: Schema$6['received']; | ||
expected: Schema$6['expected']; | ||
constructor({ received, expected, path }: Schema$6, message?: string); | ||
received: Schema$9['received']; | ||
expected: Schema$9['expected']; | ||
constructor({ received, expected, path }: Schema$9, message?: string); | ||
toJSON(): { | ||
@@ -99,3 +99,3 @@ received: string; | ||
*/ | ||
interface Schema$5 { | ||
interface Schema$8 { | ||
path: string; | ||
@@ -108,5 +108,5 @@ type: string; | ||
code: string; | ||
type: Schema$5['type']; | ||
maximum: Schema$5['maximum']; | ||
constructor({ path, type, maximum }: Schema$5, message?: string); | ||
type: Schema$8['type']; | ||
maximum: Schema$8['maximum']; | ||
constructor({ path, type, maximum }: Schema$8, message?: string); | ||
toJSON(): { | ||
@@ -133,3 +133,3 @@ type: string; | ||
*/ | ||
interface Schema$4 { | ||
interface Schema$7 { | ||
path: string; | ||
@@ -142,5 +142,5 @@ type: string; | ||
code: string; | ||
type: Schema$4['type']; | ||
minimum: Schema$4['minimum']; | ||
constructor({ path, type, minimum }: Schema$4, message?: string); | ||
type: Schema$7['type']; | ||
minimum: Schema$7['minimum']; | ||
constructor({ path, type, minimum }: Schema$7, message?: string); | ||
toJSON(): { | ||
@@ -157,3 +157,3 @@ type: string; | ||
type IssueException = InvalidTypeException | TooSmallException | TooBigException | InvalidStringException | FieldException; | ||
interface Schema$3 { | ||
interface Schema$6 { | ||
issues: IssueException[]; | ||
@@ -164,4 +164,4 @@ } | ||
code: string; | ||
issues: Schema$3['issues']; | ||
constructor({ issues }?: Schema$3, message?: string); | ||
issues: Schema$6['issues']; | ||
constructor({ issues }?: Schema$6, message?: string); | ||
addIssue(issue: IssueException): void; | ||
@@ -188,3 +188,3 @@ toJSON(): { | ||
*/ | ||
interface Schema$2 { | ||
interface Schema$5 { | ||
path: string; | ||
@@ -197,4 +197,4 @@ options: string[]; | ||
code: string; | ||
options: Schema$2['options']; | ||
constructor({ options, received, path }: Schema$2, message?: string); | ||
options: Schema$5['options']; | ||
constructor({ options, received, path }: Schema$5, message?: string); | ||
toJSON(): { | ||
@@ -215,3 +215,3 @@ options: string[]; | ||
interface Schema$1 { | ||
interface Schema$4 { | ||
resource: string; | ||
@@ -223,5 +223,5 @@ access: 'create' | 'read' | 'update' | 'delete'; | ||
code: string; | ||
resource: Schema$1['resource']; | ||
access: Schema$1['access']; | ||
constructor({ resource, access }: Schema$1, message?: string); | ||
resource: Schema$4['resource']; | ||
access: Schema$4['access']; | ||
constructor({ resource, access }: Schema$4, message?: string); | ||
toJSON(): { | ||
@@ -236,3 +236,3 @@ resource: string; | ||
interface Schema { | ||
interface Schema$3 { | ||
resource: string; | ||
@@ -243,6 +243,57 @@ } | ||
code: string; | ||
resource: Schema$3['resource']; | ||
constructor({ resource }: Schema$3, message?: string); | ||
toJSON(): { | ||
resource: string; | ||
name: string; | ||
message: string; | ||
code: string; | ||
}; | ||
} | ||
interface Schema$2 { | ||
path: string; | ||
} | ||
declare class TooManyRequestsException extends Exception { | ||
name: string; | ||
code: string; | ||
path: Schema$2['path']; | ||
constructor({ path }: Schema$2, message?: string); | ||
toJSON(): { | ||
path: string; | ||
name: string; | ||
message: string; | ||
code: string; | ||
}; | ||
} | ||
interface Schema$1 { | ||
resource: string; | ||
} | ||
declare class UnprocessableResourceException extends Exception { | ||
name: string; | ||
code: string; | ||
resource: Schema$1['resource']; | ||
constructor({ resource }: Schema$1, message?: string); | ||
toJSON(): { | ||
resource: string; | ||
name: string; | ||
message: string; | ||
code: string; | ||
}; | ||
} | ||
interface Schema { | ||
resource: string; | ||
limit: number; | ||
} | ||
declare class RateLimitExceededException extends Exception { | ||
name: string; | ||
code: string; | ||
resource: Schema['resource']; | ||
constructor({ resource }: Schema, message?: string); | ||
limit: Schema['limit']; | ||
constructor({ resource, limit }: Schema, message?: string); | ||
toJSON(): { | ||
resource: string; | ||
limit: number; | ||
name: string; | ||
@@ -254,2 +305,2 @@ message: string; | ||
export { Exception, FieldException, GenericException, InsufficientPermissionException, InvalidEnumException, InvalidStringException, InvalidTypeException, ResourceNotFoundException, TooBigException, TooSmallException, UserInputException }; | ||
export { Exception, FieldException, GenericException, InsufficientPermissionException, InvalidEnumException, InvalidStringException, InvalidTypeException, RateLimitExceededException, ResourceNotFoundException, TooBigException, TooManyRequestsException, TooSmallException, UnprocessableResourceException, UserInputException }; |
@@ -189,2 +189,56 @@ 'use strict'; | ||
// src/exceptions/TooManyRequestsException.ts | ||
var TooManyRequestsException = class extends Exception { | ||
name = "TooManyRequestsException"; | ||
code = "0006"; | ||
path; | ||
constructor({ path }, message = `"${path}" was requested too many times`) { | ||
super(message); | ||
this.path = path; | ||
} | ||
toJSON() { | ||
return { | ||
...super.toJSON(), | ||
path: this.path | ||
}; | ||
} | ||
}; | ||
// src/exceptions/UnprocessableResourceException.ts | ||
var UnprocessableResourceException = class extends Exception { | ||
name = "UnprocessableResourceException"; | ||
code = "0004"; | ||
resource; | ||
constructor({ resource }, message = `"${resource}" could not be processed`) { | ||
super(message); | ||
this.resource = resource; | ||
} | ||
toJSON() { | ||
return { | ||
...super.toJSON(), | ||
resource: this.resource | ||
}; | ||
} | ||
}; | ||
// src/exceptions/RateLimitExceededException.ts | ||
var RateLimitExceededException = class extends Exception { | ||
name = "RateLimitExceededException"; | ||
code = "0005"; | ||
resource; | ||
limit; | ||
constructor({ resource, limit }, message = `"${resource}" reached the limit of ${limit} requests`) { | ||
super(message); | ||
this.resource = resource; | ||
this.limit = limit; | ||
} | ||
toJSON() { | ||
return { | ||
...super.toJSON(), | ||
resource: this.resource, | ||
limit: this.limit | ||
}; | ||
} | ||
}; | ||
exports.Exception = Exception; | ||
@@ -197,5 +251,8 @@ exports.FieldException = FieldException; | ||
exports.InvalidTypeException = InvalidTypeException; | ||
exports.RateLimitExceededException = RateLimitExceededException; | ||
exports.ResourceNotFoundException = ResourceNotFoundException; | ||
exports.TooBigException = TooBigException; | ||
exports.TooManyRequestsException = TooManyRequestsException; | ||
exports.TooSmallException = TooSmallException; | ||
exports.UnprocessableResourceException = UnprocessableResourceException; | ||
exports.UserInputException = UserInputException; |
{ | ||
"name": "@aircall/exception", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "dist/index.js", | ||
@@ -44,5 +44,5 @@ "module": "dist/index.mjs", | ||
"size": "size-limit", | ||
"test:ci": "pnpm run test --testSequencer @aircall/test-sequencer/parallel-ci-sequencer.js --passWithNoTests", | ||
"test:ci": "pnpm run test --testSequencer @aircall/test-sequencer/parallel-ci-sequencer.js --passWithNoTests --silent", | ||
"test": "jest --passWithNoTests" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
29532
744