@directus/api 19.0.1 → 19.0.2
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.
|
@@ -114,7 +114,8 @@ router.post('/cache/clear', asyncHandler(async (req, res) => {
|
|
|
114
114
|
accountability: req.accountability,
|
|
115
115
|
schema: req.schema,
|
|
116
116
|
});
|
|
117
|
-
|
|
117
|
+
const clearSystemCache = 'system' in req.query && (req.query['system'] === '' || Boolean(req.query['system']));
|
|
118
|
+
await service.clearCache({ system: clearSystemCache });
|
|
118
119
|
res.status(200).end();
|
|
119
120
|
}));
|
|
120
121
|
export default router;
|
package/dist/services/utils.d.ts
CHANGED
package/dist/services/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ForbiddenError, InvalidPayloadError } from '@directus/errors';
|
|
2
2
|
import { systemCollectionRows } from '@directus/system-data';
|
|
3
|
-
import {
|
|
3
|
+
import { clearSystemCache, getCache } from '../cache.js';
|
|
4
4
|
import getDatabase from '../database/index.js';
|
|
5
5
|
import emitter from '../emitter.js';
|
|
6
6
|
import { shouldClearCache } from '../utils/should-clear-cache.js';
|
|
@@ -112,10 +112,14 @@ export class UtilsService {
|
|
|
112
112
|
accountability: this.accountability,
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
async clearCache() {
|
|
115
|
+
async clearCache({ system }) {
|
|
116
116
|
if (this.accountability?.admin !== true) {
|
|
117
117
|
throw new ForbiddenError();
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
const { cache } = getCache();
|
|
120
|
+
if (system) {
|
|
121
|
+
await clearSystemCache({ forced: true });
|
|
122
|
+
}
|
|
123
|
+
return cache?.clear();
|
|
120
124
|
}
|
|
121
125
|
}
|
|
@@ -16,6 +16,9 @@ export function getCacheControlHeader(req, ttl, globalCacheSettings, personalize
|
|
|
16
16
|
// When the resource / current request shouldn't be cached
|
|
17
17
|
if (ttl === undefined || ttl < 0)
|
|
18
18
|
return 'no-cache';
|
|
19
|
+
// When the API cache can invalidate at any moment
|
|
20
|
+
if (globalCacheSettings && env['CACHE_AUTO_PURGE'] === true)
|
|
21
|
+
return 'no-cache';
|
|
19
22
|
const headerValues = [];
|
|
20
23
|
// When caching depends on the authentication status of the users
|
|
21
24
|
if (personalized) {
|
package/dist/utils/get-schema.js
CHANGED
|
@@ -34,24 +34,33 @@ export async function getSchema(options, attempt = 0) {
|
|
|
34
34
|
const lockKey = 'schemaCache--preparing';
|
|
35
35
|
const messageKey = 'schemaCache--done';
|
|
36
36
|
const processId = await lock.increment(lockKey);
|
|
37
|
+
if (processId >= env['CACHE_SCHEMA_MAX_ITERATIONS']) {
|
|
38
|
+
await lock.delete(lockKey);
|
|
39
|
+
}
|
|
37
40
|
const currentProcessShouldHandleOperation = processId === 1;
|
|
38
41
|
if (currentProcessShouldHandleOperation === false) {
|
|
39
42
|
logger.trace('Schema cache is prepared in another process, waiting for result.');
|
|
40
|
-
return new Promise((resolve) => {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
41
44
|
const TIMEOUT = 10000;
|
|
42
|
-
|
|
43
|
-
const callback = async () => {
|
|
44
|
-
if (timeout)
|
|
45
|
-
clearTimeout(timeout);
|
|
46
|
-
const schema = await getSchema(options, attempt + 1);
|
|
47
|
-
resolve(schema);
|
|
48
|
-
bus.unsubscribe(messageKey, callback);
|
|
49
|
-
};
|
|
50
|
-
bus.subscribe(messageKey, callback);
|
|
51
|
-
timeout = setTimeout(async () => {
|
|
45
|
+
const timeout = setTimeout(() => {
|
|
52
46
|
logger.trace('Did not receive schema callback message in time. Pulling schema...');
|
|
53
|
-
callback();
|
|
47
|
+
callback().catch(reject);
|
|
54
48
|
}, TIMEOUT);
|
|
49
|
+
bus.subscribe(messageKey, callback);
|
|
50
|
+
async function callback() {
|
|
51
|
+
try {
|
|
52
|
+
if (timeout)
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
const schema = await getSchema(options, attempt + 1);
|
|
55
|
+
resolve(schema);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
reject(error);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
bus.unsubscribe(messageKey, callback);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
66
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.2",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -146,29 +146,29 @@
|
|
|
146
146
|
"ws": "8.16.0",
|
|
147
147
|
"zod": "3.22.4",
|
|
148
148
|
"zod-validation-error": "3.0.3",
|
|
149
|
-
"@directus/
|
|
150
|
-
"@directus/
|
|
151
|
-
"@directus/errors": "0.2.4",
|
|
152
|
-
"@directus/extensions-registry": "1.0.3",
|
|
153
|
-
"@directus/constants": "11.0.3",
|
|
149
|
+
"@directus/env": "1.1.2",
|
|
150
|
+
"@directus/app": "12.0.2",
|
|
154
151
|
"@directus/extensions": "1.0.3",
|
|
152
|
+
"@directus/constants": "11.0.3",
|
|
153
|
+
"@directus/extensions-registry": "1.0.3",
|
|
154
|
+
"@directus/errors": "0.2.4",
|
|
155
155
|
"@directus/extensions-sdk": "11.0.3",
|
|
156
156
|
"@directus/format-title": "10.1.1",
|
|
157
|
-
"@directus/memory": "1.0.6",
|
|
158
157
|
"@directus/pressure": "1.0.18",
|
|
159
158
|
"@directus/schema": "11.0.1",
|
|
159
|
+
"@directus/memory": "1.0.6",
|
|
160
160
|
"@directus/specs": "10.2.8",
|
|
161
161
|
"@directus/storage-driver-azure": "10.0.19",
|
|
162
|
-
"@directus/storage": "10.0.11",
|
|
163
162
|
"@directus/storage-driver-gcs": "10.0.19",
|
|
164
163
|
"@directus/storage-driver-cloudinary": "10.0.19",
|
|
164
|
+
"@directus/storage-driver-local": "10.0.18",
|
|
165
|
+
"@directus/storage": "10.0.11",
|
|
165
166
|
"@directus/storage-driver-s3": "10.0.20",
|
|
166
167
|
"@directus/storage-driver-supabase": "1.0.11",
|
|
167
|
-
"@directus/storage-driver-local": "10.0.18",
|
|
168
168
|
"@directus/system-data": "1.0.2",
|
|
169
|
-
"
|
|
169
|
+
"directus": "10.10.7",
|
|
170
170
|
"@directus/utils": "11.0.7",
|
|
171
|
-
"directus": "
|
|
171
|
+
"@directus/validation": "0.0.14"
|
|
172
172
|
},
|
|
173
173
|
"devDependencies": {
|
|
174
174
|
"@ngneat/falso": "7.2.0",
|