Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@directus/errors

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/errors - npm Package Compare versions

Comparing version 0.4.0-rc.1 to 0.4.0

10

dist/index.d.ts

@@ -19,2 +19,3 @@ import { Range } from '@directus/storage';

IllegalAssetTransformation = "ILLEGAL_ASSET_TRANSFORMATION",
Internal = "INTERNAL_SERVER_ERROR",
InvalidCredentials = "INVALID_CREDENTIALS",

@@ -178,7 +179,6 @@ InvalidForeignKey = "INVALID_FOREIGN_KEY",

interface ForbiddenErrorExtensions {
reason: string;
}
declare const ForbiddenError: DirectusErrorConstructor<void | ForbiddenErrorExtensions>;
declare const ForbiddenError: DirectusErrorConstructor<void>;
declare const InternalServerError: DirectusErrorConstructor<void>;
declare const InvalidCredentialsError: DirectusErrorConstructor<void>;

@@ -207,2 +207,2 @@

export { ContainsNullValuesError, ContentTooLargeError, type DirectusError, type DirectusErrorConstructor, ErrorCode, ForbiddenError, HitRateLimitError, IllegalAssetTransformationError, InvalidCredentialsError, InvalidForeignKeyError, InvalidIpError, InvalidOtpError, InvalidPayloadError, InvalidProviderConfigError, InvalidProviderError, InvalidQueryError, InvalidTokenError, LimitExceededError, MethodNotAllowedError, NotNullViolationError, OutOfDateError, RangeNotSatisfiableError, RecordNotUniqueError, RouteNotFoundError, ServiceUnavailableError, TokenExpiredError, UnexpectedResponseError, UnprocessableContentError, UnsupportedMediaTypeError, UserSuspendedError, ValueOutOfRangeError, ValueTooLongError, createError, isDirectusError };
export { ContainsNullValuesError, ContentTooLargeError, type DirectusError, type DirectusErrorConstructor, ErrorCode, ForbiddenError, HitRateLimitError, IllegalAssetTransformationError, InternalServerError, InvalidCredentialsError, InvalidForeignKeyError, InvalidIpError, InvalidOtpError, InvalidPayloadError, InvalidProviderConfigError, InvalidProviderError, InvalidQueryError, InvalidTokenError, LimitExceededError, MethodNotAllowedError, NotNullViolationError, OutOfDateError, RangeNotSatisfiableError, RecordNotUniqueError, RouteNotFoundError, ServiceUnavailableError, TokenExpiredError, UnexpectedResponseError, UnprocessableContentError, UnsupportedMediaTypeError, UserSuspendedError, ValueOutOfRangeError, ValueTooLongError, createError, isDirectusError };

@@ -25,2 +25,3 @@ // src/create-error.ts

ErrorCode2["IllegalAssetTransformation"] = "ILLEGAL_ASSET_TRANSFORMATION";
ErrorCode2["Internal"] = "INTERNAL_SERVER_ERROR";
ErrorCode2["InvalidCredentials"] = "INVALID_CREDENTIALS";

@@ -75,11 +76,7 @@ ErrorCode2["InvalidForeignKey"] = "INVALID_FOREIGN_KEY";

// src/errors/forbidden.ts
var messageConstructor2 = (ext) => {
if (ext?.reason) return ext.reason;
return `You don't have permission to access this.`;
};
var ForbiddenError = createError("FORBIDDEN" /* Forbidden */, messageConstructor2, 403);
var ForbiddenError = createError("FORBIDDEN" /* Forbidden */, `You don't have permission to access this.`, 403);
// src/errors/hit-rate-limit.ts
import ms from "ms";
var messageConstructor3 = (extensions) => {
var messageConstructor2 = (extensions) => {
const msBeforeNext = extensions.reset.getTime() - Date.now();

@@ -90,3 +87,3 @@ return `Too many requests, retry after ${ms(msBeforeNext)}.`;

"REQUESTS_EXCEEDED" /* RequestsExceeded */,
messageConstructor3,
messageConstructor2,
429

@@ -102,2 +99,5 @@ );

// src/errors/internal.ts
var InternalServerError = createError("INTERNAL_SERVER_ERROR" /* Internal */, `An unexpected error occurred.`);
// src/errors/invalid-credentials.ts

@@ -107,3 +107,3 @@ var InvalidCredentialsError = createError("INVALID_CREDENTIALS" /* InvalidCredentials */, "Invalid user credentials.", 401);

// src/errors/invalid-foreign-key.ts
var messageConstructor4 = ({ collection, field }) => {
var messageConstructor3 = ({ collection, field }) => {
let message = "Invalid foreign key";

@@ -121,3 +121,3 @@ if (field) {

"INVALID_FOREIGN_KEY" /* InvalidForeignKey */,
messageConstructor4,
messageConstructor3,
400

@@ -133,6 +133,6 @@ );

// src/errors/invalid-payload.ts
var messageConstructor5 = ({ reason }) => `Invalid payload. ${reason}.`;
var messageConstructor4 = ({ reason }) => `Invalid payload. ${reason}.`;
var InvalidPayloadError = createError(
"INVALID_PAYLOAD" /* InvalidPayload */,
messageConstructor5,
messageConstructor4,
400

@@ -152,6 +152,6 @@ );

// src/errors/invalid-query.ts
var messageConstructor6 = ({ reason }) => `Invalid query. ${reason}.`;
var messageConstructor5 = ({ reason }) => `Invalid query. ${reason}.`;
var InvalidQueryError = createError(
"INVALID_QUERY" /* InvalidQuery */,
messageConstructor6,
messageConstructor5,
400

@@ -164,3 +164,3 @@ );

// src/errors/limit-exceeded.ts
var messageConstructor7 = ({ category }) => {
var messageConstructor6 = ({ category }) => {
return `${category} limit exceeded.`;

@@ -170,3 +170,3 @@ };

"LIMIT_EXCEEDED" /* LimitExceeded */,
messageConstructor7,
messageConstructor6,
403

@@ -176,6 +176,6 @@ );

// src/errors/method-not-allowed.ts
var messageConstructor8 = (extensions) => `Invalid method "${extensions.current}" used. Should be one of ${extensions.allowed.map((method) => `"${method}"`).join(", ")}.`;
var messageConstructor7 = (extensions) => `Invalid method "${extensions.current}" used. Should be one of ${extensions.allowed.map((method) => `"${method}"`).join(", ")}.`;
var MethodNotAllowedError = createError(
"METHOD_NOT_ALLOWED" /* MethodNotAllowed */,
messageConstructor8,
messageConstructor7,
405

@@ -185,3 +185,3 @@ );

// src/errors/not-null-violation.ts
var messageConstructor9 = ({ collection, field }) => {
var messageConstructor8 = ({ collection, field }) => {
let message = "Value ";

@@ -199,3 +199,3 @@ if (field) {

"NOT_NULL_VIOLATION" /* NotNullViolation */,
messageConstructor9,
messageConstructor8,
400

@@ -212,3 +212,3 @@ );

// src/errors/range-not-satisfiable.ts
var messageConstructor10 = ({ range }) => {
var messageConstructor9 = ({ range }) => {
const rangeString = `"${range.start ?? ""}-${range.end ?? ""}"`;

@@ -219,3 +219,3 @@ return `Range ${rangeString} is invalid or the file's size doesn't match the requested range.`;

"RANGE_NOT_SATISFIABLE" /* RangeNotSatisfiable */,
messageConstructor10,
messageConstructor9,
416

@@ -225,3 +225,3 @@ );

// src/errors/record-not-unique.ts
var messageConstructor11 = ({ collection, field }) => {
var messageConstructor10 = ({ collection, field }) => {
let message = "Value ";

@@ -239,3 +239,3 @@ if (field) {

"RECORD_NOT_UNIQUE" /* RecordNotUnique */,
messageConstructor11,
messageConstructor10,
400

@@ -245,10 +245,10 @@ );

// src/errors/route-not-found.ts
var messageConstructor12 = ({ path }) => `Route ${path} doesn't exist.`;
var RouteNotFoundError = createError("ROUTE_NOT_FOUND" /* RouteNotFound */, messageConstructor12, 404);
var messageConstructor11 = ({ path }) => `Route ${path} doesn't exist.`;
var RouteNotFoundError = createError("ROUTE_NOT_FOUND" /* RouteNotFound */, messageConstructor11, 404);
// src/errors/service-unavailable.ts
var messageConstructor13 = ({ service, reason }) => `Service "${service}" is unavailable. ${reason}.`;
var messageConstructor12 = ({ service, reason }) => `Service "${service}" is unavailable. ${reason}.`;
var ServiceUnavailableError = createError(
"SERVICE_UNAVAILABLE" /* ServiceUnavailable */,
messageConstructor13,
messageConstructor12,
503

@@ -268,6 +268,6 @@ );

// src/errors/unprocessable-content.ts
var messageConstructor14 = (extensions) => `Can't process content. ${extensions.reason}.`;
var messageConstructor13 = (extensions) => `Can't process content. ${extensions.reason}.`;
var UnprocessableContentError = createError(
"UNPROCESSABLE_CONTENT" /* UnprocessableContent */,
messageConstructor14,
messageConstructor13,
422

@@ -277,6 +277,6 @@ );

// src/errors/unsupported-media-type.ts
var messageConstructor15 = (extensions) => `Unsupported media type "${extensions.mediaType}" in ${extensions.where}.`;
var messageConstructor14 = (extensions) => `Unsupported media type "${extensions.mediaType}" in ${extensions.where}.`;
var UnsupportedMediaTypeError = createError(
"UNSUPPORTED_MEDIA_TYPE" /* UnsupportedMediaType */,
messageConstructor15,
messageConstructor14,
415

@@ -289,3 +289,3 @@ );

// src/errors/value-out-of-range.ts
var messageConstructor16 = ({ collection, field }) => {
var messageConstructor15 = ({ collection, field }) => {
let message = "Numeric value ";

@@ -303,3 +303,3 @@ if (field) {

"VALUE_OUT_OF_RANGE" /* ValueOutOfRange */,
messageConstructor16,
messageConstructor15,
400

@@ -309,3 +309,3 @@ );

// src/errors/value-too-long.ts
var messageConstructor17 = ({ collection, field }) => {
var messageConstructor16 = ({ collection, field }) => {
let message = "Value ";

@@ -323,3 +323,3 @@ if (field) {

"VALUE_TOO_LONG" /* ValueTooLong */,
messageConstructor17,
messageConstructor16,
400

@@ -334,2 +334,3 @@ );

IllegalAssetTransformationError,
InternalServerError,
InvalidCredentialsError,

@@ -336,0 +337,0 @@ InvalidForeignKeyError,

{
"name": "@directus/errors",
"version": "0.4.0-rc.1",
"version": "0.4.0",
"description": "Create consistent error objects around the codebase",

@@ -30,7 +30,7 @@ "repository": {

"@vitest/coverage-v8": "1.5.3",
"tsup": "8.1.0",
"tsup": "8.2.2",
"typescript": "5.4.5",
"vitest": "1.5.3",
"@directus/tsconfig": "1.0.1",
"@directus/random": "0.2.8"
"@directus/random": "0.2.8",
"@directus/tsconfig": "1.0.1"
},

@@ -37,0 +37,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc