@directus/api 18.1.1 → 18.2.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/extensions/lib/sandbox/register/operation.d.ts +1 -1
- package/dist/extensions/lib/sandbox/register/operation.js +4 -1
- package/dist/redis/utils/redis-config-available.js +3 -0
- package/dist/services/graphql/index.js +14 -5
- package/dist/services/graphql/schema-cache.d.ts +3 -0
- package/dist/services/graphql/schema-cache.js +12 -0
- package/package.json +15 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PromiseCallback } from '@directus/types';
|
|
2
2
|
import type { Reference } from 'isolated-vm';
|
|
3
3
|
export declare function registerOperationGenerator(): {
|
|
4
|
-
register: (id: Reference<string>, cb: Reference<(
|
|
4
|
+
register: (id: Reference<string>, cb: Reference<(options: Record<string, unknown>) => unknown | Promise<unknown> | void>) => void;
|
|
5
5
|
unregisterFunctions: PromiseCallback[];
|
|
6
6
|
};
|
|
@@ -9,7 +9,10 @@ export function registerOperationGenerator() {
|
|
|
9
9
|
if (cb.typeof !== 'function')
|
|
10
10
|
throw new TypeError('Operation config handler has to be of type function');
|
|
11
11
|
const idCopied = id.copySync();
|
|
12
|
-
const handler = async (
|
|
12
|
+
const handler = async (options) => {
|
|
13
|
+
const response = await callReference(cb, [options]);
|
|
14
|
+
return response.copy();
|
|
15
|
+
};
|
|
13
16
|
flowManager.addOperation(idCopied, handler);
|
|
14
17
|
unregisterFunctions.push(() => {
|
|
15
18
|
flowManager.removeOperation(idCopied);
|
|
@@ -4,5 +4,8 @@ import { useEnv } from '@directus/env';
|
|
|
4
4
|
*/
|
|
5
5
|
export const redisConfigAvailable = () => {
|
|
6
6
|
const env = useEnv();
|
|
7
|
+
if ('REDIS_ENABLED' in env) {
|
|
8
|
+
return env['REDIS_ENABLED'] === true;
|
|
9
|
+
}
|
|
7
10
|
return 'REDIS' in env || Object.keys(env).some((key) => key.startsWith('REDIS_'));
|
|
8
11
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Action, FUNCTIONS } from '@directus/constants';
|
|
2
2
|
import { useEnv } from '@directus/env';
|
|
3
3
|
import { ErrorCode, ForbiddenError, InvalidPayloadError, isDirectusError } from '@directus/errors';
|
|
4
|
+
import { isSystemCollection } from '@directus/system-data';
|
|
4
5
|
import { parseFilterFunctionPath, toBoolean } from '@directus/utils';
|
|
5
6
|
import argon2 from 'argon2';
|
|
6
7
|
import { GraphQLBoolean, GraphQLEnumType, GraphQLError, GraphQLFloat, GraphQLID, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, NoSchemaIntrospectionCustomRule, execute, specifiedRules, validate, } from 'graphql';
|
|
@@ -12,6 +13,8 @@ import getDatabase from '../../database/index.js';
|
|
|
12
13
|
import { generateHash } from '../../utils/generate-hash.js';
|
|
13
14
|
import { getGraphQLType } from '../../utils/get-graphql-type.js';
|
|
14
15
|
import { getService } from '../../utils/get-service.js';
|
|
16
|
+
import isDirectusJWT from '../../utils/is-directus-jwt.js';
|
|
17
|
+
import { verifyAccessJWT } from '../../utils/jwt.js';
|
|
15
18
|
import { mergeVersionsRaw, mergeVersionsRecursive } from '../../utils/merge-version-data.js';
|
|
16
19
|
import { reduceSchema } from '../../utils/reduce-schema.js';
|
|
17
20
|
import { sanitizeQuery } from '../../utils/sanitize-query.js';
|
|
@@ -31,6 +34,7 @@ import { UsersService } from '../users.js';
|
|
|
31
34
|
import { UtilsService } from '../utils.js';
|
|
32
35
|
import { VersionsService } from '../versions.js';
|
|
33
36
|
import { GraphQLExecutionError, GraphQLValidationError } from './errors/index.js';
|
|
37
|
+
import { cache } from './schema-cache.js';
|
|
34
38
|
import { createSubscriptionGenerator } from './subscription.js';
|
|
35
39
|
import { GraphQLBigInt } from './types/bigint.js';
|
|
36
40
|
import { GraphQLDate } from './types/date.js';
|
|
@@ -40,9 +44,6 @@ import { GraphQLStringOrFloat } from './types/string-or-float.js';
|
|
|
40
44
|
import { GraphQLVoid } from './types/void.js';
|
|
41
45
|
import { addPathToValidationError } from './utils/add-path-to-validation-error.js';
|
|
42
46
|
import processError from './utils/process-error.js';
|
|
43
|
-
import { isSystemCollection } from '@directus/system-data';
|
|
44
|
-
import isDirectusJWT from '../../utils/is-directus-jwt.js';
|
|
45
|
-
import { verifyAccessJWT } from '../../utils/jwt.js';
|
|
46
47
|
const env = useEnv();
|
|
47
48
|
const validationRules = Array.from(specifiedRules);
|
|
48
49
|
if (env['GRAPHQL_INTROSPECTION'] === false) {
|
|
@@ -104,6 +105,10 @@ export class GraphQLService {
|
|
|
104
105
|
return formattedResult;
|
|
105
106
|
}
|
|
106
107
|
getSchema(type = 'schema') {
|
|
108
|
+
const key = `${type}_${this.accountability?.role}_${this.accountability?.user}`;
|
|
109
|
+
const cachedSchema = cache.get(key);
|
|
110
|
+
if (cachedSchema)
|
|
111
|
+
return cachedSchema;
|
|
107
112
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
108
113
|
const self = this;
|
|
109
114
|
const schemaComposer = new SchemaComposer();
|
|
@@ -218,9 +223,13 @@ export class GraphQLService {
|
|
|
218
223
|
}, {}));
|
|
219
224
|
}
|
|
220
225
|
if (type === 'sdl') {
|
|
221
|
-
|
|
226
|
+
const sdl = schemaComposer.toSDL();
|
|
227
|
+
cache.set(key, sdl);
|
|
228
|
+
return sdl;
|
|
222
229
|
}
|
|
223
|
-
|
|
230
|
+
const gqlSchema = schemaComposer.buildSchema();
|
|
231
|
+
cache.set(key, gqlSchema);
|
|
232
|
+
return gqlSchema;
|
|
224
233
|
/**
|
|
225
234
|
* Construct an object of types for every collection, using the permitted fields per action type
|
|
226
235
|
* as it's fields.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEnv } from '@directus/env';
|
|
2
|
+
import { GraphQLSchema } from 'graphql';
|
|
3
|
+
import LRUMapDefault from 'mnemonist/lru-map.js';
|
|
4
|
+
import { useBus } from '../../bus/index.js';
|
|
5
|
+
// Workaround for misaligned types in mnemonist package exports
|
|
6
|
+
const LRUMap = LRUMapDefault;
|
|
7
|
+
const env = useEnv();
|
|
8
|
+
const bus = useBus();
|
|
9
|
+
export const cache = new LRUMap(Number(env['GRAPHQL_SCHEMA_CACHE_CAPACITY'] ?? 100));
|
|
10
|
+
bus.subscribe('schemaChanged', () => {
|
|
11
|
+
cache.clear();
|
|
12
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.2.0",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"micromustache": "8.0.3",
|
|
114
114
|
"mime-types": "2.1.35",
|
|
115
115
|
"minimatch": "9.0.3",
|
|
116
|
+
"mnemonist": "0.39.8",
|
|
116
117
|
"ms": "2.1.3",
|
|
117
118
|
"nanoid": "5.0.6",
|
|
118
119
|
"node-machine-id": "1.1.12",
|
|
@@ -144,28 +145,28 @@
|
|
|
144
145
|
"ws": "8.16.0",
|
|
145
146
|
"zod": "3.22.4",
|
|
146
147
|
"zod-validation-error": "3.0.3",
|
|
147
|
-
"@directus/app": "11.0.
|
|
148
|
-
"@directus/
|
|
148
|
+
"@directus/app": "11.0.3",
|
|
149
|
+
"@directus/env": "1.1.0",
|
|
149
150
|
"@directus/constants": "11.0.3",
|
|
151
|
+
"@directus/errors": "0.2.4",
|
|
152
|
+
"@directus/extensions-registry": "1.0.1",
|
|
150
153
|
"@directus/extensions": "1.0.1",
|
|
151
154
|
"@directus/extensions-sdk": "11.0.1",
|
|
152
|
-
"@directus/extensions-registry": "1.0.1",
|
|
153
|
-
"@directus/pressure": "1.0.17",
|
|
154
155
|
"@directus/memory": "1.0.5",
|
|
156
|
+
"@directus/pressure": "1.0.17",
|
|
157
|
+
"@directus/specs": "10.2.7",
|
|
155
158
|
"@directus/schema": "11.0.1",
|
|
156
159
|
"@directus/storage": "10.0.11",
|
|
157
|
-
"@directus/specs": "10.2.7",
|
|
158
160
|
"@directus/storage-driver-azure": "10.0.18",
|
|
159
|
-
"@directus/env": "1.0.4",
|
|
160
|
-
"@directus/storage-driver-gcs": "10.0.18",
|
|
161
161
|
"@directus/storage-driver-cloudinary": "10.0.18",
|
|
162
|
-
"@directus/storage-driver-
|
|
162
|
+
"@directus/storage-driver-gcs": "10.0.18",
|
|
163
163
|
"@directus/storage-driver-s3": "10.0.19",
|
|
164
|
+
"@directus/storage-driver-local": "10.0.18",
|
|
165
|
+
"@directus/storage-driver-supabase": "1.0.10",
|
|
164
166
|
"@directus/system-data": "1.0.1",
|
|
165
167
|
"@directus/utils": "11.0.6",
|
|
166
|
-
"
|
|
167
|
-
"@directus/validation": "0.0.13"
|
|
168
|
-
"directus": "10.10.2"
|
|
168
|
+
"directus": "10.10.3",
|
|
169
|
+
"@directus/validation": "0.0.13"
|
|
169
170
|
},
|
|
170
171
|
"devDependencies": {
|
|
171
172
|
"@ngneat/falso": "7.2.0",
|
|
@@ -208,8 +209,8 @@
|
|
|
208
209
|
"typescript": "5.3.3",
|
|
209
210
|
"vitest": "1.3.1",
|
|
210
211
|
"@directus/random": "0.2.7",
|
|
211
|
-
"@directus/
|
|
212
|
-
"@directus/
|
|
212
|
+
"@directus/types": "11.0.7",
|
|
213
|
+
"@directus/tsconfig": "1.0.1"
|
|
213
214
|
},
|
|
214
215
|
"optionalDependencies": {
|
|
215
216
|
"@keyv/redis": "2.8.4",
|