@aircall/exception
Advanced tools
Comparing version 0.1.2 to 0.1.5
@@ -11,8 +11,8 @@ declare abstract class Exception extends Error { | ||
interface Schema$b { | ||
interface Schema$c { | ||
path: string; | ||
} | ||
declare abstract class FieldException extends Exception { | ||
path: Schema$b['path']; | ||
constructor({ path }: Schema$b, message?: string); | ||
path: Schema$c['path']; | ||
constructor({ path }: Schema$c, message?: string); | ||
toJSON(): { | ||
@@ -26,4 +26,4 @@ path: string; | ||
type StringValidation = 'phoneNumber' | 'email' | 'url' | 'emoji' | 'uuid' | 'regex' | 'cuid' | 'cuid2' | 'ulid' | 'datetime' | 'ip'; | ||
interface Schema$a { | ||
type StringValidation = 'phoneNumber' | 'email' | 'url' | 'emoji' | 'uuid' | 'nanoid' | 'regex' | 'cuid' | 'cuid2' | 'ulid' | 'datetime' | 'ip' | 'date' | 'time' | 'duration' | 'base64'; | ||
interface Schema$b { | ||
path: string; | ||
@@ -45,4 +45,4 @@ validation: StringValidation; | ||
code: string; | ||
validation: Schema$a['validation']; | ||
constructor({ validation, path }: Schema$a, message?: string); | ||
validation: Schema$b['validation']; | ||
constructor({ validation, path }: Schema$b, message?: string); | ||
toJSON(): { | ||
@@ -65,3 +65,3 @@ validation: StringValidation; | ||
*/ | ||
interface Schema$9 { | ||
interface Schema$a { | ||
path: string; | ||
@@ -74,5 +74,5 @@ received: string; | ||
code: string; | ||
received: Schema$9['received']; | ||
expected: Schema$9['expected']; | ||
constructor({ received, expected, path }: Schema$9, message?: string); | ||
received: Schema$a['received']; | ||
expected: Schema$a['expected']; | ||
constructor({ received, expected, path }: Schema$a, message?: string); | ||
toJSON(): { | ||
@@ -99,3 +99,3 @@ received: string; | ||
*/ | ||
interface Schema$8 { | ||
interface Schema$9 { | ||
path: string; | ||
@@ -108,5 +108,5 @@ type: string; | ||
code: string; | ||
type: Schema$8['type']; | ||
maximum: Schema$8['maximum']; | ||
constructor({ path, type, maximum }: Schema$8, message?: string); | ||
type: Schema$9['type']; | ||
maximum: Schema$9['maximum']; | ||
constructor({ path, type, maximum }: Schema$9, message?: string); | ||
toJSON(): { | ||
@@ -133,3 +133,3 @@ type: string; | ||
*/ | ||
interface Schema$7 { | ||
interface Schema$8 { | ||
path: string; | ||
@@ -142,5 +142,5 @@ type: string; | ||
code: string; | ||
type: Schema$7['type']; | ||
minimum: Schema$7['minimum']; | ||
constructor({ path, type, minimum }: Schema$7, message?: string); | ||
type: Schema$8['type']; | ||
minimum: Schema$8['minimum']; | ||
constructor({ path, type, minimum }: Schema$8, message?: string); | ||
toJSON(): { | ||
@@ -157,3 +157,3 @@ type: string; | ||
type IssueException = InvalidTypeException | TooSmallException | TooBigException | InvalidStringException | FieldException; | ||
interface Schema$6 { | ||
interface Schema$7 { | ||
issues: IssueException[]; | ||
@@ -164,4 +164,4 @@ } | ||
code: string; | ||
issues: Schema$6['issues']; | ||
constructor({ issues }?: Schema$6, message?: string); | ||
issues: Schema$7['issues']; | ||
constructor({ issues }?: Schema$7, message?: string); | ||
addIssue(issue: IssueException): void; | ||
@@ -188,3 +188,3 @@ toJSON(): { | ||
*/ | ||
interface Schema$5 { | ||
interface Schema$6 { | ||
path: string; | ||
@@ -197,4 +197,4 @@ options: string[]; | ||
code: string; | ||
options: Schema$5['options']; | ||
constructor({ options, received, path }: Schema$5, message?: string); | ||
options: Schema$6['options']; | ||
constructor({ options, received, path }: Schema$6, message?: string); | ||
toJSON(): { | ||
@@ -215,3 +215,3 @@ options: string[]; | ||
interface Schema$4 { | ||
interface Schema$5 { | ||
resource: string; | ||
@@ -223,5 +223,5 @@ access: 'create' | 'read' | 'update' | 'delete'; | ||
code: string; | ||
resource: Schema$4['resource']; | ||
access: Schema$4['access']; | ||
constructor({ resource, access }: Schema$4, message?: string); | ||
resource: Schema$5['resource']; | ||
access: Schema$5['access']; | ||
constructor({ resource, access }: Schema$5, message?: string); | ||
toJSON(): { | ||
@@ -236,3 +236,3 @@ resource: string; | ||
interface Schema$3 { | ||
interface Schema$4 { | ||
resource: string; | ||
@@ -243,4 +243,4 @@ } | ||
code: string; | ||
resource: Schema$3['resource']; | ||
constructor({ resource }: Schema$3, message?: string); | ||
resource: Schema$4['resource']; | ||
constructor({ resource }: Schema$4, message?: string); | ||
toJSON(): { | ||
@@ -254,3 +254,3 @@ resource: string; | ||
interface Schema$2 { | ||
interface Schema$3 { | ||
path: string; | ||
@@ -261,4 +261,4 @@ } | ||
code: string; | ||
path: Schema$2['path']; | ||
constructor({ path }: Schema$2, message?: string); | ||
path: Schema$3['path']; | ||
constructor({ path }: Schema$3, message?: string); | ||
toJSON(): { | ||
@@ -272,3 +272,3 @@ path: string; | ||
interface Schema$1 { | ||
interface Schema$2 { | ||
resource: string; | ||
@@ -279,4 +279,4 @@ } | ||
code: string; | ||
resource: Schema$1['resource']; | ||
constructor({ resource }: Schema$1, message?: string); | ||
resource: Schema$2['resource']; | ||
constructor({ resource }: Schema$2, message?: string); | ||
toJSON(): { | ||
@@ -290,3 +290,3 @@ resource: string; | ||
interface Schema { | ||
interface Schema$1 { | ||
resource: string; | ||
@@ -298,5 +298,5 @@ limit: number; | ||
code: string; | ||
resource: Schema['resource']; | ||
limit: Schema['limit']; | ||
constructor({ resource, limit }: Schema, message?: string); | ||
resource: Schema$1['resource']; | ||
limit: Schema$1['limit']; | ||
constructor({ resource, limit }: Schema$1, message?: string); | ||
toJSON(): { | ||
@@ -311,2 +311,24 @@ resource: string; | ||
export { Exception, FieldException, GenericException, InsufficientPermissionException, InvalidEnumException, InvalidStringException, InvalidTypeException, RateLimitExceededException, ResourceNotFoundException, TooBigException, TooManyRequestsException, TooSmallException, UnprocessableResourceException, UserInputException }; | ||
interface Schema { | ||
reason: string; | ||
} | ||
declare class UnauthorizedException extends Exception { | ||
name: string; | ||
code: string; | ||
reason: Schema['reason']; | ||
constructor({ reason }: Schema, message?: string); | ||
toJSON(): { | ||
reason: string; | ||
name: string; | ||
message: string; | ||
code: string; | ||
}; | ||
} | ||
declare class InternalServerException extends Exception { | ||
name: string; | ||
code: string; | ||
constructor(message?: string); | ||
} | ||
export { Exception, FieldException, GenericException, InsufficientPermissionException, InternalServerException, InvalidEnumException, InvalidStringException, InvalidTypeException, RateLimitExceededException, ResourceNotFoundException, TooBigException, TooManyRequestsException, TooSmallException, UnauthorizedException, UnprocessableResourceException, UserInputException }; |
@@ -243,2 +243,28 @@ 'use strict'; | ||
// src/exceptions/UnauthorizedException.ts | ||
var UnauthorizedException = class extends Exception { | ||
name = "UnauthorizedException"; | ||
code = "0007"; | ||
reason; | ||
constructor({ reason }, message = "Unauthorized access") { | ||
super(message); | ||
this.reason = reason; | ||
} | ||
toJSON() { | ||
return { | ||
...super.toJSON(), | ||
reason: this.reason | ||
}; | ||
} | ||
}; | ||
// src/exceptions/InternalServerException.ts | ||
var InternalServerException = class extends Exception { | ||
name = "InternalServerException"; | ||
code = "0008"; | ||
constructor(message = "Internal server error") { | ||
super(message); | ||
} | ||
}; | ||
exports.Exception = Exception; | ||
@@ -248,2 +274,3 @@ exports.FieldException = FieldException; | ||
exports.InsufficientPermissionException = InsufficientPermissionException; | ||
exports.InternalServerException = InternalServerException; | ||
exports.InvalidEnumException = InvalidEnumException; | ||
@@ -257,3 +284,4 @@ exports.InvalidStringException = InvalidStringException; | ||
exports.TooSmallException = TooSmallException; | ||
exports.UnauthorizedException = UnauthorizedException; | ||
exports.UnprocessableResourceException = UnprocessableResourceException; | ||
exports.UserInputException = UserInputException; |
{ | ||
"name": "@aircall/exception", | ||
"version": "0.1.2", | ||
"version": "0.1.5", | ||
"main": "dist/index.js", | ||
@@ -8,2 +8,10 @@ "module": "dist/index.mjs", | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"publishConfig": { | ||
@@ -29,4 +37,4 @@ "access": "public" | ||
"devDependencies": { | ||
"@aircall/test-sequencer": "1.0.0", | ||
"@aircall/tsconfig": "1.4.0", | ||
"@aircall/test-sequencer": "1.0.2", | ||
"@aircall/tsconfig": "1.4.2", | ||
"@size-limit/preset-small-lib": "8.1.0", | ||
@@ -44,7 +52,6 @@ "@types/jest": "29.5.2", | ||
"dev": "pnpm build --watch", | ||
"posttest": "pnpm run size", | ||
"size": "size-limit", | ||
"test:ci": "pnpm run test --testSequencer @aircall/test-sequencer/parallel-ci-sequencer.js --passWithNoTests --silent", | ||
"test:ci": "pnpm run test --shard ${CI_NODE_INDEX}/${CI_NODE_TOTAL} --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
32166
814