diff --git a/api/src/constants.ts b/api/src/constants.ts index 889a792792..3bbf2d5e45 100644 --- a/api/src/constants.ts +++ b/api/src/constants.ts @@ -43,5 +43,3 @@ export const FILTER_VARIABLES = ['$NOW', '$CURRENT_USER', '$CURRENT_ROLE']; export const ALIAS_TYPES = ['alias', 'o2m', 'm2m', 'm2a', 'files', 'files', 'translations']; export const COLUMN_TRANSFORMS = ['year', 'month', 'day', 'weekday', 'hour', 'minute', 'second']; - -export const REGEX_BETWEEN_PARENS = /\(([^)]+)\)/; diff --git a/api/src/extensions.ts b/api/src/extensions.ts index 3385f98fd1..39432e45aa 100644 --- a/api/src/extensions.ts +++ b/api/src/extensions.ts @@ -20,7 +20,7 @@ import { getSchema } from './utils/get-schema'; import * as services from './services'; import { schedule, validate } from 'node-cron'; -import { REGEX_BETWEEN_PARENS } from './constants'; +import { REGEX_BETWEEN_PARENS } from '@directus/shared/constants'; import { rollup } from 'rollup'; // @TODO Remove this once a new version of @rollup/plugin-virtual has been released // @ts-expect-error diff --git a/api/src/utils/apply-function-to-column-name.ts b/api/src/utils/apply-function-to-column-name.ts index e7847950f6..4c8a17bcfa 100644 --- a/api/src/utils/apply-function-to-column-name.ts +++ b/api/src/utils/apply-function-to-column-name.ts @@ -1,4 +1,4 @@ -import { REGEX_BETWEEN_PARENS } from '../constants'; +import { REGEX_BETWEEN_PARENS } from '@directus/shared/constants'; /** * Takes in a column name, and transforms the original name with the generated column name based on diff --git a/api/src/utils/apply-query.ts b/api/src/utils/apply-query.ts index e5d52defa0..4309dd91cb 100644 --- a/api/src/utils/apply-query.ts +++ b/api/src/utils/apply-query.ts @@ -25,7 +25,7 @@ export default function applyQuery( dbQuery.orderBy( query.sort.map((sort) => ({ ...sort, - column: getColumn(knex, collection, sort.column, false) as any, + column: getColumn(knex, collection, sort.column) as any, })) ); } @@ -304,7 +304,8 @@ export function applyFilter( const [table, column] = key.split('.'); // Is processed through Knex.Raw, so should be safe to string-inject into these where queries - const selectionRaw = getColumn(knex, table, column, false) as any; + const selectionRaw = getColumn(knex, table, column) as any; + // Knex supports "raw" in the columnName parameter, but isn't typed as such. Too bad.. // See https://github.com/knex/knex/issues/4518 @TODO remove as any once knex is updated diff --git a/api/src/utils/get-column.ts b/api/src/utils/get-column.ts index 1829330450..6ca51558ab 100644 --- a/api/src/utils/get-column.ts +++ b/api/src/utils/get-column.ts @@ -1,6 +1,6 @@ import { Knex } from 'knex'; import { FunctionsHelper } from '../database/functions'; -import { REGEX_BETWEEN_PARENS } from '../constants'; +import { REGEX_BETWEEN_PARENS } from '@directus/shared/constants'; import { applyFunctionToColumnName } from './apply-function-to-column-name'; /** diff --git a/api/src/utils/strip-function.ts b/api/src/utils/strip-function.ts index fab6f7327b..4ebe7a3629 100644 --- a/api/src/utils/strip-function.ts +++ b/api/src/utils/strip-function.ts @@ -1,4 +1,4 @@ -import { REGEX_BETWEEN_PARENS } from '../constants'; +import { REGEX_BETWEEN_PARENS } from '@directus/shared/constants'; /** * Strip the function declarations from a list of fields diff --git a/package-lock.json b/package-lock.json index 19493dcd48..358eaf2bbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59830,7 +59830,7 @@ "mime": "2.5.2", "mitt": "3.0.0", "nanoid": "3.1.23", - "p-queue": "*", + "p-queue": "^6.6.2", "pinia": "2.0.0-beta.5", "prettier": "2.3.2", "pretty-ms": "7.0.1", diff --git a/packages/shared/src/constants/index.ts b/packages/shared/src/constants/index.ts index fe095a517d..0d34f9eb2c 100644 --- a/packages/shared/src/constants/index.ts +++ b/packages/shared/src/constants/index.ts @@ -1,3 +1,4 @@ export * from './extensions'; export * from './fields'; +export * from './regex'; export * from './symbols'; diff --git a/packages/shared/src/constants/regex.ts b/packages/shared/src/constants/regex.ts new file mode 100644 index 0000000000..399b5bdfe5 --- /dev/null +++ b/packages/shared/src/constants/regex.ts @@ -0,0 +1 @@ +export const REGEX_BETWEEN_PARENS = /\(([^)]+)\)/;