41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
|
import { IApiResponse } from "@rocket.chat/apps-engine/definition/api";
|
||
|
|
||
|
export enum SCIMErrorType {
|
||
|
INVALID_FILTER = "invalidFilter",
|
||
|
TOO_MANY = "tooMany",
|
||
|
UNIQUENESS = "uniqueness",
|
||
|
MUTABILITY = "mutability",
|
||
|
INVALID_SYNTAX = "invalidSyntax",
|
||
|
INVALID_PATH = "invalidPath",
|
||
|
NO_TARGET = "noTarget",
|
||
|
INVALID_VALUE = "invalidValue",
|
||
|
INVALID_VERS = "invalidVers",
|
||
|
SENSITIVE = "sensitive",
|
||
|
}
|
||
|
|
||
|
export enum SCIMErrorDetail {
|
||
|
TEMPORARY_REDIRECT = "The client is directed to repeat the same HTTP request at the location identified.",
|
||
|
PERMANENT_REDIRECT = "The client is directed to repeat the same HTTP request at the location identified.",
|
||
|
BAD_REQUEST = "Request is unparsable, syntactically incorrect, or violates schema.",
|
||
|
UNAUTHORIZED = "Authorization failure. The authorization header is invalid or missing.",
|
||
|
FORBIDDEN = "Operation is not permitted based on the supplied authorization.",
|
||
|
NOT_FOUND = "Specified resource or endpoint does not exist.",
|
||
|
CONFLICT = "The specified version number does not match the resource's latest version number, or a service provider refused to create a new, duplicate resource.",
|
||
|
PRECONDITION_FAILED = "Failed to update. Resource has changed on the server.",
|
||
|
PAYLOAD_TOO_LARGE = `{"maxOperations": 1000,"maxPayloadSize": 1048576}`,
|
||
|
INTERNAL_SERVER_ERROR = "An internal error.",
|
||
|
NOT_IMPLEMENTED = "Service provider does not support the request operation.",
|
||
|
}
|
||
|
|
||
|
export class SCIMError {
|
||
|
public readonly schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"];
|
||
|
public scimType: SCIMErrorType;
|
||
|
public detail: SCIMErrorDetail | string;
|
||
|
public status: string;
|
||
|
public toApiResponse(): IApiResponse {
|
||
|
return {
|
||
|
status: parseInt(this.status, 10),
|
||
|
content: this,
|
||
|
};
|
||
|
}
|
||
|
}
|