mirror of
https://github.com/directus/directus.git
synced 2026-02-09 09:15:57 -05:00
The Great TypeScript Modernization Program Season 3 Episode 6: The Big One (#18014)
* Step 1 * Step 2 * False sense of confidence * Couple more before dinner * Update schema package * Update format-title * Upgrade specs file * Close * Replace ts-node-dev with tsx, and various others * Replace lodash with lodash-es * Add lodash-es types * Update knex import * More fun is had * FSE * Consolidate repos * Various tweaks and fixes * Fix specs * Remove dependency on knex-schema-inspector * Fix wrong imports of inspector * Move shared exceptions to new package * Move constants to separate module * Move types to new types package * Use directus/types * I believe this is no longer needed * [WIP] Start moving utils to esm * ESMify Shared * Move shared utils to @directus/utils * Use @directus/utils instead of @directus/shared/utils * It runs! * Use correct schemaoverview type * Fix imports * Fix the thing * Start on new update-checker lib * Use new update-check package * Swap out directus/shared in app * Pushing through the last bits now * Dangerously make extensions SDK ESM * Use @directus/types in tests * Copy util function to test * Fix linter config * Add missing import * Hot takes * Fix build * Curse these default exports * No tests in constants * Add tests * Remove tests from types * Add tests for exceptions * Fix test * Fix app tests * Fix import in test * Fix various tests * Fix specs export * Some more tests * Remove broken integration tests These were broken beyond repair.. They were also written before we really knew what we we're doing with tests, so I think it's better to say goodbye and start over with these * Regenerate lockfile * Fix imports from merge * I create my own problems * Make sharp play nice * Add vitest config * Install missing blackbox dep * Consts shouldn't be in types tsk tsk tsk tsk * Fix type/const usage in extensions-sdk * cursed.default * Reduce circular deps * Fix circular dep in items service * vvv * Trigger testing for all vendors * Add workaround for rollup * Prepend the file protocol for the ESM loader to be compatible with Windows "WARN: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'" * Fix postgres * Schema package updates Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> * Resolve cjs/mjs extensions * Clean-up eslint config * fixed extension concatination * using string interpolation for consistency * Revert MySQL optimisation * Revert testing for all vendors * Replace tsx with esbuild-kit/esm-loader Is a bit faster and we can rely on the built-in `watch` and `inspect` functionalities of Node.js Note: The possibility to watch other files (.env in our case) might be added in the future, see https://github.com/nodejs/node/issues/45467 * Use exact version for esbuild-kit/esm-loader * Fix import --------- Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Exceptions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import getDatabase from '../../../database';
|
||||
import { ContainsNullValuesException } from '../contains-null-values';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key';
|
||||
import { NotNullViolationException } from '../not-null-violation';
|
||||
import { RecordNotUniqueException } from '../record-not-unique';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range';
|
||||
import { ValueTooLongException } from '../value-too-long';
|
||||
import type { MSSQLError } from './types';
|
||||
import getDatabase from '../../../database/index.js';
|
||||
import { ContainsNullValuesException } from '../contains-null-values.js';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key.js';
|
||||
import { NotNullViolationException } from '../not-null-violation.js';
|
||||
import { RecordNotUniqueException } from '../record-not-unique.js';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range.js';
|
||||
import { ValueTooLongException } from '../value-too-long.js';
|
||||
import type { MSSQLError } from './types.js';
|
||||
|
||||
enum MSSQLErrorCodes {
|
||||
FOREIGN_KEY_VIOLATION = 547,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ContainsNullValuesException } from '../contains-null-values';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key';
|
||||
import { NotNullViolationException } from '../not-null-violation';
|
||||
import { RecordNotUniqueException } from '../record-not-unique';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range';
|
||||
import { ValueTooLongException } from '../value-too-long';
|
||||
import type { MySQLError } from './types';
|
||||
import { ContainsNullValuesException } from '../contains-null-values.js';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key.js';
|
||||
import { NotNullViolationException } from '../not-null-violation.js';
|
||||
import { RecordNotUniqueException } from '../record-not-unique.js';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range.js';
|
||||
import { ValueTooLongException } from '../value-too-long.js';
|
||||
import type { MySQLError } from './types.js';
|
||||
|
||||
enum MySQLErrorCodes {
|
||||
UNIQUE_VIOLATION = 'ER_DUP_ENTRY',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ContainsNullValuesException } from '../contains-null-values';
|
||||
import type { OracleError } from './types';
|
||||
import { ContainsNullValuesException } from '../contains-null-values.js';
|
||||
import type { OracleError } from './types.js';
|
||||
|
||||
enum OracleErrorCodes {
|
||||
'CONTAINS_NULL_VALUES' = 2296,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ContainsNullValuesException } from '../contains-null-values';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key';
|
||||
import { NotNullViolationException } from '../not-null-violation';
|
||||
import { RecordNotUniqueException } from '../record-not-unique';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range';
|
||||
import { ValueTooLongException } from '../value-too-long';
|
||||
import type { PostgresError } from './types';
|
||||
import { ContainsNullValuesException } from '../contains-null-values.js';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key.js';
|
||||
import { NotNullViolationException } from '../not-null-violation.js';
|
||||
import { RecordNotUniqueException } from '../record-not-unique.js';
|
||||
import { ValueOutOfRangeException } from '../value-out-of-range.js';
|
||||
import { ValueTooLongException } from '../value-too-long.js';
|
||||
import type { PostgresError } from './types.js';
|
||||
|
||||
enum PostgresErrorCodes {
|
||||
FOREIGN_KEY_VIOLATION = '23503',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ContainsNullValuesException } from '../contains-null-values';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key';
|
||||
import { NotNullViolationException } from '../not-null-violation';
|
||||
import { RecordNotUniqueException } from '../record-not-unique';
|
||||
import type { SQLiteError } from './types';
|
||||
import { ContainsNullValuesException } from '../contains-null-values.js';
|
||||
import { InvalidForeignKeyException } from '../invalid-foreign-key.js';
|
||||
import { NotNullViolationException } from '../not-null-violation.js';
|
||||
import { RecordNotUniqueException } from '../record-not-unique.js';
|
||||
import type { SQLiteError } from './types.js';
|
||||
|
||||
// NOTE:
|
||||
// - Sqlite doesn't have varchar with length support, so no ValueTooLongException
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Exceptions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import getDatabase, { getDatabaseClient } from '../../database';
|
||||
import emitter from '../../emitter';
|
||||
import { extractError as mssql } from './dialects/mssql';
|
||||
import { extractError as mysql } from './dialects/mysql';
|
||||
import { extractError as oracle } from './dialects/oracle';
|
||||
import { extractError as postgres } from './dialects/postgres';
|
||||
import { extractError as sqlite } from './dialects/sqlite';
|
||||
import type { SQLError } from './dialects/types';
|
||||
import getDatabase, { getDatabaseClient } from '../../database/index.js';
|
||||
import emitter from '../../emitter.js';
|
||||
import { extractError as mssql } from './dialects/mssql.js';
|
||||
import { extractError as mysql } from './dialects/mysql.js';
|
||||
import { extractError as oracle } from './dialects/oracle.js';
|
||||
import { extractError as postgres } from './dialects/postgres.js';
|
||||
import { extractError as sqlite } from './dialects/sqlite.js';
|
||||
import type { SQLError } from './dialects/types.js';
|
||||
|
||||
/**
|
||||
* Translates an error thrown by any of the databases into a pre-defined Exception. Currently
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Exceptions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
collection: string;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import * as exceptions from '@directus/exceptions';
|
||||
const { BaseException } = exceptions;
|
||||
|
||||
export class ForbiddenException extends BaseException {
|
||||
constructor() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import * as sharedExceptions from '@directus/exceptions';
|
||||
|
||||
export class GraphQLValidationException extends BaseException {
|
||||
export class GraphQLValidationException extends sharedExceptions.BaseException {
|
||||
constructor(extensions: Record<string, any>) {
|
||||
super('GraphQL validation error.', 400, 'GRAPHQL_VALIDATION_EXCEPTION', extensions);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
limit: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class IllegalAssetTransformation extends BaseException {
|
||||
constructor(message: string) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
export * from './forbidden';
|
||||
export * from './graphql-validation';
|
||||
export * from './hit-rate-limit';
|
||||
export * from './illegal-asset-transformation';
|
||||
export * from './invalid-config';
|
||||
export * from './invalid-credentials';
|
||||
export * from './invalid-ip';
|
||||
export * from './invalid-otp';
|
||||
export * from './invalid-payload';
|
||||
export * from './invalid-provider';
|
||||
export * from './invalid-query';
|
||||
export * from './invalid-token';
|
||||
export * from './method-not-allowed';
|
||||
export * from './range-not-satisfiable';
|
||||
export * from './route-not-found';
|
||||
export * from './service-unavailable';
|
||||
export * from './token-expired';
|
||||
export * from './unprocessable-entity';
|
||||
export * from './unsupported-media-type';
|
||||
export * from './user-suspended';
|
||||
export * from './unexpected-response';
|
||||
export * from './forbidden.js';
|
||||
export * from './graphql-validation.js';
|
||||
export * from './hit-rate-limit.js';
|
||||
export * from './illegal-asset-transformation.js';
|
||||
export * from './invalid-config.js';
|
||||
export * from './invalid-credentials.js';
|
||||
export * from './invalid-ip.js';
|
||||
export * from './invalid-otp.js';
|
||||
export * from './invalid-payload.js';
|
||||
export * from './invalid-provider.js';
|
||||
export * from './invalid-query.js';
|
||||
export * from './invalid-token.js';
|
||||
export * from './method-not-allowed.js';
|
||||
export * from './range-not-satisfiable.js';
|
||||
export * from './route-not-found.js';
|
||||
export * from './service-unavailable.js';
|
||||
export * from './token-expired.js';
|
||||
export * from './unprocessable-entity.js';
|
||||
export * from './unsupported-media-type.js';
|
||||
export * from './user-suspended.js';
|
||||
export * from './unexpected-response.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidConfigException extends BaseException {
|
||||
constructor(message = 'Invalid config', extensions?: Record<string, any>) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidCredentialsException extends BaseException {
|
||||
constructor(message = 'Invalid user credentials.') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidIPException extends BaseException {
|
||||
constructor(message = 'Invalid IP address.') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidOTPException extends BaseException {
|
||||
constructor(message = 'Invalid user OTP.') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidPayloadException extends BaseException {
|
||||
constructor(message: string, extensions?: Record<string, unknown>) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidProviderException extends BaseException {
|
||||
constructor(message = 'Invalid provider.') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidQueryException extends BaseException {
|
||||
constructor(message: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class InvalidTokenException extends BaseException {
|
||||
constructor(message = 'Invalid token') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
allow: string[];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/49721
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
import type { Range } from '@directus/storage';
|
||||
|
||||
export class RangeNotSatisfiableException extends BaseException {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class RouteNotFoundException extends BaseException {
|
||||
constructor(path: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
type Extensions = {
|
||||
service: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class TokenExpiredException extends BaseException {
|
||||
constructor(message = 'Token expired.') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class UnexpectedResponseException extends BaseException {
|
||||
constructor(message: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class UnprocessableEntityException extends BaseException {
|
||||
constructor(message: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class UnsupportedMediaTypeException extends BaseException {
|
||||
constructor(message: string, extensions?: Record<string, unknown>) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseException } from '@directus/shared/exceptions';
|
||||
import { BaseException } from '@directus/exceptions';
|
||||
|
||||
export class UserSuspendedException extends BaseException {
|
||||
constructor(message = 'User suspended.') {
|
||||
|
||||
Reference in New Issue
Block a user