This repository has been archived on 2024-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
rocketchat-scim/scim/Error.ts
2022-02-14 14:03:16 +01:00

50 lines
2 KiB
TypeScript

import { HttpStatusCode } from "@rocket.chat/apps-engine/definition/accessors";
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 setScimType(scimType: SCIMErrorType): SCIMError {
this.scimType = scimType;
return this;
}
public setStatus(status: HttpStatusCode): SCIMError {
this.status = `${status}`;
return this;
}
public setDetail(detail: SCIMErrorDetail | string): SCIMError {
this.detail = detail;
return this;
}
}