@directus/api 20.1.0 → 21.0.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/app.js +2 -2
- package/dist/auth/drivers/ldap.js +1 -1
- package/dist/auth/drivers/oauth2.js +1 -1
- package/dist/auth/drivers/openid.js +1 -1
- package/dist/auth/drivers/saml.js +1 -1
- package/dist/auth.js +1 -1
- package/dist/cache.d.ts +0 -1
- package/dist/cache.js +8 -23
- package/dist/cli/commands/bootstrap/index.js +1 -1
- package/dist/cli/commands/count/index.js +1 -1
- package/dist/cli/commands/database/install.js +1 -1
- package/dist/cli/commands/database/migrate.js +1 -1
- package/dist/cli/commands/roles/create.js +1 -1
- package/dist/cli/commands/schema/apply.js +1 -1
- package/dist/cli/commands/schema/snapshot.js +1 -1
- package/dist/cli/commands/users/create.js +1 -1
- package/dist/cli/commands/users/passwd.js +1 -1
- package/dist/cli/load-extensions.js +1 -1
- package/dist/constants.js +2 -2
- package/dist/controllers/assets.js +1 -1
- package/dist/controllers/auth.js +1 -1
- package/dist/controllers/files.js +1 -1
- package/dist/controllers/schema.js +1 -1
- package/dist/controllers/tus.js +5 -3
- package/dist/database/index.js +11 -7
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +1 -1
- package/dist/database/migrations/20210802A-replace-groups.js +1 -1
- package/dist/database/migrations/20230721A-require-shares-fields.js +1 -1
- package/dist/database/migrations/20240305A-change-useragent-type.js +1 -1
- package/dist/database/migrations/20240716A-update-files-date-fields.d.ts +3 -0
- package/dist/database/migrations/20240716A-update-files-date-fields.js +33 -0
- package/dist/database/migrations/run.js +1 -1
- package/dist/emitter.js +1 -1
- package/dist/extensions/lib/get-shared-deps-mapping.js +1 -1
- package/dist/extensions/lib/installation/manager.js +1 -1
- package/dist/extensions/lib/sandbox/register/call-reference.js +1 -1
- package/dist/extensions/lib/sandbox/sdk/generators/log.js +1 -1
- package/dist/extensions/lib/sync-extensions.js +1 -1
- package/dist/extensions/manager.js +1 -1
- package/dist/flows.js +1 -1
- package/dist/{logger.js → logger/index.js} +3 -9
- package/dist/logger/redact-query.d.ts +1 -0
- package/dist/logger/redact-query.js +13 -0
- package/dist/mailer.js +1 -1
- package/dist/middleware/cache.js +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/error-handler.d.ts +2 -2
- package/dist/middleware/error-handler.js +55 -52
- package/dist/middleware/rate-limiter-global.js +1 -1
- package/dist/middleware/respond.js +1 -1
- package/dist/operations/log/index.js +1 -1
- package/dist/operations/mail/index.js +1 -1
- package/dist/request/is-denied-ip.js +1 -1
- package/dist/server.js +1 -1
- package/dist/services/activity.js +1 -1
- package/dist/services/assets.js +3 -6
- package/dist/services/fields.d.ts +3 -0
- package/dist/services/fields.js +29 -5
- package/dist/services/files/lib/get-sharp-instance.d.ts +2 -0
- package/dist/services/files/lib/get-sharp-instance.js +10 -0
- package/dist/services/files/utils/get-metadata.js +8 -7
- package/dist/services/files.js +6 -1
- package/dist/services/graphql/utils/process-error.js +1 -1
- package/dist/services/graphql/utils/sanitize-gql-schema.js +1 -1
- package/dist/services/import-export.js +1 -1
- package/dist/services/mail/index.d.ts +1 -1
- package/dist/services/mail/index.js +10 -2
- package/dist/services/notifications.js +1 -1
- package/dist/services/relations.d.ts +3 -1
- package/dist/services/relations.js +27 -5
- package/dist/services/server.js +1 -1
- package/dist/services/shares.js +1 -1
- package/dist/services/tus/data-store.js +5 -6
- package/dist/services/tus/server.d.ts +1 -1
- package/dist/services/tus/server.js +9 -2
- package/dist/services/users.js +1 -1
- package/dist/services/webhooks.js +1 -1
- package/dist/telemetry/lib/track.js +1 -1
- package/dist/utils/apply-diff.js +1 -1
- package/dist/utils/apply-query.js +8 -2
- package/dist/utils/delete-from-require-cache.js +1 -1
- package/dist/utils/get-default-value.js +1 -1
- package/dist/utils/get-ip-from-req.js +1 -1
- package/dist/utils/get-permissions.js +1 -1
- package/dist/utils/get-schema.js +4 -4
- package/dist/utils/is-url-allowed.js +1 -1
- package/dist/utils/sanitize-query.js +1 -1
- package/dist/utils/transaction.js +1 -1
- package/dist/utils/validate-env.js +1 -1
- package/dist/utils/validate-storage.js +1 -1
- package/dist/websocket/controllers/base.js +1 -1
- package/dist/websocket/controllers/graphql.js +1 -1
- package/dist/websocket/controllers/rest.js +1 -1
- package/dist/websocket/errors.js +1 -1
- package/package.json +32 -32
- /package/dist/{logger.d.ts → logger/index.d.ts} +0 -0
package/dist/app.js
CHANGED
|
@@ -44,12 +44,12 @@ import { isInstalled, validateDatabaseConnection, validateDatabaseExtensions, va
|
|
|
44
44
|
import emitter from './emitter.js';
|
|
45
45
|
import { getExtensionManager } from './extensions/index.js';
|
|
46
46
|
import { getFlowManager } from './flows.js';
|
|
47
|
-
import { createExpressLogger, useLogger } from './logger.js';
|
|
47
|
+
import { createExpressLogger, useLogger } from './logger/index.js';
|
|
48
48
|
import authenticate from './middleware/authenticate.js';
|
|
49
49
|
import cache from './middleware/cache.js';
|
|
50
50
|
import { checkIP } from './middleware/check-ip.js';
|
|
51
51
|
import cors from './middleware/cors.js';
|
|
52
|
-
import errorHandler from './middleware/error-handler.js';
|
|
52
|
+
import { errorHandler } from './middleware/error-handler.js';
|
|
53
53
|
import extractToken from './middleware/extract-token.js';
|
|
54
54
|
import getPermissions from './middleware/get-permissions.js';
|
|
55
55
|
import rateLimiterGlobal from './middleware/rate-limiter-global.js';
|
|
@@ -5,7 +5,7 @@ import Joi from 'joi';
|
|
|
5
5
|
import ldap from 'ldapjs';
|
|
6
6
|
import getDatabase from '../../database/index.js';
|
|
7
7
|
import emitter from '../../emitter.js';
|
|
8
|
-
import { useLogger } from '../../logger.js';
|
|
8
|
+
import { useLogger } from '../../logger/index.js';
|
|
9
9
|
import { respond } from '../../middleware/respond.js';
|
|
10
10
|
import { AuthenticationService } from '../../services/authentication.js';
|
|
11
11
|
import { UsersService } from '../../services/users.js';
|
|
@@ -9,7 +9,7 @@ import { getAuthProvider } from '../../auth.js';
|
|
|
9
9
|
import { REFRESH_COOKIE_OPTIONS, SESSION_COOKIE_OPTIONS } from '../../constants.js';
|
|
10
10
|
import getDatabase from '../../database/index.js';
|
|
11
11
|
import emitter from '../../emitter.js';
|
|
12
|
-
import { useLogger } from '../../logger.js';
|
|
12
|
+
import { useLogger } from '../../logger/index.js';
|
|
13
13
|
import { respond } from '../../middleware/respond.js';
|
|
14
14
|
import { AuthenticationService } from '../../services/authentication.js';
|
|
15
15
|
import { UsersService } from '../../services/users.js';
|
|
@@ -9,7 +9,7 @@ import { getAuthProvider } from '../../auth.js';
|
|
|
9
9
|
import { REFRESH_COOKIE_OPTIONS, SESSION_COOKIE_OPTIONS } from '../../constants.js';
|
|
10
10
|
import getDatabase from '../../database/index.js';
|
|
11
11
|
import emitter from '../../emitter.js';
|
|
12
|
-
import { useLogger } from '../../logger.js';
|
|
12
|
+
import { useLogger } from '../../logger/index.js';
|
|
13
13
|
import { respond } from '../../middleware/respond.js';
|
|
14
14
|
import { AuthenticationService } from '../../services/authentication.js';
|
|
15
15
|
import { UsersService } from '../../services/users.js';
|
|
@@ -7,7 +7,7 @@ import { getAuthProvider } from '../../auth.js';
|
|
|
7
7
|
import { REFRESH_COOKIE_OPTIONS, SESSION_COOKIE_OPTIONS } from '../../constants.js';
|
|
8
8
|
import getDatabase from '../../database/index.js';
|
|
9
9
|
import emitter from '../../emitter.js';
|
|
10
|
-
import { useLogger } from '../../logger.js';
|
|
10
|
+
import { useLogger } from '../../logger/index.js';
|
|
11
11
|
import { respond } from '../../middleware/respond.js';
|
|
12
12
|
import { AuthenticationService } from '../../services/authentication.js';
|
|
13
13
|
import { UsersService } from '../../services/users.js';
|
package/dist/auth.js
CHANGED
|
@@ -4,7 +4,7 @@ import { toArray } from '@directus/utils';
|
|
|
4
4
|
import { LDAPAuthDriver, LocalAuthDriver, OAuth2AuthDriver, OpenIDAuthDriver, SAMLAuthDriver, } from './auth/drivers/index.js';
|
|
5
5
|
import { DEFAULT_AUTH_PROVIDER } from './constants.js';
|
|
6
6
|
import getDatabase from './database/index.js';
|
|
7
|
-
import { useLogger } from './logger.js';
|
|
7
|
+
import { useLogger } from './logger/index.js';
|
|
8
8
|
import { getConfigFromEnv } from './utils/get-config-from-env.js';
|
|
9
9
|
import { getSchema } from './utils/get-schema.js';
|
|
10
10
|
const providers = new Map();
|
package/dist/cache.d.ts
CHANGED
package/dist/cache.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
|
-
import { getSimpleHash } from '@directus/utils';
|
|
3
2
|
import Keyv from 'keyv';
|
|
4
3
|
import { useBus } from './bus/index.js';
|
|
5
|
-
import { useLogger } from './logger.js';
|
|
4
|
+
import { useLogger } from './logger/index.js';
|
|
6
5
|
import { redisConfigAvailable } from './redis/index.js';
|
|
7
6
|
import { compress, decompress } from './utils/compress.js';
|
|
8
7
|
import { getConfigFromEnv } from './utils/get-config-from-env.js';
|
|
@@ -15,16 +14,16 @@ const require = createRequire(import.meta.url);
|
|
|
15
14
|
let cache = null;
|
|
16
15
|
let systemCache = null;
|
|
17
16
|
let localSchemaCache = null;
|
|
18
|
-
let sharedSchemaCache = null;
|
|
19
17
|
let lockCache = null;
|
|
20
18
|
let messengerSubscribed = false;
|
|
21
19
|
const messenger = useBus();
|
|
22
|
-
if (redisConfigAvailable() &&
|
|
20
|
+
if (redisConfigAvailable() && !messengerSubscribed) {
|
|
23
21
|
messengerSubscribed = true;
|
|
24
22
|
messenger.subscribe('schemaChanged', async (opts) => {
|
|
25
|
-
if (cache && opts?.['autoPurgeCache'] !== false) {
|
|
23
|
+
if (env['CACHE_STORE'] === 'memory' && env['CACHE_AUTO_PURGE'] && cache && opts?.['autoPurgeCache'] !== false) {
|
|
26
24
|
await cache.clear();
|
|
27
25
|
}
|
|
26
|
+
await localSchemaCache?.clear();
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
export function getCache() {
|
|
@@ -37,10 +36,6 @@ export function getCache() {
|
|
|
37
36
|
systemCache = getKeyvInstance(env['CACHE_STORE'], getMilliseconds(env['CACHE_SYSTEM_TTL']), '_system');
|
|
38
37
|
systemCache.on('error', (err) => logger.warn(err, `[system-cache] ${err}`));
|
|
39
38
|
}
|
|
40
|
-
if (sharedSchemaCache === null) {
|
|
41
|
-
sharedSchemaCache = getKeyvInstance(env['CACHE_STORE'], getMilliseconds(env['CACHE_SYSTEM_TTL']), '_schema_shared');
|
|
42
|
-
sharedSchemaCache.on('error', (err) => logger.warn(err, `[shared-schema-cache] ${err}`));
|
|
43
|
-
}
|
|
44
39
|
if (localSchemaCache === null) {
|
|
45
40
|
localSchemaCache = getKeyvInstance('memory', getMilliseconds(env['CACHE_SYSTEM_TTL']), '_schema');
|
|
46
41
|
localSchemaCache.on('error', (err) => logger.warn(err, `[schema-cache] ${err}`));
|
|
@@ -49,7 +44,7 @@ export function getCache() {
|
|
|
49
44
|
lockCache = getKeyvInstance(env['CACHE_STORE'], undefined, '_lock');
|
|
50
45
|
lockCache.on('error', (err) => logger.warn(err, `[lock-cache] ${err}`));
|
|
51
46
|
}
|
|
52
|
-
return { cache, systemCache,
|
|
47
|
+
return { cache, systemCache, localSchemaCache, lockCache };
|
|
53
48
|
}
|
|
54
49
|
export async function flushCaches(forced) {
|
|
55
50
|
const { cache } = getCache();
|
|
@@ -57,14 +52,13 @@ export async function flushCaches(forced) {
|
|
|
57
52
|
await cache?.clear();
|
|
58
53
|
}
|
|
59
54
|
export async function clearSystemCache(opts) {
|
|
60
|
-
const { systemCache, localSchemaCache, lockCache
|
|
55
|
+
const { systemCache, localSchemaCache, lockCache } = getCache();
|
|
61
56
|
// Flush system cache when forced or when system cache lock not set
|
|
62
57
|
if (opts?.forced || !(await lockCache.get('system-cache-lock'))) {
|
|
63
58
|
await lockCache.set('system-cache-lock', true, 10000);
|
|
64
59
|
await systemCache.clear();
|
|
65
60
|
await lockCache.delete('system-cache-lock');
|
|
66
61
|
}
|
|
67
|
-
await sharedSchemaCache.clear();
|
|
68
62
|
await localSchemaCache.clear();
|
|
69
63
|
messenger.publish('schemaChanged', { autoPurgeCache: opts?.autoPurgeCache });
|
|
70
64
|
}
|
|
@@ -79,20 +73,11 @@ export async function getSystemCache(key) {
|
|
|
79
73
|
return await getCacheValue(systemCache, key);
|
|
80
74
|
}
|
|
81
75
|
export async function setSchemaCache(schema) {
|
|
82
|
-
const { localSchemaCache
|
|
83
|
-
const schemaHash = getSimpleHash(JSON.stringify(schema));
|
|
84
|
-
await sharedSchemaCache.set('hash', schemaHash);
|
|
76
|
+
const { localSchemaCache } = getCache();
|
|
85
77
|
await localSchemaCache.set('schema', schema);
|
|
86
|
-
await localSchemaCache.set('hash', schemaHash);
|
|
87
78
|
}
|
|
88
79
|
export async function getSchemaCache() {
|
|
89
|
-
const { localSchemaCache
|
|
90
|
-
const sharedSchemaHash = await sharedSchemaCache.get('hash');
|
|
91
|
-
if (!sharedSchemaHash)
|
|
92
|
-
return;
|
|
93
|
-
const localSchemaHash = await localSchemaCache.get('hash');
|
|
94
|
-
if (!localSchemaHash || localSchemaHash !== sharedSchemaHash)
|
|
95
|
-
return;
|
|
80
|
+
const { localSchemaCache } = getCache();
|
|
96
81
|
return await localSchemaCache.get('schema');
|
|
97
82
|
}
|
|
98
83
|
export async function setCacheValue(cache, key, value, ttl) {
|
|
@@ -2,7 +2,7 @@ import { useEnv } from '@directus/env';
|
|
|
2
2
|
import getDatabase, { hasDatabaseConnection, isInstalled, validateDatabaseConnection, } from '../../../database/index.js';
|
|
3
3
|
import runMigrations from '../../../database/migrations/run.js';
|
|
4
4
|
import installDatabase from '../../../database/seeds/run.js';
|
|
5
|
-
import { useLogger } from '../../../logger.js';
|
|
5
|
+
import { useLogger } from '../../../logger/index.js';
|
|
6
6
|
import { RolesService } from '../../../services/roles.js';
|
|
7
7
|
import { SettingsService } from '../../../services/settings.js';
|
|
8
8
|
import { UsersService } from '../../../services/users.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import getDatabase from '../../../database/index.js';
|
|
2
|
-
import { useLogger } from '../../../logger.js';
|
|
2
|
+
import { useLogger } from '../../../logger/index.js';
|
|
3
3
|
export default async function count(collection) {
|
|
4
4
|
const database = getDatabase();
|
|
5
5
|
const logger = useLogger();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import installSeeds from '../../../database/seeds/run.js';
|
|
2
2
|
import getDatabase from '../../../database/index.js';
|
|
3
|
-
import { useLogger } from '../../../logger.js';
|
|
3
|
+
import { useLogger } from '../../../logger/index.js';
|
|
4
4
|
export default async function start() {
|
|
5
5
|
const database = getDatabase();
|
|
6
6
|
const logger = useLogger();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import run from '../../../database/migrations/run.js';
|
|
2
2
|
import getDatabase from '../../../database/index.js';
|
|
3
|
-
import { useLogger } from '../../../logger.js';
|
|
3
|
+
import { useLogger } from '../../../logger/index.js';
|
|
4
4
|
export default async function migrate(direction) {
|
|
5
5
|
const database = getDatabase();
|
|
6
6
|
const logger = useLogger();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSchema } from '../../../utils/get-schema.js';
|
|
2
2
|
import { RolesService } from '../../../services/roles.js';
|
|
3
3
|
import getDatabase from '../../../database/index.js';
|
|
4
|
-
import { useLogger } from '../../../logger.js';
|
|
4
|
+
import { useLogger } from '../../../logger/index.js';
|
|
5
5
|
export default async function rolesCreate({ role: name, admin }) {
|
|
6
6
|
const database = getDatabase();
|
|
7
7
|
const logger = useLogger();
|
|
@@ -5,7 +5,7 @@ import inquirer from 'inquirer';
|
|
|
5
5
|
import { load as loadYaml } from 'js-yaml';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import getDatabase, { isInstalled, validateDatabaseConnection } from '../../../database/index.js';
|
|
8
|
-
import { useLogger } from '../../../logger.js';
|
|
8
|
+
import { useLogger } from '../../../logger/index.js';
|
|
9
9
|
import { DiffKind } from '../../../types/index.js';
|
|
10
10
|
import { isNestedMetaUpdate } from '../../../utils/apply-diff.js';
|
|
11
11
|
import { applySnapshot } from '../../../utils/apply-snapshot.js';
|
|
@@ -3,7 +3,7 @@ import inquirer from 'inquirer';
|
|
|
3
3
|
import { dump as toYaml } from 'js-yaml';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import getDatabase from '../../../database/index.js';
|
|
6
|
-
import { useLogger } from '../../../logger.js';
|
|
6
|
+
import { useLogger } from '../../../logger/index.js';
|
|
7
7
|
import { getSnapshot } from '../../../utils/get-snapshot.js';
|
|
8
8
|
export async function snapshot(snapshotPath, options) {
|
|
9
9
|
const database = getDatabase();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import getDatabase from '../../../database/index.js';
|
|
2
|
-
import { useLogger } from '../../../logger.js';
|
|
2
|
+
import { useLogger } from '../../../logger/index.js';
|
|
3
3
|
import { UsersService } from '../../../services/users.js';
|
|
4
4
|
import { getSchema } from '../../../utils/get-schema.js';
|
|
5
5
|
export default async function usersCreate({ email, password, role, }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import getDatabase from '../../../database/index.js';
|
|
2
|
-
import { useLogger } from '../../../logger.js';
|
|
2
|
+
import { useLogger } from '../../../logger/index.js';
|
|
3
3
|
import { UsersService } from '../../../services/users.js';
|
|
4
4
|
import { generateHash } from '../../../utils/generate-hash.js';
|
|
5
5
|
import { getSchema } from '../../../utils/get-schema.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
2
|
import { isInstalled, validateMigrations } from '../database/index.js';
|
|
3
3
|
import { getExtensionManager } from '../extensions/index.js';
|
|
4
|
-
import { useLogger } from '../logger.js';
|
|
4
|
+
import { useLogger } from '../logger/index.js';
|
|
5
5
|
export const loadExtensions = async () => {
|
|
6
6
|
const env = useEnv();
|
|
7
7
|
const logger = useLogger();
|
package/dist/constants.js
CHANGED
|
@@ -82,8 +82,8 @@ export const SUPPORTED_IMAGE_METADATA_FORMATS = [
|
|
|
82
82
|
/** Resumable uploads */
|
|
83
83
|
export const RESUMABLE_UPLOADS = {
|
|
84
84
|
ENABLED: toBoolean(env['TUS_ENABLED']),
|
|
85
|
-
CHUNK_SIZE: bytes(env['TUS_CHUNK_SIZE']),
|
|
86
|
-
MAX_SIZE: bytes(env['FILES_MAX_UPLOAD_SIZE']),
|
|
85
|
+
CHUNK_SIZE: bytes.parse(env['TUS_CHUNK_SIZE']),
|
|
86
|
+
MAX_SIZE: bytes.parse(env['FILES_MAX_UPLOAD_SIZE']),
|
|
87
87
|
EXPIRATION_TIME: getMilliseconds(env['TUS_UPLOAD_EXPIRATION'], 600_000 /* 10min */),
|
|
88
88
|
SCHEDULE: String(env['TUS_CLEANUP_SCHEDULE']),
|
|
89
89
|
};
|
|
@@ -6,7 +6,7 @@ import { Router } from 'express';
|
|
|
6
6
|
import { merge, pick } from 'lodash-es';
|
|
7
7
|
import { ASSET_TRANSFORM_QUERY_KEYS, SYSTEM_ASSET_ALLOW_LIST } from '../constants.js';
|
|
8
8
|
import getDatabase from '../database/index.js';
|
|
9
|
-
import { useLogger } from '../logger.js';
|
|
9
|
+
import { useLogger } from '../logger/index.js';
|
|
10
10
|
import useCollection from '../middleware/use-collection.js';
|
|
11
11
|
import { AssetsService } from '../services/assets.js';
|
|
12
12
|
import { PayloadService } from '../services/payload.js';
|
package/dist/controllers/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ErrorCode, InvalidPayloadError, isDirectusError } from '@directus/error
|
|
|
3
3
|
import { Router } from 'express';
|
|
4
4
|
import { createLDAPAuthRouter, createLocalAuthRouter, createOAuth2AuthRouter, createOpenIDAuthRouter, createSAMLAuthRouter, } from '../auth/drivers/index.js';
|
|
5
5
|
import { DEFAULT_AUTH_PROVIDER, REFRESH_COOKIE_OPTIONS, SESSION_COOKIE_OPTIONS } from '../constants.js';
|
|
6
|
-
import { useLogger } from '../logger.js';
|
|
6
|
+
import { useLogger } from '../logger/index.js';
|
|
7
7
|
import { respond } from '../middleware/respond.js';
|
|
8
8
|
import { AuthenticationService } from '../services/authentication.js';
|
|
9
9
|
import { UsersService } from '../services/users.js';
|
|
@@ -35,7 +35,7 @@ export const multipartHandler = (req, res, next) => {
|
|
|
35
35
|
headers,
|
|
36
36
|
defParamCharset: 'utf8',
|
|
37
37
|
limits: {
|
|
38
|
-
fileSize: env['FILES_MAX_UPLOAD_SIZE'] ? bytes(env['FILES_MAX_UPLOAD_SIZE']) : undefined,
|
|
38
|
+
fileSize: env['FILES_MAX_UPLOAD_SIZE'] ? bytes.parse(env['FILES_MAX_UPLOAD_SIZE']) : undefined,
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
const savedFiles = [];
|
|
@@ -3,7 +3,7 @@ import { parseJSON } from '@directus/utils';
|
|
|
3
3
|
import Busboy from 'busboy';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import { load as loadYaml } from 'js-yaml';
|
|
6
|
-
import { useLogger } from '../logger.js';
|
|
6
|
+
import { useLogger } from '../logger/index.js';
|
|
7
7
|
import { respond } from '../middleware/respond.js';
|
|
8
8
|
import { SchemaService } from '../services/schema.js';
|
|
9
9
|
import asyncHandler from '../utils/async-handler.js';
|
package/dist/controllers/tus.js
CHANGED
|
@@ -26,7 +26,7 @@ const checkFileAccess = asyncHandler(async (req, _res, next) => {
|
|
|
26
26
|
if (!req.accountability?.admin) {
|
|
27
27
|
const action = mapAction(req.method);
|
|
28
28
|
if (action === 'create') {
|
|
29
|
-
// checkAccess
|
|
29
|
+
// checkAccess doesn't seem to work as expected for "create" actions
|
|
30
30
|
const hasPermission = Boolean(req.accountability?.permissions?.find((permission) => {
|
|
31
31
|
return permission.collection === 'directus_files' && permission.action === action;
|
|
32
32
|
}));
|
|
@@ -45,21 +45,23 @@ const checkFileAccess = asyncHandler(async (req, _res, next) => {
|
|
|
45
45
|
return next();
|
|
46
46
|
});
|
|
47
47
|
const handler = asyncHandler(async (req, res) => {
|
|
48
|
-
const tusServer = await createTusServer({
|
|
48
|
+
const [tusServer, cleanupServer] = await createTusServer({
|
|
49
49
|
schema: req.schema,
|
|
50
50
|
accountability: req.accountability,
|
|
51
51
|
});
|
|
52
52
|
await tusServer.handle(req, res);
|
|
53
|
+
cleanupServer();
|
|
53
54
|
});
|
|
54
55
|
export function scheduleTusCleanup() {
|
|
55
56
|
if (!RESUMABLE_UPLOADS.ENABLED)
|
|
56
57
|
return;
|
|
57
58
|
if (validateCron(RESUMABLE_UPLOADS.SCHEDULE)) {
|
|
58
59
|
scheduleSynchronizedJob('tus-cleanup', RESUMABLE_UPLOADS.SCHEDULE, async () => {
|
|
59
|
-
const tusServer = await createTusServer({
|
|
60
|
+
const [tusServer, cleanupServer] = await createTusServer({
|
|
60
61
|
schema: await getSchema(),
|
|
61
62
|
});
|
|
62
63
|
await tusServer.cleanUpExpiredUploads();
|
|
64
|
+
cleanupServer();
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
}
|
package/dist/database/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'path';
|
|
|
9
9
|
import { performance } from 'perf_hooks';
|
|
10
10
|
import { promisify } from 'util';
|
|
11
11
|
import { getExtensionsPath } from '../extensions/lib/get-extensions-path.js';
|
|
12
|
-
import { useLogger } from '../logger.js';
|
|
12
|
+
import { useLogger } from '../logger/index.js';
|
|
13
13
|
import { getConfigFromEnv } from '../utils/get-config-from-env.js';
|
|
14
14
|
import { validateEnv } from '../utils/validate-env.js';
|
|
15
15
|
import { getHelpers } from './helpers/index.js';
|
|
@@ -122,15 +122,19 @@ export function getDatabase() {
|
|
|
122
122
|
}
|
|
123
123
|
database = knex.default(knexConfig);
|
|
124
124
|
validateDatabaseCharset(database);
|
|
125
|
-
const times =
|
|
125
|
+
const times = new Map();
|
|
126
126
|
database
|
|
127
|
-
.on('query', (
|
|
128
|
-
times
|
|
127
|
+
.on('query', ({ __knexUid }) => {
|
|
128
|
+
times.set(__knexUid, performance.now());
|
|
129
129
|
})
|
|
130
130
|
.on('query-response', (_response, queryInfo) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
const time = times.get(queryInfo.__knexUid);
|
|
132
|
+
let delta;
|
|
133
|
+
if (time) {
|
|
134
|
+
delta = performance.now() - time;
|
|
135
|
+
times.delete(queryInfo.__knexUid);
|
|
136
|
+
}
|
|
137
|
+
logger.trace(`[${delta ? delta.toFixed(3) : '?'}ms] ${queryInfo.sql} [${(queryInfo.bindings ?? []).join(', ')}]`);
|
|
134
138
|
});
|
|
135
139
|
return database;
|
|
136
140
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInspector } from '@directus/schema';
|
|
2
|
-
import { useLogger } from '../../logger.js';
|
|
2
|
+
import { useLogger } from '../../logger/index.js';
|
|
3
3
|
import { getDefaultIndexName } from '../../utils/get-default-index-name.js';
|
|
4
4
|
export async function up(knex) {
|
|
5
5
|
const logger = useLogger();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseJSON } from '@directus/utils';
|
|
2
|
-
import { useLogger } from '../../logger.js';
|
|
2
|
+
import { useLogger } from '../../logger/index.js';
|
|
3
3
|
export async function up(knex) {
|
|
4
4
|
const logger = useLogger();
|
|
5
5
|
const dividerGroups = await knex.select('*').from('directus_fields').where('interface', '=', 'group-divider');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInspector } from '@directus/schema';
|
|
2
|
-
import { useLogger } from '../../logger.js';
|
|
2
|
+
import { useLogger } from '../../logger/index.js';
|
|
3
3
|
import { getHelpers } from '../helpers/index.js';
|
|
4
4
|
export async function up(knex) {
|
|
5
5
|
const helper = getHelpers(knex).schema;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getHelpers } from '../helpers/index.js';
|
|
2
|
+
export async function up(knex) {
|
|
3
|
+
const helper = getHelpers(knex).schema;
|
|
4
|
+
const isMysql = helper.isOneOfClients(['mysql']);
|
|
5
|
+
if (isMysql) {
|
|
6
|
+
// Knex creates invalid statement on MySQL, see https://github.com/knex/knex/issues/1888
|
|
7
|
+
await knex.schema.raw('ALTER TABLE `directus_files` CHANGE `uploaded_on` `created_on` TIMESTAMP NOT NULL DEFAULT current_timestamp();');
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
await knex.schema.alterTable('directus_files', (table) => {
|
|
11
|
+
table.renameColumn('uploaded_on', 'created_on');
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
await knex.schema.alterTable('directus_files', (table) => {
|
|
15
|
+
table.timestamp('uploaded_on');
|
|
16
|
+
});
|
|
17
|
+
await knex('directus_files').update('uploaded_on', knex.ref('created_on'));
|
|
18
|
+
}
|
|
19
|
+
export async function down(knex) {
|
|
20
|
+
await knex.schema.alterTable('directus_files', (table) => {
|
|
21
|
+
table.dropColumn('uploaded_on');
|
|
22
|
+
});
|
|
23
|
+
const helper = getHelpers(knex).schema;
|
|
24
|
+
const isMysql = helper.isOneOfClients(['mysql']);
|
|
25
|
+
if (isMysql) {
|
|
26
|
+
await knex.schema.raw('ALTER TABLE `directus_files` CHANGE `created_on` `uploaded_on` TIMESTAMP NOT NULL DEFAULT current_timestamp();');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await knex.schema.alterTable('directus_files', (table) => {
|
|
30
|
+
table.renameColumn('created_on', 'uploaded_on');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -6,7 +6,7 @@ import { dirname } from 'node:path';
|
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { flushCaches } from '../../cache.js';
|
|
9
|
-
import { useLogger } from '../../logger.js';
|
|
9
|
+
import { useLogger } from '../../logger/index.js';
|
|
10
10
|
import getModuleDefault from '../../utils/get-module-default.js';
|
|
11
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
export default async function run(database, direction, log = true) {
|
package/dist/emitter.js
CHANGED
|
@@ -5,7 +5,7 @@ import { readdir } from 'node:fs/promises';
|
|
|
5
5
|
import { dirname } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { useLogger } from '../../logger.js';
|
|
8
|
+
import { useLogger } from '../../logger/index.js';
|
|
9
9
|
import { Url } from '../../utils/url.js';
|
|
10
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
export const getSharedDepsMapping = async (deps) => {
|
|
@@ -9,7 +9,7 @@ import { Readable } from 'node:stream';
|
|
|
9
9
|
import Queue from 'p-queue';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { extract } from 'tar';
|
|
12
|
-
import { useLogger } from '../../../logger.js';
|
|
12
|
+
import { useLogger } from '../../../logger/index.js';
|
|
13
13
|
import { getStorage } from '../../../storage/index.js';
|
|
14
14
|
import { getExtensionsPath } from '../get-extensions-path.js';
|
|
15
15
|
const env = useEnv();
|
|
@@ -8,7 +8,7 @@ import { pipeline } from 'node:stream/promises';
|
|
|
8
8
|
import Queue from 'p-queue';
|
|
9
9
|
import { useBus } from '../../bus/index.js';
|
|
10
10
|
import { useLock } from '../../lock/index.js';
|
|
11
|
-
import { useLogger } from '../../logger.js';
|
|
11
|
+
import { useLogger } from '../../logger/index.js';
|
|
12
12
|
import { getStorage } from '../../storage/index.js';
|
|
13
13
|
import { getExtensionsPath } from './get-extensions-path.js';
|
|
14
14
|
import { SyncStatus, getSyncStatus, setSyncStatus } from './sync-status.js';
|
|
@@ -20,7 +20,7 @@ import { useBus } from '../bus/index.js';
|
|
|
20
20
|
import getDatabase from '../database/index.js';
|
|
21
21
|
import emitter, { Emitter } from '../emitter.js';
|
|
22
22
|
import { getFlowManager } from '../flows.js';
|
|
23
|
-
import { useLogger } from '../logger.js';
|
|
23
|
+
import { useLogger } from '../logger/index.js';
|
|
24
24
|
import * as services from '../services/index.js';
|
|
25
25
|
import { deleteFromRequireCache } from '../utils/delete-from-require-cache.js';
|
|
26
26
|
import getModuleDefault from '../utils/get-module-default.js';
|
package/dist/flows.js
CHANGED
|
@@ -7,7 +7,7 @@ import { get } from 'micromustache';
|
|
|
7
7
|
import { useBus } from './bus/index.js';
|
|
8
8
|
import getDatabase from './database/index.js';
|
|
9
9
|
import emitter from './emitter.js';
|
|
10
|
-
import { useLogger } from './logger.js';
|
|
10
|
+
import { useLogger } from './logger/index.js';
|
|
11
11
|
import { ActivityService } from './services/activity.js';
|
|
12
12
|
import { FlowsService } from './services/flows.js';
|
|
13
13
|
import * as services from './services/index.js';
|
|
@@ -4,7 +4,8 @@ import { merge } from 'lodash-es';
|
|
|
4
4
|
import { URL } from 'node:url';
|
|
5
5
|
import { pino } from 'pino';
|
|
6
6
|
import { pinoHttp, stdSerializers } from 'pino-http';
|
|
7
|
-
import { getConfigFromEnv } from '
|
|
7
|
+
import { getConfigFromEnv } from '../utils/get-config-from-env.js';
|
|
8
|
+
import { redactQuery } from './redact-query.js';
|
|
8
9
|
export const _cache = { logger: undefined };
|
|
9
10
|
export const useLogger = () => {
|
|
10
11
|
if (_cache.logger) {
|
|
@@ -78,7 +79,7 @@ export const createExpressLogger = () => {
|
|
|
78
79
|
}
|
|
79
80
|
if (env['LOG_STYLE'] === 'raw') {
|
|
80
81
|
httpLoggerOptions.redact = {
|
|
81
|
-
paths: ['req.headers.authorization', 'req.headers.cookie', 'res.headers'],
|
|
82
|
+
paths: ['req.headers.authorization', 'req.headers.cookie', 'res.headers', 'req.query.access_token'],
|
|
82
83
|
censor: (value, pathParts) => {
|
|
83
84
|
const path = pathParts.join('.');
|
|
84
85
|
if (path === 'res.headers') {
|
|
@@ -131,10 +132,3 @@ export const createExpressLogger = () => {
|
|
|
131
132
|
},
|
|
132
133
|
});
|
|
133
134
|
};
|
|
134
|
-
function redactQuery(originalPath) {
|
|
135
|
-
const url = new URL(originalPath, 'http://example.com/');
|
|
136
|
-
if (url.searchParams.has('access_token')) {
|
|
137
|
-
url.searchParams.set('access_token', REDACTED_TEXT);
|
|
138
|
-
}
|
|
139
|
-
return url.pathname + url.search;
|
|
140
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redactQuery(originalPath: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { REDACTED_TEXT } from '@directus/utils';
|
|
2
|
+
export function redactQuery(originalPath) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(originalPath, 'http://example.com/');
|
|
5
|
+
if (url.searchParams.has('access_token')) {
|
|
6
|
+
url.searchParams.set('access_token', REDACTED_TEXT);
|
|
7
|
+
}
|
|
8
|
+
return url.pathname + url.search;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return originalPath;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/mailer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
2
|
import nodemailer from 'nodemailer';
|
|
3
|
-
import { useLogger } from './logger.js';
|
|
3
|
+
import { useLogger } from './logger/index.js';
|
|
4
4
|
import { getConfigFromEnv } from './utils/get-config-from-env.js';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
6
6
|
const require = createRequire(import.meta.url);
|
package/dist/middleware/cache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
2
|
import { getCache, getCacheValue } from '../cache.js';
|
|
3
|
-
import { useLogger } from '../logger.js';
|
|
3
|
+
import { useLogger } from '../logger/index.js';
|
|
4
4
|
import asyncHandler from '../utils/async-handler.js';
|
|
5
5
|
import { getCacheControlHeader } from '../utils/get-cache-headers.js';
|
|
6
6
|
import { getCacheKey } from '../utils/get-cache-key.js';
|