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

@directus/errors

Package Overview
Dependencies
Maintainers
0
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.3.2 to 0.4.0-rc.0

6

dist/index.d.ts

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

field: string | null;
primaryKey?: boolean;
}

@@ -177,3 +178,6 @@ declare const RecordNotUniqueError: DirectusErrorConstructor<RecordNotUniqueErrorExtensions>;

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

@@ -180,0 +184,0 @@ declare const InvalidCredentialsError: DirectusErrorConstructor<void>;

66

dist/index.js

@@ -74,7 +74,11 @@ // src/create-error.ts

// src/errors/forbidden.ts
var ForbiddenError = createError("FORBIDDEN" /* Forbidden */, `You don't have permission to access this.`, 403);
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);
// src/errors/hit-rate-limit.ts
import ms from "ms";
var messageConstructor2 = (extensions) => {
var messageConstructor3 = (extensions) => {
const msBeforeNext = extensions.reset.getTime() - Date.now();

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

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

@@ -101,3 +105,3 @@ );

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

@@ -115,3 +119,3 @@ if (field) {

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

@@ -127,6 +131,6 @@ );

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

@@ -146,6 +150,6 @@ );

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

@@ -158,3 +162,3 @@ );

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

@@ -164,3 +168,3 @@ };

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

@@ -170,6 +174,6 @@ );

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

@@ -179,3 +183,3 @@ );

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

@@ -193,3 +197,3 @@ if (field) {

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

@@ -206,3 +210,3 @@ );

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

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

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

@@ -219,3 +223,3 @@ );

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

@@ -233,3 +237,3 @@ if (field) {

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

@@ -239,10 +243,10 @@ );

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

@@ -262,6 +266,6 @@ );

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

@@ -271,6 +275,6 @@ );

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

@@ -283,3 +287,3 @@ );

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

@@ -297,3 +301,3 @@ if (field) {

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

@@ -303,3 +307,3 @@ );

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

@@ -317,3 +321,3 @@ if (field) {

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

@@ -320,0 +324,0 @@ );

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

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

"@vitest/coverage-v8": "1.5.3",
"tsup": "8.0.2",
"tsup": "8.1.0",
"typescript": "5.4.5",

@@ -33,0 +33,0 @@ "vitest": "1.5.3",

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