From 17afb9a3bcc09efbc7dacd24b7539a618245e104 Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Fri, 21 Apr 2023 18:59:27 +0200 Subject: [PATCH] =?UTF-8?q?Patch=20Tuesday=20=F0=9F=90=B8=20(#18260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update `@directus/api` deps (minor) @aws-sdk/client-ses 3.292.0 → 3.316.0 @godaddy/terminus 4.11.2 → 4.12.0 @rollup/plugin-alias 4.0.3 → 4.0.4 @rollup/plugin-node-resolve 15.0.1 → 15.0.2 @types/node 18.15.3 → 18.15.11 @vitest/coverage-c8 0.29.3 → 0.30.1 axios 1.3.4 → 1.3.6 fs-extra 11.1.0 → 11.1.1 helmet 6.0.1 → 6.1.5 ioredis 5.3.1 → 5.3.2 joi 17.8.4 → 17.9.1 liquidjs 10.6.1 → 10.7.0 marked 4.2.12 → 4.3.0 nanoid 3.3.4 → 3.3.6 rollup 3.19.1 → 3.20.6 sharp 0.31.3 → 0.32.0 vitest 0.29.3 → 0.30.1 vm2 3.9.16 → 3.9.17 * Update `@directus/api` deps (major) @rollup/plugin-alias 4.0.4 → 5.0.0 @types/inquirer 8.2.6 → 9.0.3 @types/node 18.15.11 → 18.15.12 camelcase 6.3.0 → 7.0.1 chalk 4.1.2 → 5.2.0 commander 9.5.0 → 10.0.1 execa 5.1.1 → 7.1.1 icc 2.0.0 → 3.0.0 inquirer 8.2.5 → 9.1.5 ~ldapjs 2.3.3 → 3.0.2~ nanoid 3.3.6 → 4.0.2 ~openapi3-ts 3.2.0 → 4.1.1~ ora 5.4.1 → 6.3.0 strip-bom-stream 4.0.0 → 5.0.0 tedious 15.1.3 → 16.0.0 typescript 4.9.5 → 5.0.4 * Update `@directus/app` deps @babel/core 7.21.3 → 7.21.4 @babel/preset-env 7.20.2 → 7.21.4 @fortawesome/fontawesome-svg-core 6.3.0 → 6.4.0 @fortawesome/free-brands-svg-icons 6.3.0 → 6.4.0 @fullcalendar/core 6.1.4 → 6.1.5 @fullcalendar/daygrid 6.1.4 → 6.1.5 @fullcalendar/interaction 6.1.4 → 6.1.5 @fullcalendar/list 6.1.4 → 6.1.5 @fullcalendar/timegrid 6.1.4 → 6.1.5 @pinia/testing 0.0.15 → 0.0.16 @popperjs/core 2.11.6 → 2.11.7 @storybook/addon-actions 7.0.0-rc.4 → 7.0.6 @storybook/addon-backgrounds 7.0.0-rc.4 → 7.0.6 @storybook/addon-docs 7.0.0-rc.4 → 7.0.6 @storybook/addon-essentials 7.0.0-rc.4 → 7.0.6 @storybook/addon-links 7.0.0-rc.4 → 7.0.6 @storybook/addon-mdx-gfm 7.0.0-rc.4 → 7.0.6 @storybook/addon-measure 7.0.0-rc.4 → 7.0.6 @storybook/addon-outline 7.0.0-rc.4 → 7.0.6 @storybook/client-api 7.0.0-rc.4 → 7.0.6 @storybook/client-logger 7.0.0-rc.4 → 7.0.6 @storybook/vue3 7.0.0-rc.4 → 7.0.6 @storybook/vue3-vite 7.0.0-rc.4 → 7.0.6 @types/diff 5.0.2 → 5.0.3 @types/dompurify 3.0.0 → 3.0.2 @types/lodash 4.14.191 → 4.14.194 @vitejs/plugin-vue 4.0.0 → 4.1.0 @vue/test-utils 2.3.1 → 2.3.2 apexcharts 3.37.1 → 3.39.0 axios 1.3.4 → 1.3.6 dompurify 3.0.1 → 3.0.2 happy-dom 8.9.0 → 9.8.4 marked 4.2.12 → 4.3.0 nanoid 4.0.1 → 4.0.2 pinia 2.0.33 → 2.0.34 sass 1.59.3 → 1.62.0 storybook 7.0.0-rc.4 → 7.0.6 typescript 4.9.5 → 5.0.4 vite 4.1.4 → 4.2.2 vitest 0.29.3 → 0.30.1 webpack 5.76.2 → 5.80.0 * Update root deps * Update `@directus/composables` deps * Update `@directus/constant` deps * Update `create-directus-extension` deps * Update `@directus/exceptions` deps * tsconfig workaround: ignoreDeprecations * Update `@directus/extensions-sdk` deps * Update `@directus/schema` deps * Update `@directus/storage` deps * Update `@directus/storage-driver-azure` deps * Update `@directus/storage-driver-cloudinary` deps * Update `@directus/storage-driver-gcs` deps * Update `@directus/storage-driver-local` deps * Update `@directus/storage-driver-s3` deps * Update `@directus/types` deps * Update `@directus/update-check` deps * Update `@directus/utils` deps * tsconfig workaround in schema: ignoreDeprecations * tsconfig workaround in remaining packages: ignoreDeprecations * Update `tests-blackbox` deps * Revert "tsconfig workaround: ignoreDeprecations" This reverts commit 5d97da55e3ae2083c6679d88d852fb8bf1ba10c6. * Revert tsconfig override * Update tsconfig * Fix imports in @directus/utils * Fix imports in composables * Fix imports in extensions-sdk * Fix imports in @directus/api * Move RateLimiterAbstract to types import as well * Bump pnpm to 8.3.1 * Update `docs` deps > [...] the @vueuse/head package will be deprecated. If you're setting up this package on a new project, you should use the @unhead/vue package directly [...] * Remove obselete dep `concurrently` from extensions-sdk Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> * New day, new updates Also forgot to include minor updates of deps in `tests-blackbox` in previous commit * Fix `api` tests --------- Co-authored-by: Rijk van Zanten Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> --- api/package.json | 63 +- api/src/__mocks__/cache.mts | 13 +- api/src/app.ts | 3 +- api/src/auth/drivers/oauth2.ts | 3 +- api/src/auth/drivers/openid.ts | 3 +- api/src/cache.ts | 3 +- api/src/cli/commands/init/index.ts | 5 +- api/src/cli/commands/schema/apply.ts | 5 +- api/src/controllers/assets.ts | 3 +- api/src/controllers/files.ts | 3 +- api/src/controllers/schema.ts | 3 +- api/src/database/helpers/fn/dialects/mssql.ts | 3 +- api/src/database/helpers/fn/dialects/mysql.ts | 3 +- .../database/helpers/fn/dialects/oracle.ts | 3 +- .../database/helpers/fn/dialects/postgres.ts | 3 +- .../database/helpers/fn/dialects/sqlite.ts | 3 +- api/src/database/helpers/geometry/types.ts | 3 +- .../helpers/schema/dialects/cockroachdb.ts | 3 +- .../helpers/schema/dialects/oracle.ts | 3 +- api/src/database/migrations/run.test.ts | 5 +- api/src/database/run-ast.ts | 3 +- api/src/logger.test.ts | 10 +- api/src/mailer.ts | 3 +- api/src/middleware/graphql.ts | 3 +- api/src/operations/exec/index.ts | 3 +- api/src/operations/log/index.test.ts | 4 +- api/src/operations/trigger/index.test.ts | 4 +- api/src/rate-limiter.ts | 10 +- api/src/server.ts | 7 +- api/src/services/collections.ts | 7 +- api/src/services/fields.ts | 5 +- api/src/services/files.test.ts | 3 +- api/src/services/files.ts | 3 +- api/src/services/graphql/index.ts | 27 +- api/src/services/items.test.ts | 9 +- api/src/services/payload.test.ts | 8 +- api/src/services/payload.ts | 5 +- api/src/services/permissions.ts | 3 +- api/src/services/relations.ts | 8 +- api/src/services/roles.test.ts | 7 +- api/src/services/server.ts | 5 +- api/src/services/specifications.test.ts | 5 +- api/src/services/users.test.ts | 9 +- api/src/services/webhooks.test.ts | 7 +- api/src/services/webhooks.ts | 3 +- api/src/types/shims.d.ts | 4 - api/src/utils/apply-diff.ts | 6 +- api/src/utils/apply-query.ts | 3 +- api/src/utils/apply-snapshot.test.ts | 9 +- api/src/utils/get-cache-key.test.ts | 3 +- api/src/utils/get-column-path.test.ts | 3 +- api/src/utils/get-graphql-type.ts | 11 +- api/src/utils/get-snapshot-diff.ts | 3 +- api/src/utils/stall.test.ts | 3 +- api/src/utils/validate-diff.ts | 3 +- api/src/utils/validate-snapshot.ts | 11 +- app/package.json | 82 +- docs/.vitepress/theme/Layout.vue | 2 +- docs/.vitepress/theme/index.js | 2 +- docs/package.json | 9 +- package.json | 14 +- packages/composables/package.json | 12 +- packages/composables/src/use-collection.ts | 3 +- .../composables/src/use-custom-selection.ts | 3 +- packages/composables/src/use-element-size.ts | 3 +- packages/composables/src/use-filter-fields.ts | 3 +- packages/composables/src/use-groupable.ts | 3 +- packages/composables/src/use-items.test.ts | 3 +- packages/composables/src/use-items.ts | 3 +- packages/composables/src/use-layout.ts | 3 +- packages/composables/src/use-size-class.ts | 3 +- packages/composables/src/use-sync.ts | 3 +- packages/composables/src/use-system.ts | 4 +- packages/constants/package.json | 4 +- .../create-directus-extension/package.json | 2 +- packages/exceptions/package.json | 10 +- packages/extensions-sdk/create-build.test.ts | 2 +- packages/extensions-sdk/package.json | 29 +- .../extensions-sdk/src/cli/commands/add.ts | 2 +- .../extensions-sdk/src/cli/commands/build.ts | 10 +- .../extensions-sdk/src/cli/commands/create.ts | 2 +- .../src/cli/utils/get-package-version.ts | 2 +- packages/extensions-sdk/src/index.ts | 30 +- packages/schema/package.json | 4 +- packages/storage-driver-azure/package.json | 10 +- .../storage-driver-cloudinary/package.json | 10 +- packages/storage-driver-gcs/package.json | 10 +- packages/storage-driver-local/package.json | 8 +- packages/storage-driver-s3/package.json | 14 +- packages/storage/package.json | 8 +- packages/types/package.json | 4 +- packages/update-check/package.json | 12 +- .../utils/node/ensure-extension-dirs.test.ts | 6 +- packages/utils/node/list-folders.test.ts | 3 +- packages/utils/package.json | 16 +- packages/utils/shared/apply-options-data.ts | 3 +- packages/utils/shared/generate-joi.test.ts | 5 +- packages/utils/shared/generate-joi.ts | 5 +- packages/utils/shared/validate-payload.ts | 7 +- pnpm-lock.yaml | 6937 ++++++++--------- tests/blackbox/package.json | 12 +- 101 files changed, 3671 insertions(+), 4007 deletions(-) delete mode 100644 api/src/types/shims.d.ts diff --git a/api/package.json b/api/package.json index 83ed2b3c22..007a1ed9a0 100644 --- a/api/package.json +++ b/api/package.json @@ -70,7 +70,7 @@ }, "dependencies": { "@authenio/samlify-node-xmllint": "2.0.0", - "@aws-sdk/client-ses": "3.292.0", + "@aws-sdk/client-ses": "3.316.0", "@directus/app": "workspace:*", "@directus/constants": "workspace:*", "@directus/exceptions": "workspace:*", @@ -86,19 +86,19 @@ "@directus/storage-driver-s3": "workspace:*", "@directus/update-check": "workspace:*", "@directus/utils": "workspace:*", - "@godaddy/terminus": "4.11.2", - "@rollup/plugin-alias": "4.0.3", - "@rollup/plugin-node-resolve": "15.0.1", + "@godaddy/terminus": "4.12.0", + "@rollup/plugin-alias": "5.0.0", + "@rollup/plugin-node-resolve": "15.0.2", "@rollup/plugin-virtual": "3.0.1", "argon2": "0.30.3", "async": "3.2.4", - "axios": "1.3.4", + "axios": "1.3.6", "busboy": "1.6.0", "bytes": "3.1.2", - "camelcase": "6.3.0", - "chalk": "4.1.2", + "camelcase": "7.0.1", + "chalk": "5.2.0", "chokidar": "3.5.3", - "commander": "9.5.0", + "commander": "10.0.1", "content-disposition": "0.5.4", "cookie-parser": "1.4.6", "cors": "2.8.5", @@ -109,19 +109,19 @@ "dotenv": "16.0.3", "encodeurl": "1.0.2", "eventemitter2": "6.4.9", - "execa": "5.1.1", + "execa": "7.1.1", "exif-reader": "1.2.0", "express": "4.18.2", "fast-redact": "3.1.2", "flat": "5.0.2", - "fs-extra": "11.1.0", + "fs-extra": "11.1.1", "graphql": "16.6.0", "graphql-compose": "9.0.10", - "helmet": "6.0.1", - "icc": "2.0.0", - "inquirer": "8.2.5", - "ioredis": "5.3.1", - "joi": "17.8.4", + "helmet": "6.1.5", + "icc": "3.0.0", + "inquirer": "9.1.5", + "ioredis": "5.3.2", + "joi": "17.9.1", "js-yaml": "4.1.0", "js2xmlparser": "5.0.0", "json2csv": "5.0.7", @@ -129,20 +129,20 @@ "keyv": "4.5.2", "knex": "2.4.2", "ldapjs": "2.3.3", - "liquidjs": "10.6.1", + "liquidjs": "10.7.0", "lodash-es": "4.17.21", - "marked": "4.2.12", + "marked": "4.3.0", "micromustache": "8.0.3", "mime-types": "2.1.35", "ms": "2.1.3", - "nanoid": "3.3.4", + "nanoid": "4.0.2", "node-cron": "3.0.2", "node-machine-id": "1.1.12", "nodemailer": "6.9.1", "object-hash": "3.0.0", "openapi3-ts": "3.2.0", "openid-client": "5.4.0", - "ora": "5.4.1", + "ora": "6.3.0", "otplib": "12.0.1", "pino": "8.11.0", "pino-http": "8.3.3", @@ -150,13 +150,13 @@ "pino-pretty": "10.0.0", "qs": "6.11.1", "rate-limiter-flexible": "2.4.1", - "rollup": "3.19.1", + "rollup": "3.20.7", "samlify": "2.8.10", "sanitize-html": "2.10.0", - "sharp": "0.31.3", + "sharp": "0.32.0", "snappy": "7.2.2", "stream-json": "1.7.5", - "strip-bom-stream": "4.0.0", + "strip-bom-stream": "5.0.0", "tmp-promise": "3.0.3", "tsx": "3.12.6", "uuid": "9.0.0", @@ -165,10 +165,10 @@ "wellknown": "0.5.0" }, "devDependencies": { - "@directus/tsconfig": "0.0.6", + "@directus/tsconfig": "0.0.7", "@directus/types": "workspace:*", "@ngneat/falso": "6.4.0", - "@types/async": "3.2.18", + "@types/async": "3.2.19", "@types/busboy": "1.5.0", "@types/bytes": "3.1.1", "@types/content-disposition": "0.5.5", @@ -183,35 +183,34 @@ "@types/fast-redact": "3.0.2", "@types/flat": "5.0.2", "@types/fs-extra": "11.0.1", - "@types/inquirer": "8.2.6", + "@types/inquirer": "9.0.3", "@types/js-yaml": "4.0.5", "@types/json2csv": "5.0.3", "@types/jsonwebtoken": "9.0.1", - "@types/keyv": "3.1.4", + "@types/keyv": "4.2.0", "@types/ldapjs": "2.2.5", "@types/lodash-es": "4.17.7", "@types/marked": "4.0.8", "@types/mime-types": "2.1.1", "@types/ms": "0.7.31", - "@types/node": "18.15.3", + "@types/node": "18.15.13", "@types/node-cron": "3.0.7", "@types/nodemailer": "6.4.7", "@types/object-hash": "3.0.2", "@types/qs": "6.9.7", "@types/sanitize-html": "2.9.0", - "@types/sharp": "0.31.1", "@types/stream-json": "1.7.3", "@types/supertest": "2.0.12", "@types/uuid": "9.0.1", "@types/uuid-validate": "0.0.1", "@types/wellknown": "0.5.4", - "@vitest/coverage-c8": "0.29.3", + "@vitest/coverage-c8": "0.30.1", "copyfiles": "2.4.1", "form-data": "4.0.0", "knex-mock-client": "2.0.0", "supertest": "6.3.3", - "typescript": "4.9.5", - "vitest": "0.29.3" + "typescript": "5.0.4", + "vitest": "0.30.1" }, "optionalDependencies": { "@keyv/redis": "2.5.7", @@ -222,7 +221,7 @@ "nodemailer-sendgrid": "1.0.3", "pg": "8.10.0", "sqlite3": "5.1.6", - "tedious": "15.1.3" + "tedious": "16.0.0" }, "engines": { "node": ">=18.0.0" diff --git a/api/src/__mocks__/cache.mts b/api/src/__mocks__/cache.mts index e395074913..71f10055ab 100644 --- a/api/src/__mocks__/cache.mts +++ b/api/src/__mocks__/cache.mts @@ -1,5 +1,10 @@ +import type { Mock } from 'vitest'; import { vi } from 'vitest'; -export const getCache = vi.fn().mockReturnValue({ cache: undefined, systemCache: undefined, lockCache: undefined }); -export const flushCaches = vi.fn(); -export const clearSystemCache = vi.fn(); -export const setSystemCache = vi.fn(); + +export const getCache: Mock = vi + .fn() + .mockReturnValue({ cache: undefined, systemCache: undefined, lockCache: undefined }); + +export const flushCaches: Mock = vi.fn(); +export const clearSystemCache: Mock = vi.fn(); +export const setSystemCache: Mock = vi.fn(); diff --git a/api/src/app.ts b/api/src/app.ts index e851e17ae2..c39eadc2af 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -1,5 +1,6 @@ import cookieParser from 'cookie-parser'; -import express, { Request, RequestHandler, Response } from 'express'; +import type { Request, RequestHandler, Response } from 'express'; +import express from 'express'; import type { ServerResponse } from 'http'; import { merge } from 'lodash-es'; import { readFile } from 'node:fs/promises'; diff --git a/api/src/auth/drivers/oauth2.ts b/api/src/auth/drivers/oauth2.ts index 790545a141..c94f758969 100644 --- a/api/src/auth/drivers/oauth2.ts +++ b/api/src/auth/drivers/oauth2.ts @@ -4,7 +4,8 @@ import { parseJSON } from '@directus/utils'; import express, { Router } from 'express'; import flatten from 'flat'; import jwt from 'jsonwebtoken'; -import { Client, errors, generators, Issuer } from 'openid-client'; +import type { Client } from 'openid-client'; +import { errors, generators, Issuer } from 'openid-client'; import { getAuthProvider } from '../../auth.js'; import getDatabase from '../../database/index.js'; import emitter from '../../emitter.js'; diff --git a/api/src/auth/drivers/openid.ts b/api/src/auth/drivers/openid.ts index eb41d7046a..148dc4bdeb 100644 --- a/api/src/auth/drivers/openid.ts +++ b/api/src/auth/drivers/openid.ts @@ -4,7 +4,8 @@ import { parseJSON } from '@directus/utils'; import express, { Router } from 'express'; import flatten from 'flat'; import jwt from 'jsonwebtoken'; -import { Client, errors, generators, Issuer } from 'openid-client'; +import type { Client } from 'openid-client'; +import { errors, generators, Issuer } from 'openid-client'; import { getAuthProvider } from '../../auth.js'; import getDatabase from '../../database/index.js'; import emitter from '../../emitter.js'; diff --git a/api/src/cache.ts b/api/src/cache.ts index 18849634d5..e7ad5334f2 100644 --- a/api/src/cache.ts +++ b/api/src/cache.ts @@ -1,6 +1,7 @@ import type { SchemaOverview } from '@directus/types'; import { getSimpleHash } from '@directus/utils'; -import Keyv, { Options } from 'keyv'; +import type { Options } from 'keyv'; +import Keyv from 'keyv'; import env from './env.js'; import logger from './logger.js'; import { getMessenger } from './messenger.js'; diff --git a/api/src/cli/commands/init/index.ts b/api/src/cli/commands/init/index.ts index 532a899173..851b2cb781 100644 --- a/api/src/cli/commands/init/index.ts +++ b/api/src/cli/commands/init/index.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import execa from 'execa'; +import { execa } from 'execa'; import inquirer from 'inquirer'; import Joi from 'joi'; import type { Knex } from 'knex'; @@ -8,7 +8,8 @@ import { v4 as uuid } from 'uuid'; import runMigrations from '../../../database/migrations/run.js'; import runSeed from '../../../database/seeds/run.js'; import { generateHash } from '../../../utils/generate-hash.js'; -import createDBConnection, { Credentials } from '../../utils/create-db-connection.js'; +import type { Credentials } from '../../utils/create-db-connection.js'; +import createDBConnection from '../../utils/create-db-connection.js'; import createEnv from '../../utils/create-env/index.js'; import { defaultAdminRole, defaultAdminUser } from '../../utils/defaults.js'; import { drivers, getDriverForClient } from '../../utils/drivers.js'; diff --git a/api/src/cli/commands/schema/apply.ts b/api/src/cli/commands/schema/apply.ts index b676aa31c1..eea7202302 100644 --- a/api/src/cli/commands/schema/apply.ts +++ b/api/src/cli/commands/schema/apply.ts @@ -6,11 +6,12 @@ import { load as loadYaml } from 'js-yaml'; import path from 'path'; import getDatabase, { isInstalled, validateDatabaseConnection } from '../../../database/index.js'; import logger from '../../../logger.js'; -import { DiffKind, Snapshot } from '../../../types/index.js'; +import type { Snapshot } from '../../../types/index.js'; +import { DiffKind } from '../../../types/index.js'; import { isNestedMetaUpdate } from '../../../utils/apply-diff.js'; import { applySnapshot } from '../../../utils/apply-snapshot.js'; -import { getSnapshot } from '../../../utils/get-snapshot.js'; import { getSnapshotDiff } from '../../../utils/get-snapshot-diff.js'; +import { getSnapshot } from '../../../utils/get-snapshot.js'; export async function apply(snapshotPath: string, options?: { yes: boolean; dryRun: boolean }): Promise { const filename = path.resolve(process.cwd(), snapshotPath); diff --git a/api/src/controllers/assets.ts b/api/src/controllers/assets.ts index 95b2c5ac70..474405aa5d 100644 --- a/api/src/controllers/assets.ts +++ b/api/src/controllers/assets.ts @@ -11,7 +11,8 @@ import logger from '../logger.js'; import useCollection from '../middleware/use-collection.js'; import { AssetsService } from '../services/assets.js'; import { PayloadService } from '../services/payload.js'; -import { TransformationMethods, TransformationParams } from '../types/assets.js'; +import type { TransformationParams } from '../types/assets.js'; +import { TransformationMethods } from '../types/assets.js'; import asyncHandler from '../utils/async-handler.js'; import { getCacheControlHeader } from '../utils/get-cache-headers.js'; import { getConfigFromEnv } from '../utils/get-config-from-env.js'; diff --git a/api/src/controllers/files.ts b/api/src/controllers/files.ts index a6a85b4308..cdfd013dec 100644 --- a/api/src/controllers/files.ts +++ b/api/src/controllers/files.ts @@ -1,7 +1,8 @@ import formatTitle from '@directus/format-title'; import { toArray } from '@directus/utils'; import Busboy from 'busboy'; -import express, { RequestHandler } from 'express'; +import type { RequestHandler } from 'express'; +import express from 'express'; import Joi from 'joi'; import path from 'path'; import env from '../env.js'; diff --git a/api/src/controllers/schema.ts b/api/src/controllers/schema.ts index f4775b2537..5aaba0f03b 100644 --- a/api/src/controllers/schema.ts +++ b/api/src/controllers/schema.ts @@ -1,6 +1,7 @@ import { parseJSON } from '@directus/utils'; import Busboy from 'busboy'; -import express, { RequestHandler } from 'express'; +import type { RequestHandler } from 'express'; +import express from 'express'; import { load as loadYaml } from 'js-yaml'; import { InvalidPayloadException, UnsupportedMediaTypeException } from '../exceptions/index.js'; import logger from '../logger.js'; diff --git a/api/src/database/helpers/fn/dialects/mssql.ts b/api/src/database/helpers/fn/dialects/mssql.ts index 881a355bdc..e64dd53651 100644 --- a/api/src/database/helpers/fn/dialects/mssql.ts +++ b/api/src/database/helpers/fn/dialects/mssql.ts @@ -1,5 +1,6 @@ import type { Knex } from 'knex'; -import { FnHelper, FnHelperOptions } from '../types.js'; +import type { FnHelperOptions } from '../types.js'; +import { FnHelper } from '../types.js'; const parseLocaltime = (columnType?: string) => { if (columnType === 'timestamp') { diff --git a/api/src/database/helpers/fn/dialects/mysql.ts b/api/src/database/helpers/fn/dialects/mysql.ts index cee885da1e..b11e818acd 100644 --- a/api/src/database/helpers/fn/dialects/mysql.ts +++ b/api/src/database/helpers/fn/dialects/mysql.ts @@ -1,5 +1,6 @@ import type { Knex } from 'knex'; -import { FnHelper, FnHelperOptions } from '../types.js'; +import type { FnHelperOptions } from '../types.js'; +import { FnHelper } from '../types.js'; export class FnHelperMySQL extends FnHelper { year(table: string, column: string): Knex.Raw { diff --git a/api/src/database/helpers/fn/dialects/oracle.ts b/api/src/database/helpers/fn/dialects/oracle.ts index 139a415681..b5dd3b7e41 100644 --- a/api/src/database/helpers/fn/dialects/oracle.ts +++ b/api/src/database/helpers/fn/dialects/oracle.ts @@ -1,5 +1,6 @@ import type { Knex } from 'knex'; -import { FnHelper, FnHelperOptions } from '../types.js'; +import type { FnHelperOptions } from '../types.js'; +import { FnHelper } from '../types.js'; const parseLocaltime = (columnType?: string) => { if (columnType === 'timestamp') { diff --git a/api/src/database/helpers/fn/dialects/postgres.ts b/api/src/database/helpers/fn/dialects/postgres.ts index 17ec933847..ab172196b9 100644 --- a/api/src/database/helpers/fn/dialects/postgres.ts +++ b/api/src/database/helpers/fn/dialects/postgres.ts @@ -1,5 +1,6 @@ import type { Knex } from 'knex'; -import { FnHelper, FnHelperOptions } from '../types.js'; +import type { FnHelperOptions } from '../types.js'; +import { FnHelper } from '../types.js'; const parseLocaltime = (columnType?: string) => { if (columnType === 'timestamp') { diff --git a/api/src/database/helpers/fn/dialects/sqlite.ts b/api/src/database/helpers/fn/dialects/sqlite.ts index bb73b99538..b76293600d 100644 --- a/api/src/database/helpers/fn/dialects/sqlite.ts +++ b/api/src/database/helpers/fn/dialects/sqlite.ts @@ -1,5 +1,6 @@ import type { Knex } from 'knex'; -import { FnHelper, FnHelperOptions } from '../types.js'; +import type { FnHelperOptions } from '../types.js'; +import { FnHelper } from '../types.js'; const parseLocaltime = (columnType?: string) => { if (columnType === 'timestamp') { diff --git a/api/src/database/helpers/geometry/types.ts b/api/src/database/helpers/geometry/types.ts index a81f78ef85..9fe081fa46 100644 --- a/api/src/database/helpers/geometry/types.ts +++ b/api/src/database/helpers/geometry/types.ts @@ -1,6 +1,7 @@ import type { Field, RawField } from '@directus/types'; import type { Knex } from 'knex'; -import { GeoJSONGeometry, stringify as geojsonToWKT } from 'wellknown'; +import type { GeoJSONGeometry } from 'wellknown'; +import { stringify as geojsonToWKT } from 'wellknown'; import { DatabaseHelper } from '../types.js'; export abstract class GeometryHelper extends DatabaseHelper { diff --git a/api/src/database/helpers/schema/dialects/cockroachdb.ts b/api/src/database/helpers/schema/dialects/cockroachdb.ts index bde511190f..cd9423aaec 100644 --- a/api/src/database/helpers/schema/dialects/cockroachdb.ts +++ b/api/src/database/helpers/schema/dialects/cockroachdb.ts @@ -1,5 +1,6 @@ import type { KNEX_TYPES } from '@directus/constants'; -import { Options, SchemaHelper } from '../types.js'; +import type { Options } from '../types.js'; +import { SchemaHelper } from '../types.js'; export class SchemaHelperCockroachDb extends SchemaHelper { override async changeToType( diff --git a/api/src/database/helpers/schema/dialects/oracle.ts b/api/src/database/helpers/schema/dialects/oracle.ts index 1b6c412223..2b2a315522 100644 --- a/api/src/database/helpers/schema/dialects/oracle.ts +++ b/api/src/database/helpers/schema/dialects/oracle.ts @@ -1,6 +1,7 @@ import type { KNEX_TYPES } from '@directus/constants'; import type { Field, Relation, Type } from '@directus/types'; -import { Options, SchemaHelper } from '../types.js'; +import type { Options } from '../types.js'; +import { SchemaHelper } from '../types.js'; export class SchemaHelperOracle extends SchemaHelper { override async changeToType( diff --git a/api/src/database/migrations/run.test.ts b/api/src/database/migrations/run.test.ts index d12cbce16e..5a17833570 100644 --- a/api/src/database/migrations/run.test.ts +++ b/api/src/database/migrations/run.test.ts @@ -1,8 +1,9 @@ -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; +import type { MockedFunction } from 'vitest'; +import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'; import run from './run.js'; -import { describe, beforeAll, afterEach, it, expect, MockedFunction, vi } from 'vitest'; describe('run', () => { let db: MockedFunction; diff --git a/api/src/database/run-ast.ts b/api/src/database/run-ast.ts index e9a8b7f387..01f22ba5f5 100644 --- a/api/src/database/run-ast.ts +++ b/api/src/database/run-ast.ts @@ -7,7 +7,8 @@ import env from '../env.js'; import { PayloadService } from '../services/payload.js'; import type { AST, FieldNode, FunctionFieldNode, M2ONode, NestedCollectionNode } from '../types/ast.js'; import { applyFunctionToColumnName } from '../utils/apply-function-to-column-name.js'; -import applyQuery, { applyLimit, applySort, ColumnSortRecord, generateAlias } from '../utils/apply-query.js'; +import type { ColumnSortRecord } from '../utils/apply-query.js'; +import applyQuery, { applyLimit, applySort, generateAlias } from '../utils/apply-query.js'; import { getCollectionFromAlias } from '../utils/get-collection-from-alias.js'; import type { AliasMap } from '../utils/get-column-path.js'; import { getColumn } from '../utils/get-column.js'; diff --git a/api/src/logger.test.ts b/api/src/logger.test.ts index 9118fe8ee4..9f430d53bb 100644 --- a/api/src/logger.test.ts +++ b/api/src/logger.test.ts @@ -1,8 +1,11 @@ +import { Writable } from 'node:stream'; +import { pino } from 'pino'; import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; +import { REDACT_TEXT } from './constants.js'; const REFRESH_TOKEN_COOKIE_NAME = 'directus_refresh_token'; -vi.mock('./env', async () => { +vi.doMock('./env', async () => { const MOCK_ENV = { AUTH_PROVIDERS: 'ranger,monospace', AUTH_RANGER_DRIVER: 'oauth2', @@ -18,10 +21,7 @@ vi.mock('./env', async () => { }; }); -import { Writable } from 'node:stream'; -import { pino } from 'pino'; -import { REDACT_TEXT } from './constants.js'; -import { httpLoggerOptions } from './logger.js'; +const { httpLoggerOptions } = await import('./logger.js'); const logOutput = vi.fn(); diff --git a/api/src/mailer.ts b/api/src/mailer.ts index 25ca038ce2..6b74d50732 100644 --- a/api/src/mailer.ts +++ b/api/src/mailer.ts @@ -1,4 +1,5 @@ -import nodemailer, { Transporter } from 'nodemailer'; +import type { Transporter } from 'nodemailer'; +import nodemailer from 'nodemailer'; import env from './env.js'; import logger from './logger.js'; import { getConfigFromEnv } from './utils/get-config-from-env.js'; diff --git a/api/src/middleware/graphql.ts b/api/src/middleware/graphql.ts index 5dc2e72a0a..3c09736f4b 100644 --- a/api/src/middleware/graphql.ts +++ b/api/src/middleware/graphql.ts @@ -1,6 +1,7 @@ import { parseJSON } from '@directus/utils'; import type { RequestHandler } from 'express'; -import { DocumentNode, getOperationAST, parse, Source } from 'graphql'; +import type { DocumentNode } from 'graphql'; +import { getOperationAST, parse, Source } from 'graphql'; import { InvalidPayloadException, InvalidQueryException, MethodNotAllowedException } from '../exceptions/index.js'; import type { GraphQLParams } from '../types/index.js'; import asyncHandler from '../utils/async-handler.js'; diff --git a/api/src/operations/exec/index.ts b/api/src/operations/exec/index.ts index 8aeff598de..facc0c307d 100644 --- a/api/src/operations/exec/index.ts +++ b/api/src/operations/exec/index.ts @@ -1,6 +1,7 @@ import { defineOperationApi, toArray } from '@directus/utils'; -import { NodeVM, NodeVMOptions, VMScript } from 'vm2'; import { isBuiltin } from 'node:module'; +import type { NodeVMOptions } from 'vm2'; +import { NodeVM, VMScript } from 'vm2'; type Options = { code: string; diff --git a/api/src/operations/log/index.test.ts b/api/src/operations/log/index.test.ts index 63092e8598..23fafd17c5 100644 --- a/api/src/operations/log/index.test.ts +++ b/api/src/operations/log/index.test.ts @@ -2,13 +2,13 @@ import { afterEach, expect, test, vi } from 'vitest'; const loggerInfo = vi.fn(); -vi.mock('../../logger', () => ({ +vi.doMock('../../logger', () => ({ default: { info: loggerInfo, }, })); -import config from './index.js'; +const { default: config } = await import('./index.js'); afterEach(() => { vi.clearAllMocks(); diff --git a/api/src/operations/trigger/index.test.ts b/api/src/operations/trigger/index.test.ts index b89a898fcf..588535cc75 100644 --- a/api/src/operations/trigger/index.test.ts +++ b/api/src/operations/trigger/index.test.ts @@ -2,13 +2,13 @@ import { afterEach, expect, test, vi } from 'vitest'; const runOperationFlow = vi.fn(); -vi.mock('../../flows.js', () => ({ +vi.doMock('../../flows.js', () => ({ getFlowManager: vi.fn().mockReturnValue({ runOperationFlow, }), })); -import config from './index.js'; +const { default: config } = await import('./index.js'); const testFlowId = '00000000-0000-0000-0000-000000000000'; diff --git a/api/src/rate-limiter.ts b/api/src/rate-limiter.ts index 6690a3a829..75e43fb069 100644 --- a/api/src/rate-limiter.ts +++ b/api/src/rate-limiter.ts @@ -1,12 +1,6 @@ import { merge } from 'lodash-es'; -import { - IRateLimiterOptions, - IRateLimiterStoreOptions, - RateLimiterAbstract, - RateLimiterMemcache, - RateLimiterMemory, - RateLimiterRedis, -} from 'rate-limiter-flexible'; +import type { IRateLimiterOptions, IRateLimiterStoreOptions, RateLimiterAbstract } from 'rate-limiter-flexible'; +import { RateLimiterMemcache, RateLimiterMemory, RateLimiterRedis } from 'rate-limiter-flexible'; import env from './env.js'; import { getConfigFromEnv } from './utils/get-config-from-env.js'; diff --git a/api/src/server.ts b/api/src/server.ts index 57bc74f3a2..888101b440 100644 --- a/api/src/server.ts +++ b/api/src/server.ts @@ -1,18 +1,19 @@ -import { createTerminus, TerminusOptions } from '@godaddy/terminus'; +import { isUpToDate } from '@directus/update-check'; +import type { TerminusOptions } from '@godaddy/terminus'; +import { createTerminus } from '@godaddy/terminus'; import type { Request } from 'express'; import * as http from 'http'; import * as https from 'https'; import { once } from 'lodash-es'; import qs from 'qs'; -import { isUpToDate } from '@directus/update-check'; import url from 'url'; -import * as pkg from './utils/package.js'; import createApp from './app.js'; import getDatabase from './database/index.js'; import emitter from './emitter.js'; import env from './env.js'; import logger from './logger.js'; import { getConfigFromEnv } from './utils/get-config-from-env.js'; +import * as pkg from './utils/package.js'; export let SERVER_ONLINE = true; diff --git a/api/src/services/collections.ts b/api/src/services/collections.ts index 9d8dc5a098..b29f9f25bc 100644 --- a/api/src/services/collections.ts +++ b/api/src/services/collections.ts @@ -1,14 +1,15 @@ +import type { SchemaInspector, Table } from '@directus/schema'; import { createInspector } from '@directus/schema'; import type { Accountability, FieldMeta, RawField, SchemaOverview } from '@directus/types'; import { addFieldFlag } from '@directus/utils'; import type Keyv from 'keyv'; import type { Knex } from 'knex'; -import type { Table, SchemaInspector } from '@directus/schema'; -import { omit, chunk } from 'lodash-es'; +import { chunk, omit } from 'lodash-es'; import { clearSystemCache, getCache } from '../cache.js'; import { ALIAS_TYPES } from '../constants.js'; +import type { Helpers } from '../database/helpers/index.js'; +import { getHelpers } from '../database/helpers/index.js'; import getDatabase, { getSchemaInspector } from '../database/index.js'; -import { getHelpers, Helpers } from '../database/helpers/index.js'; import { systemCollectionRows } from '../database/system-data/collections/index.js'; import emitter from '../emitter.js'; import env from '../env.js'; diff --git a/api/src/services/fields.ts b/api/src/services/fields.ts index a0ca9cfa17..13edb77f64 100644 --- a/api/src/services/fields.ts +++ b/api/src/services/fields.ts @@ -1,6 +1,6 @@ +import { KNEX_TYPES, REGEX_BETWEEN_PARENS } from '@directus/constants'; import type { Column, SchemaInspector } from '@directus/schema'; import { createInspector } from '@directus/schema'; -import { KNEX_TYPES, REGEX_BETWEEN_PARENS } from '@directus/constants'; import type { Accountability, Field, FieldMeta, RawField, SchemaOverview, Type } from '@directus/types'; import { addFieldFlag, toArray } from '@directus/utils'; import type Keyv from 'keyv'; @@ -8,7 +8,8 @@ import type { Knex } from 'knex'; import { isEqual, isNil } from 'lodash-es'; import { clearSystemCache, getCache } from '../cache.js'; import { ALIAS_TYPES } from '../constants.js'; -import { getHelpers, Helpers } from '../database/helpers/index.js'; +import type { Helpers } from '../database/helpers/index.js'; +import { getHelpers } from '../database/helpers/index.js'; import getDatabase, { getSchemaInspector } from '../database/index.js'; import { systemFieldRows } from '../database/system-data/fields/index.js'; import emitter from '../emitter.js'; diff --git a/api/src/services/files.test.ts b/api/src/services/files.test.ts index 64f59cfc6f..fe145ab223 100644 --- a/api/src/services/files.test.ts +++ b/api/src/services/files.test.ts @@ -1,7 +1,8 @@ import type { Knex } from 'knex'; import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, MockedFunction, SpyInstance, vi } from 'vitest'; +import type { MockedFunction, SpyInstance } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { InvalidPayloadException } from '../exceptions/index.js'; import { FilesService, ItemsService } from './index.js'; diff --git a/api/src/services/files.ts b/api/src/services/files.ts index 27b65a5038..9de69a02dd 100644 --- a/api/src/services/files.ts +++ b/api/src/services/files.ts @@ -2,6 +2,7 @@ import formatTitle from '@directus/format-title'; import { toArray } from '@directus/utils'; import encodeURL from 'encodeurl'; import exif from 'exif-reader'; +import type { IccProfile } from 'icc'; import { parse as parseIcc } from 'icc'; import { clone, pick } from 'lodash-es'; import { extension } from 'mime-types'; @@ -166,7 +167,7 @@ export class FilesService extends ItemsService { exif?: Record; gps?: Record; interop?: Record; - icc?: Record; + icc?: IccProfile; iptc?: Record; xmp?: Record; } = {}; diff --git a/api/src/services/graphql/index.ts b/api/src/services/graphql/index.ts index 3fdd31e024..4f9a3bed7a 100644 --- a/api/src/services/graphql/index.ts +++ b/api/src/services/graphql/index.ts @@ -1,16 +1,21 @@ -import { FUNCTIONS } from '@directus/constants'; +import { Action, FUNCTIONS } from '@directus/constants'; import type { BaseException } from '@directus/exceptions'; import type { Accountability, Aggregate, Filter, PrimaryKey, Query, SchemaOverview } from '@directus/types'; -import { Action } from '@directus/constants'; import { parseFilterFunctionPath } from '@directus/utils'; import argon2 from 'argon2'; -import { +import type { ArgumentNode, - execute, ExecutionResult, FieldNode, FormattedExecutionResult, FragmentDefinitionNode, + GraphQLNullableType, + GraphQLResolveInfo, + InlineFragmentNode, + SelectionNode, + ValueNode, +} from 'graphql'; +import { GraphQLBoolean, GraphQLEnumType, GraphQLError, @@ -19,32 +24,24 @@ import { GraphQLInt, GraphQLList, GraphQLNonNull, - GraphQLNullableType, GraphQLObjectType, - GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, - InlineFragmentNode, NoSchemaIntrospectionCustomRule, - SelectionNode, + execute, specifiedRules, validate, - ValueNode, } from 'graphql'; -import { - GraphQLJSON, - InputTypeComposer, +import type { InputTypeComposerFieldConfigMapDefinition, - ObjectTypeComposer, ObjectTypeComposerFieldConfigAsObjectDefinition, ObjectTypeComposerFieldConfigDefinition, ObjectTypeComposerFieldConfigMapDefinition, ResolverDefinition, - SchemaComposer, - toInputObjectType, } from 'graphql-compose'; +import { GraphQLJSON, InputTypeComposer, ObjectTypeComposer, SchemaComposer, toInputObjectType } from 'graphql-compose'; import type { Knex } from 'knex'; import { flatten, get, mapKeys, merge, omit, pick, set, transform, uniq } from 'lodash-es'; import { clearSystemCache, getCache } from '../../cache.js'; diff --git a/api/src/services/items.test.ts b/api/src/services/items.test.ts index 784b6df855..564c383dc7 100644 --- a/api/src/services/items.test.ts +++ b/api/src/services/items.test.ts @@ -1,14 +1,15 @@ import type { CollectionsOverview, NestedDeepQuery } from '@directus/types'; -import knex from 'knex'; import type { Knex } from 'knex'; -import { createTracker, MockClient, Tracker } from 'knex-mock-client'; +import knex from 'knex'; +import { MockClient, Tracker, createTracker } from 'knex-mock-client'; import { cloneDeep } from 'lodash-es'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, MockedFunction, vi } from 'vitest'; +import type { MockedFunction } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { getDatabaseClient } from '../../src/database/index.js'; import { ItemsService } from '../../src/services/index.js'; -import { InvalidPayloadException } from '../exceptions/index.js'; import { sqlFieldFormatter, sqlFieldList } from '../__utils__/items-utils.js'; import { systemSchema, userSchema } from '../__utils__/schemas.js'; +import { InvalidPayloadException } from '../exceptions/index.js'; vi.mock('../env', async () => { const actual = (await vi.importActual('../env')) as { default: Record }; diff --git a/api/src/services/payload.test.ts b/api/src/services/payload.test.ts index 3204760e6b..069123ba2e 100644 --- a/api/src/services/payload.test.ts +++ b/api/src/services/payload.test.ts @@ -1,9 +1,11 @@ -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { MockClient, Tracker, createTracker } from 'knex-mock-client'; +import type { MockedFunction } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; +import type { Helpers } from '../../src/database/helpers/index.js'; +import { getHelpers } from '../../src/database/helpers/index.js'; import { PayloadService } from '../../src/services/index.js'; -import { getHelpers, Helpers } from '../../src/database/helpers/index.js'; -import { describe, beforeAll, afterEach, it, expect, vi, beforeEach, MockedFunction } from 'vitest'; vi.mock('../../src/database/index', () => ({ getDatabaseClient: vi.fn().mockReturnValue('postgres'), diff --git a/api/src/services/payload.ts b/api/src/services/payload.ts index 0d285ed54e..4fe3a867c3 100644 --- a/api/src/services/payload.ts +++ b/api/src/services/payload.ts @@ -1,14 +1,15 @@ import type { Accountability, Query, SchemaOverview } from '@directus/types'; -import { format, parseISO, isValid } from 'date-fns'; import { parseJSON, toArray } from '@directus/utils'; +import { format, isValid, parseISO } from 'date-fns'; import flat from 'flat'; import Joi from 'joi'; import type { Knex } from 'knex'; import { clone, cloneDeep, isNil, isObject, isPlainObject, omit, pick } from 'lodash-es'; import { v4 as uuid } from 'uuid'; import { parse as wktToGeoJSON } from 'wellknown'; +import type { Helpers } from '../database/helpers/index.js'; +import { getHelpers } from '../database/helpers/index.js'; import getDatabase from '../database/index.js'; -import { getHelpers, Helpers } from '../database/helpers/index.js'; import { ForbiddenException, InvalidPayloadException } from '../exceptions/index.js'; import type { AbstractServiceOptions, diff --git a/api/src/services/permissions.ts b/api/src/services/permissions.ts index edaa1617b6..530b343174 100644 --- a/api/src/services/permissions.ts +++ b/api/src/services/permissions.ts @@ -2,7 +2,8 @@ import type { PermissionsAction, Query } from '@directus/types'; import type Keyv from 'keyv'; import { clearSystemCache, getCache } from '../cache.js'; import { appAccessMinimalPermissions } from '../database/system-data/app-access-permissions/index.js'; -import { ItemsService, QueryOptions } from '../services/items.js'; +import type { QueryOptions } from '../services/items.js'; +import { ItemsService } from '../services/items.js'; import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types/index.js'; import { filterItems } from '../utils/filter-items.js'; diff --git a/api/src/services/relations.ts b/api/src/services/relations.ts index 3d1eae49e2..e69edf3997 100644 --- a/api/src/services/relations.ts +++ b/api/src/services/relations.ts @@ -1,19 +1,21 @@ +import type { ForeignKey, SchemaInspector } from '@directus/schema'; import { createInspector } from '@directus/schema'; import type { Accountability, Query, Relation, RelationMeta, SchemaOverview } from '@directus/types'; import { toArray } from '@directus/utils'; import type Keyv from 'keyv'; import type { Knex } from 'knex'; -import type { ForeignKey, SchemaInspector } from '@directus/schema'; import { clearSystemCache, getCache } from '../cache.js'; +import type { Helpers } from '../database/helpers/index.js'; +import { getHelpers } from '../database/helpers/index.js'; import getDatabase, { getSchemaInspector } from '../database/index.js'; -import { getHelpers, Helpers } from '../database/helpers/index.js'; import { systemRelationRows } from '../database/system-data/relations/index.js'; import emitter from '../emitter.js'; import { ForbiddenException, InvalidPayloadException } from '../exceptions/index.js'; import type { AbstractServiceOptions, ActionEventParams, MutationOptions } from '../types/index.js'; import { getDefaultIndexName } from '../utils/get-default-index-name.js'; import { getSchema } from '../utils/get-schema.js'; -import { ItemsService, QueryOptions } from './items.js'; +import type { QueryOptions } from './items.js'; +import { ItemsService } from './items.js'; import { PermissionsService } from './permissions.js'; export class RelationsService { diff --git a/api/src/services/roles.test.ts b/api/src/services/roles.test.ts index c88ece1de2..ceef27bd08 100644 --- a/api/src/services/roles.test.ts +++ b/api/src/services/roles.test.ts @@ -1,10 +1,11 @@ import type { SchemaOverview } from '@directus/types'; -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, MockedFunction, SpyInstance, vi } from 'vitest'; -import { ItemsService, PermissionsService, PresetsService, RolesService, UsersService } from './index.js'; +import type { MockedFunction, SpyInstance } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { ForbiddenException, UnprocessableEntityException } from '../exceptions/index.js'; +import { ItemsService, PermissionsService, PresetsService, RolesService, UsersService } from './index.js'; vi.mock('../../src/database/index', () => { return { __esModule: true, default: vi.fn(), getDatabaseClient: vi.fn().mockReturnValue('postgres') }; diff --git a/api/src/services/server.ts b/api/src/services/server.ts index 241c973e50..def178ed07 100644 --- a/api/src/services/server.ts +++ b/api/src/services/server.ts @@ -201,7 +201,8 @@ export class ServerService { checks[`${client}:responseTime`]![0]!.observedValue = +(endTime - startTime).toFixed(3); if ( - checks[`${client}:responseTime`]![0]!.observedValue! > checks[`${client}:responseTime`]![0]!.threshold! && + Number(checks[`${client}:responseTime`]![0]!.observedValue!) > + checks[`${client}:responseTime`]![0]!.threshold! && checks[`${client}:responseTime`]![0]!.status !== 'error' ) { checks[`${client}:responseTime`]![0]!.status = 'warn'; @@ -388,7 +389,7 @@ export class ServerService { checks[`storage:${location}:responseTime`]![0]!.observedValue = +(endTime - startTime).toFixed(3); if ( - checks[`storage:${location}:responseTime`]![0]!.observedValue! > + Number(checks[`storage:${location}:responseTime`]![0]!.observedValue!) > checks[`storage:${location}:responseTime`]![0]!.threshold! && checks[`storage:${location}:responseTime`]![0]!.status !== 'error' ) { diff --git a/api/src/services/specifications.test.ts b/api/src/services/specifications.test.ts index 70de6854ec..ec640aa018 100644 --- a/api/src/services/specifications.test.ts +++ b/api/src/services/specifications.test.ts @@ -1,7 +1,8 @@ -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, MockedFunction, vi } from 'vitest'; +import type { MockedFunction } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { CollectionsService, FieldsService, RelationsService, SpecificationService } from '../../src/services/index.js'; import type { Collection } from '../types/index.js'; diff --git a/api/src/services/users.test.ts b/api/src/services/users.test.ts index 30b504a941..079f7fc3d7 100644 --- a/api/src/services/users.test.ts +++ b/api/src/services/users.test.ts @@ -1,11 +1,12 @@ import type { SchemaOverview } from '@directus/types'; -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, MockedFunction, SpyInstance, vi } from 'vitest'; -import { ItemsService, MailService, UsersService } from './index.js'; -import { ForbiddenException, InvalidPayloadException } from '../exceptions/index.js'; +import type { MockedFunction, SpyInstance } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { RecordNotUniqueException } from '../exceptions/database/record-not-unique.js'; +import { ForbiddenException, InvalidPayloadException } from '../exceptions/index.js'; +import { ItemsService, MailService, UsersService } from './index.js'; vi.mock('../../src/database/index', () => ({ default: vi.fn(), diff --git a/api/src/services/webhooks.test.ts b/api/src/services/webhooks.test.ts index fae32793f5..7980f8823a 100644 --- a/api/src/services/webhooks.test.ts +++ b/api/src/services/webhooks.test.ts @@ -1,9 +1,10 @@ -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeAll, beforeEach, describe, expect, it, SpyInstance, vi } from 'vitest'; -import { WebhooksService } from './index.js'; +import type { SpyInstance } from 'vitest'; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { getMessenger } from '../messenger.js'; +import { WebhooksService } from './index.js'; vi.mock('../../src/database/index', () => { return { __esModule: true, default: vi.fn(), getDatabaseClient: vi.fn().mockReturnValue('postgres') }; diff --git a/api/src/services/webhooks.ts b/api/src/services/webhooks.ts index 3d855667af..5cd2ffb212 100644 --- a/api/src/services/webhooks.ts +++ b/api/src/services/webhooks.ts @@ -1,4 +1,5 @@ -import { getMessenger, Messenger } from '../messenger.js'; +import type { Messenger } from '../messenger.js'; +import { getMessenger } from '../messenger.js'; import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey, Webhook } from '../types/index.js'; import { ItemsService } from './items.js'; diff --git a/api/src/types/shims.d.ts b/api/src/types/shims.d.ts deleted file mode 100644 index 861bc8e33a..0000000000 --- a/api/src/types/shims.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'icc' { - const parse: (buf: Buffer) => Record; - export { parse }; -} diff --git a/api/src/utils/apply-diff.ts b/api/src/utils/apply-diff.ts index 0a16c808dd..404d29ba3c 100644 --- a/api/src/utils/apply-diff.ts +++ b/api/src/utils/apply-diff.ts @@ -4,23 +4,23 @@ import deepDiff from 'deep-diff'; import type { Knex } from 'knex'; import { cloneDeep, merge, set } from 'lodash-es'; import { clearSystemCache } from '../cache.js'; +import { getHelpers } from '../database/helpers/index.js'; import getDatabase from '../database/index.js'; import emitter from '../emitter.js'; import logger from '../logger.js'; import { CollectionsService } from '../services/collections.js'; import { FieldsService } from '../services/fields.js'; import { RelationsService } from '../services/relations.js'; -import { +import type { ActionEventParams, Collection, - DiffKind, MutationOptions, Snapshot, SnapshotDiff, SnapshotField, } from '../types/index.js'; +import { DiffKind } from '../types/index.js'; import { getSchema } from './get-schema.js'; -import { getHelpers } from '../database/helpers/index.js'; type CollectionDelta = { collection: string; diff --git a/api/src/utils/apply-query.ts b/api/src/utils/apply-query.ts index fb9d2eb56a..fad5834349 100644 --- a/api/src/utils/apply-query.ts +++ b/api/src/utils/apply-query.ts @@ -15,8 +15,9 @@ import { clone, isPlainObject } from 'lodash-es'; import validate from 'uuid-validate'; import { getHelpers } from '../database/helpers/index.js'; import { InvalidQueryException } from '../exceptions/invalid-query.js'; +import type { AliasMap } from './get-column-path.js'; +import { getColumnPath } from './get-column-path.js'; import { getColumn } from './get-column.js'; -import { AliasMap, getColumnPath } from './get-column-path.js'; import { getRelationInfo } from './get-relation-info.js'; import { stripFunction } from './strip-function.js'; diff --git a/api/src/utils/apply-snapshot.test.ts b/api/src/utils/apply-snapshot.test.ts index 4a4c610b40..aca58bc25c 100644 --- a/api/src/utils/apply-snapshot.test.ts +++ b/api/src/utils/apply-snapshot.test.ts @@ -1,9 +1,8 @@ -import knex from 'knex'; import type { Knex } from 'knex'; +import knex from 'knex'; import { createTracker, MockClient, Tracker } from 'knex-mock-client'; -import { afterEach, beforeEach, describe, expect, it, MockedFunction, vi } from 'vitest'; -import { CollectionsService, FieldsService } from '../services/index.js'; -import type { Snapshot, SnapshotField } from '../types/index.js'; +import type { MockedFunction } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { snapshotApplyTestSchema } from '../__utils__/schemas.js'; import { snapshotBeforeCreateCollection, @@ -11,6 +10,8 @@ import { snapshotCreateCollection, snapshotCreateCollectionNotNested, } from '../__utils__/snapshots.js'; +import { CollectionsService, FieldsService } from '../services/index.js'; +import type { Snapshot, SnapshotField } from '../types/index.js'; import { applySnapshot } from './apply-snapshot.js'; import * as getSchema from './get-schema.js'; diff --git a/api/src/utils/get-cache-key.test.ts b/api/src/utils/get-cache-key.test.ts index fe93c55e4a..d9d48f33ec 100644 --- a/api/src/utils/get-cache-key.test.ts +++ b/api/src/utils/get-cache-key.test.ts @@ -1,5 +1,6 @@ import type { Request } from 'express'; -import { afterEach, beforeAll, describe, expect, SpyInstance, test, vi } from 'vitest'; +import type { SpyInstance } from 'vitest'; +import { afterEach, beforeAll, describe, expect, test, vi } from 'vitest'; import { getCacheKey } from './get-cache-key.js'; import * as getGraphqlQueryUtil from './get-graphql-query-and-variables.js'; diff --git a/api/src/utils/get-column-path.test.ts b/api/src/utils/get-column-path.test.ts index f70ccbc94a..bbad220cec 100644 --- a/api/src/utils/get-column-path.test.ts +++ b/api/src/utils/get-column-path.test.ts @@ -1,7 +1,8 @@ import type { DeepPartial } from '@directus/types'; import { expect, test } from 'vitest'; import { InvalidQueryException } from '../../src/exceptions/index.js'; -import { ColPathProps, getColumnPath } from '../../src/utils/get-column-path.js'; +import type { ColPathProps } from '../../src/utils/get-column-path.js'; +import { getColumnPath } from '../../src/utils/get-column-path.js'; /* { diff --git a/api/src/utils/get-graphql-type.ts b/api/src/utils/get-graphql-type.ts index acec3878cc..b28e18da21 100644 --- a/api/src/utils/get-graphql-type.ts +++ b/api/src/utils/get-graphql-type.ts @@ -1,13 +1,6 @@ import type { Type } from '@directus/types'; -import { - GraphQLBoolean, - GraphQLFloat, - GraphQLInt, - GraphQLList, - GraphQLScalarType, - GraphQLString, - GraphQLType, -} from 'graphql'; +import type { GraphQLType } from 'graphql'; +import { GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLList, GraphQLScalarType, GraphQLString } from 'graphql'; import { GraphQLJSON } from 'graphql-compose'; import { GraphQLBigInt } from '../services/graphql/types/bigint.js'; import { GraphQLDate } from '../services/graphql/types/date.js'; diff --git a/api/src/utils/get-snapshot-diff.ts b/api/src/utils/get-snapshot-diff.ts index cf6dd62c06..c0789dd672 100644 --- a/api/src/utils/get-snapshot-diff.ts +++ b/api/src/utils/get-snapshot-diff.ts @@ -1,6 +1,7 @@ import deepDiff from 'deep-diff'; import { orderBy } from 'lodash-es'; -import { Snapshot, SnapshotDiff, DiffKind } from '../types/index.js'; +import type { Snapshot, SnapshotDiff } from '../types/index.js'; +import { DiffKind } from '../types/index.js'; import { sanitizeCollection, sanitizeField, sanitizeRelation } from './sanitize-schema.js'; export function getSnapshotDiff(current: Snapshot, after: Snapshot): SnapshotDiff { diff --git a/api/src/utils/stall.test.ts b/api/src/utils/stall.test.ts index e09dfe7ffe..7e0163778d 100644 --- a/api/src/utils/stall.test.ts +++ b/api/src/utils/stall.test.ts @@ -1,4 +1,5 @@ -import { afterAll, beforeAll, expect, SpyInstance, test, vi } from 'vitest'; +import type { SpyInstance } from 'vitest'; +import { afterAll, beforeAll, expect, test, vi } from 'vitest'; import { stall } from './stall.js'; let performanceNowSpy: SpyInstance; diff --git a/api/src/utils/validate-diff.ts b/api/src/utils/validate-diff.ts index 85fae185d5..35dfdc7cb9 100644 --- a/api/src/utils/validate-diff.ts +++ b/api/src/utils/validate-diff.ts @@ -1,6 +1,7 @@ import Joi from 'joi'; import { InvalidPayloadException } from '../exceptions/invalid-payload.js'; -import { DiffKind, SnapshotDiffWithHash, SnapshotWithHash } from '../types/snapshot.js'; +import type { SnapshotDiffWithHash, SnapshotWithHash } from '../types/snapshot.js'; +import { DiffKind } from '../types/snapshot.js'; const deepDiffSchema = Joi.object({ kind: Joi.string() diff --git a/api/src/utils/validate-snapshot.ts b/api/src/utils/validate-snapshot.ts index 784b6fad9a..122e23de3e 100644 --- a/api/src/utils/validate-snapshot.ts +++ b/api/src/utils/validate-snapshot.ts @@ -1,10 +1,11 @@ -import { version as currentDirectusVersion } from './package.js'; -import { InvalidPayloadException } from '../exceptions/invalid-payload.js'; -import { getDatabaseClient } from '../database/index.js'; -import Joi from 'joi'; import { TYPES } from '@directus/constants'; +import Joi from 'joi'; import { ALIAS_TYPES } from '../constants.js'; -import { DatabaseClients, Snapshot } from '../types/index.js'; +import { getDatabaseClient } from '../database/index.js'; +import { InvalidPayloadException } from '../exceptions/invalid-payload.js'; +import type { Snapshot } from '../types/index.js'; +import { DatabaseClients } from '../types/index.js'; +import { version as currentDirectusVersion } from './package.js'; const snapshotJoiSchema = Joi.object({ version: Joi.number().valid(1).required(), diff --git a/app/package.json b/app/package.json index f66a725d50..9678ed784f 100644 --- a/app/package.json +++ b/app/package.json @@ -27,64 +27,64 @@ "test": "vitest --watch=false" }, "devDependencies": { - "@babel/core": "7.21.3", - "@babel/preset-env": "7.20.2", + "@babel/core": "7.21.4", + "@babel/preset-env": "7.21.4", "@directus/constants": "workspace:*", "@directus/exceptions": "workspace:*", "@directus/extensions-sdk": "workspace:*", "@directus/format-title": "10.0.0", "@directus/types": "workspace:*", "@directus/utils": "workspace:*", - "@fortawesome/fontawesome-svg-core": "6.3.0", - "@fortawesome/free-brands-svg-icons": "6.3.0", - "@fullcalendar/core": "6.1.4", - "@fullcalendar/daygrid": "6.1.4", - "@fullcalendar/interaction": "6.1.4", - "@fullcalendar/list": "6.1.4", - "@fullcalendar/timegrid": "6.1.4", + "@fortawesome/fontawesome-svg-core": "6.4.0", + "@fortawesome/free-brands-svg-icons": "6.4.0", + "@fullcalendar/core": "6.1.5", + "@fullcalendar/daygrid": "6.1.5", + "@fullcalendar/interaction": "6.1.5", + "@fullcalendar/list": "6.1.5", + "@fullcalendar/timegrid": "6.1.5", "@joeattardi/emoji-button": "4.6.4", "@mapbox/mapbox-gl-draw": "1.4.1", "@mapbox/mapbox-gl-draw-static-mode": "1.0.1", "@mapbox/mapbox-gl-geocoder": "5.0.1", - "@pinia/testing": "0.0.15", - "@popperjs/core": "2.11.6", + "@pinia/testing": "0.0.16", + "@popperjs/core": "2.11.7", "@rollup/plugin-yaml": "4.0.1", "@sindresorhus/slugify": "2.2.0", - "@storybook/addon-actions": "7.0.0-rc.4", - "@storybook/addon-backgrounds": "7.0.0-rc.4", - "@storybook/addon-docs": "7.0.0-rc.4", - "@storybook/addon-essentials": "7.0.0-rc.4", - "@storybook/addon-links": "7.0.0-rc.4", - "@storybook/addon-mdx-gfm": "7.0.0-rc.4", - "@storybook/addon-measure": "7.0.0-rc.4", - "@storybook/addon-outline": "7.0.0-rc.4", - "@storybook/client-api": "7.0.0-rc.4", - "@storybook/client-logger": "7.0.0-rc.4", - "@storybook/vue3": "7.0.0-rc.4", - "@storybook/vue3-vite": "7.0.0-rc.4", + "@storybook/addon-actions": "7.0.6", + "@storybook/addon-backgrounds": "7.0.6", + "@storybook/addon-docs": "7.0.6", + "@storybook/addon-essentials": "7.0.6", + "@storybook/addon-links": "7.0.6", + "@storybook/addon-mdx-gfm": "7.0.6", + "@storybook/addon-measure": "7.0.6", + "@storybook/addon-outline": "7.0.6", + "@storybook/client-api": "7.0.6", + "@storybook/client-logger": "7.0.6", + "@storybook/vue3": "7.0.6", + "@storybook/vue3-vite": "7.0.6", "@tinymce/tinymce-vue": "5.1.0", "@turf/meta": "6.5.0", "@types/base-64": "1.0.0", "@types/codemirror": "5.60.7", "@types/color": "3.0.3", "@types/diacritics": "1.3.1", - "@types/diff": "5.0.2", - "@types/dompurify": "3.0.0", + "@types/diff": "5.0.3", + "@types/dompurify": "3.0.2", "@types/file-saver": "2.0.5", "@types/geojson": "7946.0.10", "@types/json2csv": "5.0.3", - "@types/lodash": "4.14.191", + "@types/lodash": "4.14.194", "@types/mapbox__mapbox-gl-draw": "1.3.3", "@types/mapbox__mapbox-gl-geocoder": "4.7.3", "@types/marked": "4.0.8", "@types/mime": "3.0.1", "@types/qrcode": "1.5.0", "@types/wellknown": "0.5.4", - "@vitejs/plugin-vue": "4.0.0", + "@vitejs/plugin-vue": "4.1.0", "@vue/compiler-sfc": "3.2.47", - "@vue/test-utils": "2.3.1", - "apexcharts": "3.37.1", - "axios": "1.3.4", + "@vue/test-utils": "2.3.2", + "apexcharts": "3.39.0", + "axios": "1.3.6", "babel-loader": "9", "base-64": "1.0.0", "c8": "7.13.0", @@ -95,12 +95,12 @@ "date-fns": "2.29.3", "diacritics": "1.3.0", "diff": "5.1.0", - "dompurify": "3.0.1", + "dompurify": "3.0.2", "escape-string-regexp": "5.0.0", "file-saver": "2.0.5", "flatpickr": "4.6.13", "geojson": "0.5.0", - "happy-dom": "8.9.0", + "happy-dom": "9.8.4", "html-entities": "2.3.3", "json-to-graphql-query": "2.2.5", "json2csv": "5.0.7", @@ -108,29 +108,29 @@ "lodash": "4.17.21", "mapbox-gl": "1.13.3", "maplibre-gl": "1.15.3", - "marked": "4.2.12", + "marked": "4.3.0", "micromustache": "8.0.3", "mime": "3.0.0", "mitt": "3.0.0", - "nanoid": "4.0.1", + "nanoid": "4.0.2", "p-queue": "7.3.4", - "pinia": "2.0.33", + "pinia": "2.0.35", "pretty-bytes": "6.1.0", "pretty-ms": "8.0.0", "qrcode": "1.5.1", "react": "18", "react-dom": "18", - "sass": "1.59.3", - "storybook": "7.0.0-rc.4", + "sass": "1.62.0", + "storybook": "7.0.6", "tinymce": "6.4.1", - "typescript": "4.9.5", - "vite": "4.1.4", - "vitest": "0.29.3", + "typescript": "5.0.4", + "vite": "4.3.1", + "vitest": "0.30.1", "vue": "3.2.47", "vue-i18n": "9.2.2", "vue-router": "4.1.6", "vuedraggable": "4.1.0", - "webpack": "5.76.2", + "webpack": "5.80.0", "wellknown": "0.5.0" }, "publishConfig": { diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/Layout.vue index 83130df3da..18a3bd9613 100644 --- a/docs/.vitepress/theme/Layout.vue +++ b/docs/.vitepress/theme/Layout.vue @@ -1,6 +1,6 @@