@directus/api 14.0.2 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__utils__/mock-env.d.ts +18 -0
- package/dist/__utils__/mock-env.js +41 -0
- package/dist/auth/drivers/oauth2.js +4 -2
- package/dist/auth/drivers/openid.js +4 -2
- package/dist/cli/load-extensions.js +1 -2
- package/dist/controllers/assets.js +10 -10
- package/dist/controllers/files.js +1 -5
- package/dist/database/index.js +2 -1
- package/dist/database/migrations/run.js +2 -2
- package/dist/database/system-data/collections/collections.yaml +1 -1
- package/dist/database/system-data/fields/settings.yaml +12 -13
- package/dist/database/system-data/fields/users.yaml +10 -10
- package/dist/env.d.ts +2 -4
- package/dist/env.js +12 -9
- package/dist/extensions/lib/get-extensions-path.d.ts +1 -0
- package/dist/extensions/lib/get-extensions-path.js +8 -0
- package/dist/extensions/lib/get-extensions.js +3 -2
- package/dist/extensions/lib/sync-extensions.d.ts +1 -0
- package/dist/extensions/lib/sync-extensions.js +59 -0
- package/dist/extensions/lib/sync-status.d.ts +10 -0
- package/dist/extensions/lib/sync-status.js +27 -0
- package/dist/extensions/manager.js +14 -5
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +13 -2
- package/dist/messenger.js +1 -3
- package/dist/request/validate-ip.js +1 -2
- package/dist/services/extensions.js +1 -1
- package/dist/services/files.d.ts +2 -2
- package/dist/services/files.js +90 -23
- package/dist/services/mail/index.js +5 -4
- package/dist/services/mail/templates/base.liquid +383 -138
- package/dist/services/mail/templates/password-reset.liquid +35 -17
- package/dist/services/mail/templates/user-invitation.liquid +32 -13
- package/dist/services/server.js +4 -0
- package/dist/storage/register-drivers.js +1 -2
- package/dist/storage/register-locations.js +1 -2
- package/dist/utils/get-auth-providers.d.ts +1 -1
- package/dist/utils/get-config-from-env.js +1 -2
- package/dist/utils/merge-permissions.js +11 -19
- package/dist/utils/sanitize-query.js +1 -2
- package/dist/utils/should-clear-cache.js +1 -2
- package/dist/utils/should-skip-cache.js +3 -4
- package/dist/utils/validate-env.js +1 -2
- package/dist/utils/validate-storage.js +12 -9
- package/package.json +16 -15
- package/dist/__mocks__/cache.d.mts +0 -5
- package/dist/__mocks__/cache.mjs +0 -7
package/dist/services/server.js
CHANGED
|
@@ -34,6 +34,10 @@ export class ServerService {
|
|
|
34
34
|
'project_logo',
|
|
35
35
|
'project_color',
|
|
36
36
|
'default_appearance',
|
|
37
|
+
'default_theme_light',
|
|
38
|
+
'default_theme_dark',
|
|
39
|
+
'theme_light_overrides',
|
|
40
|
+
'theme_dark_overrides',
|
|
37
41
|
'default_language',
|
|
38
42
|
'public_foreground',
|
|
39
43
|
'public_background',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import env from '../env.js';
|
|
2
2
|
import { getStorageDriver } from './get-storage-driver.js';
|
|
3
3
|
export const registerDrivers = async (storage) => {
|
|
4
|
-
const env = getEnv();
|
|
5
4
|
const usedDrivers = [];
|
|
6
5
|
for (const [key, value] of Object.entries(env)) {
|
|
7
6
|
if ((key.startsWith('STORAGE_') && key.endsWith('_DRIVER')) === false)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { toArray } from '@directus/utils';
|
|
2
|
-
import
|
|
2
|
+
import env from '../env.js';
|
|
3
3
|
import { getConfigFromEnv } from '../utils/get-config-from-env.js';
|
|
4
4
|
export const registerLocations = async (storage) => {
|
|
5
|
-
const env = getEnv();
|
|
6
5
|
const locations = toArray(env['STORAGE_LOCATIONS']);
|
|
7
6
|
locations.forEach((location) => {
|
|
8
7
|
location = location.trim();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import camelcase from 'camelcase';
|
|
2
2
|
import { set } from 'lodash-es';
|
|
3
|
-
import
|
|
3
|
+
import env from '../env.js';
|
|
4
4
|
export function getConfigFromEnv(prefix, omitPrefix, type = 'camelcase') {
|
|
5
|
-
const env = getEnv();
|
|
6
5
|
const config = {};
|
|
7
6
|
for (const [key, value] of Object.entries(env)) {
|
|
8
7
|
if (key.toLowerCase().startsWith(prefix.toLowerCase()) === false)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatten, intersection,
|
|
1
|
+
import { flatten, intersection, isEmpty, merge, omit } from 'lodash-es';
|
|
2
2
|
export function mergePermissions(strategy, ...permissions) {
|
|
3
3
|
const allPermissions = flatten(permissions);
|
|
4
4
|
const mergedPermissions = allPermissions
|
|
@@ -27,15 +27,11 @@ export function mergePermission(strategy, currentPerm, newPerm) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
else if (currentPerm.permissions) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
permissions = {
|
|
36
|
-
[logicalKey]: [currentPerm.permissions, newPerm.permissions],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
30
|
+
permissions = {
|
|
31
|
+
[logicalKey]: strategy === 'or'
|
|
32
|
+
? [currentPerm.permissions, newPerm.permissions].filter((p) => !isEmpty(p))
|
|
33
|
+
: [currentPerm.permissions, newPerm.permissions],
|
|
34
|
+
};
|
|
39
35
|
}
|
|
40
36
|
else {
|
|
41
37
|
permissions = {
|
|
@@ -53,15 +49,11 @@ export function mergePermission(strategy, currentPerm, newPerm) {
|
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
else if (currentPerm.validation) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
validation = {
|
|
62
|
-
[logicalKey]: [currentPerm.validation, newPerm.validation],
|
|
63
|
-
};
|
|
64
|
-
}
|
|
52
|
+
validation = {
|
|
53
|
+
[logicalKey]: strategy === 'or'
|
|
54
|
+
? [currentPerm.validation, newPerm.validation].filter((p) => !isEmpty(p))
|
|
55
|
+
: [currentPerm.validation, newPerm.validation],
|
|
56
|
+
};
|
|
65
57
|
}
|
|
66
58
|
else {
|
|
67
59
|
validation = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { parseFilter, parseJSON } from '@directus/utils';
|
|
2
2
|
import { flatten, get, isPlainObject, merge, set } from 'lodash-es';
|
|
3
|
-
import
|
|
3
|
+
import env from '../env.js';
|
|
4
4
|
import logger from '../logger.js';
|
|
5
5
|
import { Meta } from '../types/index.js';
|
|
6
6
|
export function sanitizeQuery(rawQuery, accountability) {
|
|
7
7
|
const query = {};
|
|
8
|
-
const env = getEnv();
|
|
9
8
|
const hasMaxLimit = 'QUERY_LIMIT_MAX' in env &&
|
|
10
9
|
Number(env['QUERY_LIMIT_MAX']) >= 0 &&
|
|
11
10
|
!Number.isNaN(Number(env['QUERY_LIMIT_MAX'])) &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import env from '../env.js';
|
|
2
2
|
/**
|
|
3
3
|
* Check whether cache should be cleared
|
|
4
4
|
*
|
|
@@ -7,7 +7,6 @@ import { getEnv } from '../env.js';
|
|
|
7
7
|
* @param collection Collection name to check if cache purging should be ignored
|
|
8
8
|
*/
|
|
9
9
|
export function shouldClearCache(cache, opts, collection) {
|
|
10
|
-
const env = getEnv();
|
|
11
10
|
if (env['CACHE_AUTO_PURGE']) {
|
|
12
11
|
if (collection && env['CACHE_AUTO_PURGE_IGNORE_LIST'].includes(collection)) {
|
|
13
12
|
return false;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { getEnv } from '../env.js';
|
|
2
|
-
import { Url } from './url.js';
|
|
3
|
-
import url from 'url';
|
|
4
1
|
import { getEndpoint } from '@directus/utils';
|
|
2
|
+
import url from 'url';
|
|
3
|
+
import env from '../env.js';
|
|
4
|
+
import { Url } from './url.js';
|
|
5
5
|
/**
|
|
6
6
|
* Whether to skip caching for the current request
|
|
7
7
|
*
|
|
8
8
|
* @param req Express request object
|
|
9
9
|
*/
|
|
10
10
|
export function shouldSkipCache(req) {
|
|
11
|
-
const env = getEnv();
|
|
12
11
|
// Always skip cache for requests coming from the data studio based on Referer header
|
|
13
12
|
const referer = req.get('Referer');
|
|
14
13
|
if (referer) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import env from '../env.js';
|
|
2
2
|
import logger from '../logger.js';
|
|
3
3
|
export function validateEnv(requiredKeys) {
|
|
4
|
-
const env = getEnv();
|
|
5
4
|
for (const requiredKey of requiredKeys) {
|
|
6
5
|
if (requiredKey in env === false) {
|
|
7
6
|
logger.error(`"${requiredKey}" Environment Variable is missing.`);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import logger from '../logger.js';
|
|
3
|
-
import { access } from 'node:fs/promises';
|
|
1
|
+
import { toArray } from '@directus/utils';
|
|
4
2
|
import { constants } from 'fs';
|
|
3
|
+
import { access } from 'node:fs/promises';
|
|
5
4
|
import path from 'path';
|
|
6
|
-
import
|
|
5
|
+
import env from '../env.js';
|
|
6
|
+
import { getExtensionsPath } from '../extensions/lib/get-extensions-path.js';
|
|
7
|
+
import logger from '../logger.js';
|
|
7
8
|
export async function validateStorage() {
|
|
8
9
|
if (env['DB_CLIENT'] === 'sqlite3') {
|
|
9
10
|
try {
|
|
@@ -22,10 +23,12 @@ export async function validateStorage() {
|
|
|
22
23
|
logger.warn(`Upload directory (${path.resolve(env['STORAGE_LOCAL_ROOT'])}) is not read/writeable!`);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (!env['EXTENSIONS_LOCATION']) {
|
|
27
|
+
try {
|
|
28
|
+
await access(getExtensionsPath(), constants.R_OK);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
logger.warn(`Extensions directory (${path.resolve(getExtensionsPath())}) is not readable!`);
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "14.0
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"openid-client": "5.4.2",
|
|
123
123
|
"ora": "6.3.1",
|
|
124
124
|
"otplib": "12.0.1",
|
|
125
|
+
"p-queue": "7.4.1",
|
|
125
126
|
"papaparse": "5.4.1",
|
|
126
127
|
"pino": "8.14.1",
|
|
127
128
|
"pino-http": "8.3.3",
|
|
@@ -144,23 +145,23 @@
|
|
|
144
145
|
"ws": "8.14.2",
|
|
145
146
|
"zod": "3.22.4",
|
|
146
147
|
"zod-validation-error": "1.0.1",
|
|
147
|
-
"@directus/app": "10.
|
|
148
|
+
"@directus/app": "10.13.0",
|
|
148
149
|
"@directus/constants": "11.0.1",
|
|
149
|
-
"@directus/extensions": "0.1.1",
|
|
150
150
|
"@directus/errors": "0.2.0",
|
|
151
|
-
"@directus/extensions-sdk": "10.
|
|
152
|
-
"@directus/pressure": "1.0.
|
|
151
|
+
"@directus/extensions-sdk": "10.2.0",
|
|
152
|
+
"@directus/pressure": "1.0.13",
|
|
153
|
+
"@directus/extensions": "0.2.0",
|
|
153
154
|
"@directus/schema": "11.0.0",
|
|
154
|
-
"@directus/specs": "10.2.
|
|
155
|
+
"@directus/specs": "10.2.2",
|
|
155
156
|
"@directus/storage": "10.0.7",
|
|
156
|
-
"@directus/storage-driver-azure": "10.0.
|
|
157
|
-
"@directus/storage-driver-gcs": "10.0.
|
|
158
|
-
"@directus/storage-driver-cloudinary": "10.0.
|
|
159
|
-
"@directus/storage-driver-
|
|
160
|
-
"@directus/storage-driver-
|
|
161
|
-
"@directus/storage-driver-supabase": "1.0.
|
|
162
|
-
"@directus/validation": "0.0.
|
|
163
|
-
"@directus/utils": "11.0.
|
|
157
|
+
"@directus/storage-driver-azure": "10.0.14",
|
|
158
|
+
"@directus/storage-driver-gcs": "10.0.14",
|
|
159
|
+
"@directus/storage-driver-cloudinary": "10.0.14",
|
|
160
|
+
"@directus/storage-driver-local": "10.0.14",
|
|
161
|
+
"@directus/storage-driver-s3": "10.0.14",
|
|
162
|
+
"@directus/storage-driver-supabase": "1.0.6",
|
|
163
|
+
"@directus/validation": "0.0.9",
|
|
164
|
+
"@directus/utils": "11.0.2"
|
|
164
165
|
},
|
|
165
166
|
"devDependencies": {
|
|
166
167
|
"@ngneat/falso": "6.4.0",
|
|
@@ -210,7 +211,7 @@
|
|
|
210
211
|
"vitest": "0.31.1",
|
|
211
212
|
"@directus/random": "0.2.3",
|
|
212
213
|
"@directus/tsconfig": "1.0.1",
|
|
213
|
-
"@directus/types": "11.0.
|
|
214
|
+
"@directus/types": "11.0.2"
|
|
214
215
|
},
|
|
215
216
|
"optionalDependencies": {
|
|
216
217
|
"@keyv/redis": "2.5.8",
|
package/dist/__mocks__/cache.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
export const getCache = vi
|
|
3
|
-
.fn()
|
|
4
|
-
.mockReturnValue({ cache: undefined, systemCache: undefined, lockCache: undefined });
|
|
5
|
-
export const flushCaches = vi.fn();
|
|
6
|
-
export const clearSystemCache = vi.fn();
|
|
7
|
-
export const setSystemCache = vi.fn();
|