@directus/api 28.0.2 → 28.0.3
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/flows.js +2 -2
- package/dist/services/files.js +16 -9
- package/package.json +13 -13
package/dist/flows.js
CHANGED
|
@@ -239,8 +239,8 @@ class FlowManager {
|
|
|
239
239
|
const keys = await service.readMany(targetKeys, { fields: [primaryField] }, {
|
|
240
240
|
emitEvents: false,
|
|
241
241
|
});
|
|
242
|
-
const allowedKeys = keys.map((key) => key[primaryField]);
|
|
243
|
-
if (targetKeys.some((key) => !allowedKeys.includes(key))) {
|
|
242
|
+
const allowedKeys = keys.map((key) => String(key[primaryField]));
|
|
243
|
+
if (targetKeys.some((key) => !allowedKeys.includes(String(key)))) {
|
|
244
244
|
logger.warn(`Triggering keys ${targetKeys} is not allowed`);
|
|
245
245
|
throw new ForbiddenError();
|
|
246
246
|
}
|
package/dist/services/files.js
CHANGED
|
@@ -56,14 +56,15 @@ export class FilesService extends ItemsService {
|
|
|
56
56
|
primaryKey = await this.createOne(payload, { emitEvents: false });
|
|
57
57
|
}
|
|
58
58
|
const fileExtension = path.extname(payload.filename_download) || (payload.type && '.' + extension(payload.type)) || '';
|
|
59
|
+
const filenameDisk = primaryKey + (fileExtension || '');
|
|
59
60
|
// The filename_disk is the FINAL filename on disk
|
|
60
|
-
payload.filename_disk ||=
|
|
61
|
+
payload.filename_disk ||= filenameDisk;
|
|
61
62
|
// If the filename_disk extension doesn't match the new mimetype, update it
|
|
62
63
|
if (isReplacement === true && path.extname(payload.filename_disk) !== fileExtension) {
|
|
63
|
-
payload.filename_disk =
|
|
64
|
+
payload.filename_disk = filenameDisk;
|
|
64
65
|
}
|
|
65
66
|
// Temp filename is used for replacements
|
|
66
|
-
const tempFilenameDisk = 'temp_' +
|
|
67
|
+
const tempFilenameDisk = 'temp_' + filenameDisk;
|
|
67
68
|
if (!payload.type) {
|
|
68
69
|
payload.type = 'application/octet-stream';
|
|
69
70
|
}
|
|
@@ -119,13 +120,19 @@ export class FilesService extends ItemsService {
|
|
|
119
120
|
}
|
|
120
121
|
// If the file is a replacement, we need to update the DB record with the new payload, delete the old files, and upgrade the temp file
|
|
121
122
|
if (isReplacement === true) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
await disk.
|
|
123
|
+
try {
|
|
124
|
+
await this.updateOne(primaryKey, payload, { emitEvents: false });
|
|
125
|
+
// delete the previously saved file and thumbnails to ensure they're generated fresh
|
|
126
|
+
for await (const filepath of disk.list(String(primaryKey))) {
|
|
127
|
+
await disk.delete(filepath);
|
|
128
|
+
}
|
|
129
|
+
// Upgrade the temp file to the final filename
|
|
130
|
+
await disk.move(tempFilenameDisk, payload.filename_disk);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
await cleanUp();
|
|
134
|
+
throw err;
|
|
126
135
|
}
|
|
127
|
-
// Upgrade the temp file to the final filename
|
|
128
|
-
await disk.move(tempFilenameDisk, payload.filename_disk);
|
|
129
136
|
}
|
|
130
137
|
const { size } = await storage.location(data.storage).stat(payload.filename_disk);
|
|
131
138
|
payload.filesize = size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "28.0.
|
|
3
|
+
"version": "28.0.3",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -152,30 +152,30 @@
|
|
|
152
152
|
"ws": "8.18.1",
|
|
153
153
|
"zod": "3.24.2",
|
|
154
154
|
"zod-validation-error": "3.4.0",
|
|
155
|
-
"@directus/app": "13.11.
|
|
155
|
+
"@directus/app": "13.11.3",
|
|
156
|
+
"@directus/env": "5.1.0",
|
|
157
|
+
"@directus/constants": "13.0.1",
|
|
156
158
|
"@directus/errors": "2.0.2",
|
|
157
159
|
"@directus/extensions": "3.0.7",
|
|
158
|
-
"@directus/env": "5.1.0",
|
|
159
160
|
"@directus/extensions-registry": "3.0.7",
|
|
161
|
+
"@directus/format-title": "12.0.1",
|
|
160
162
|
"@directus/extensions-sdk": "14.0.0",
|
|
161
|
-
"@directus/constants": "13.0.1",
|
|
162
|
-
"@directus/pressure": "3.0.6",
|
|
163
163
|
"@directus/memory": "3.0.6",
|
|
164
|
-
"@directus/
|
|
164
|
+
"@directus/pressure": "3.0.6",
|
|
165
165
|
"@directus/schema": "13.0.1",
|
|
166
166
|
"@directus/schema-builder": "0.0.3",
|
|
167
167
|
"@directus/specs": "11.1.0",
|
|
168
168
|
"@directus/storage": "12.0.0",
|
|
169
|
+
"@directus/storage-driver-azure": "12.0.6",
|
|
169
170
|
"@directus/storage-driver-cloudinary": "12.0.6",
|
|
170
171
|
"@directus/storage-driver-gcs": "12.0.6",
|
|
171
|
-
"@directus/storage-driver-azure": "12.0.6",
|
|
172
|
-
"@directus/storage-driver-s3": "12.0.6",
|
|
173
172
|
"@directus/storage-driver-local": "12.0.0",
|
|
174
173
|
"@directus/storage-driver-supabase": "3.0.6",
|
|
175
|
-
"@directus/utils": "13.0.7",
|
|
176
|
-
"@directus/validation": "2.0.6",
|
|
177
174
|
"@directus/system-data": "3.1.1",
|
|
178
|
-
"directus": "
|
|
175
|
+
"@directus/utils": "13.0.7",
|
|
176
|
+
"@directus/storage-driver-s3": "12.0.6",
|
|
177
|
+
"directus": "11.9.3",
|
|
178
|
+
"@directus/validation": "2.0.6"
|
|
179
179
|
},
|
|
180
180
|
"devDependencies": {
|
|
181
181
|
"@directus/tsconfig": "3.0.0",
|
|
@@ -219,9 +219,9 @@
|
|
|
219
219
|
"knex-mock-client": "3.0.2",
|
|
220
220
|
"typescript": "5.8.2",
|
|
221
221
|
"vitest": "2.1.9",
|
|
222
|
+
"@directus/random": "2.0.1",
|
|
222
223
|
"@directus/schema-builder": "0.0.3",
|
|
223
|
-
"@directus/types": "13.2.0"
|
|
224
|
-
"@directus/random": "2.0.1"
|
|
224
|
+
"@directus/types": "13.2.0"
|
|
225
225
|
},
|
|
226
226
|
"optionalDependencies": {
|
|
227
227
|
"@keyv/redis": "3.0.1",
|