@directus/api 13.1.0 → 13.1.1
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/controllers/files.js +1 -1
- package/dist/env.js +2 -2
- package/dist/services/files.js +1 -1
- package/dist/services/users.d.ts +4 -0
- package/dist/services/users.js +19 -0
- package/package.json +12 -12
|
@@ -76,8 +76,8 @@ export const multipartHandler = (req, res, next) => {
|
|
|
76
76
|
if (!payload.title) {
|
|
77
77
|
payload.title = formatTitle(path.parse(filename).name);
|
|
78
78
|
}
|
|
79
|
-
payload.filename_download = filename;
|
|
80
79
|
}
|
|
80
|
+
payload.filename_download = filename;
|
|
81
81
|
const payloadWithRequiredFields = {
|
|
82
82
|
...payload,
|
|
83
83
|
type: mimeType,
|
package/dist/env.js
CHANGED
|
@@ -358,10 +358,10 @@ async function processConfiguration() {
|
|
|
358
358
|
}
|
|
359
359
|
throw new Error(`Invalid JS configuration file export type. Requires one of "function", "object", received: "${typeof config}"`);
|
|
360
360
|
}
|
|
361
|
-
if (fileExt === '
|
|
361
|
+
if (fileExt === 'json') {
|
|
362
362
|
return require(configPath);
|
|
363
363
|
}
|
|
364
|
-
if (fileExt === '
|
|
364
|
+
if (fileExt === 'yaml' || fileExt === 'yml') {
|
|
365
365
|
const data = requireYAML(configPath);
|
|
366
366
|
if (typeof data === 'object') {
|
|
367
367
|
return data;
|
package/dist/services/files.js
CHANGED
|
@@ -230,7 +230,7 @@ export class FilesService extends ItemsService {
|
|
|
230
230
|
title: formatTitle(filename),
|
|
231
231
|
...(body || {}),
|
|
232
232
|
};
|
|
233
|
-
return await this.uploadOne(decompressResponse(fileResponse.data, fileResponse.headers), payload);
|
|
233
|
+
return await this.uploadOne(decompressResponse(fileResponse.data, fileResponse.headers), payload, payload.id);
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Create a file (only applicable when it is not a multipart/data POST request)
|
package/dist/services/users.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare class UsersService extends ItemsService {
|
|
|
26
26
|
* Create url for inviting users
|
|
27
27
|
*/
|
|
28
28
|
private inviteUrl;
|
|
29
|
+
/**
|
|
30
|
+
* Validate array of emails. Intended to be used with create/update users
|
|
31
|
+
*/
|
|
32
|
+
private validateEmail;
|
|
29
33
|
/**
|
|
30
34
|
* Create a new user
|
|
31
35
|
*/
|
package/dist/services/users.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSimpleHash, toArray } from '@directus/utils';
|
|
2
2
|
import { FailedValidationError, joiValidationErrorItemToErrorExtensions } from '@directus/validation';
|
|
3
|
+
import Joi from 'joi';
|
|
3
4
|
import jwt from 'jsonwebtoken';
|
|
4
5
|
import { cloneDeep, isEmpty } from 'lodash-es';
|
|
5
6
|
import { performance } from 'perf_hooks';
|
|
@@ -130,6 +131,22 @@ export class UsersService extends ItemsService {
|
|
|
130
131
|
inviteURL.setQuery('token', token);
|
|
131
132
|
return inviteURL.toString();
|
|
132
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Validate array of emails. Intended to be used with create/update users
|
|
136
|
+
*/
|
|
137
|
+
validateEmail(input) {
|
|
138
|
+
const emails = Array.isArray(input) ? input : [input];
|
|
139
|
+
const schema = Joi.string().email().required();
|
|
140
|
+
for (const email of emails) {
|
|
141
|
+
const { error } = schema.validate(email);
|
|
142
|
+
if (error) {
|
|
143
|
+
throw new FailedValidationError({
|
|
144
|
+
field: 'email',
|
|
145
|
+
type: 'email',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
133
150
|
/**
|
|
134
151
|
* Create a new user
|
|
135
152
|
*/
|
|
@@ -145,6 +162,7 @@ export class UsersService extends ItemsService {
|
|
|
145
162
|
const passwords = data['map']((payload) => payload['password']).filter((password) => password);
|
|
146
163
|
try {
|
|
147
164
|
if (emails.length) {
|
|
165
|
+
this.validateEmail(emails);
|
|
148
166
|
await this.checkUniqueEmails(emails);
|
|
149
167
|
}
|
|
150
168
|
if (passwords.length) {
|
|
@@ -212,6 +230,7 @@ export class UsersService extends ItemsService {
|
|
|
212
230
|
field: 'email',
|
|
213
231
|
});
|
|
214
232
|
}
|
|
233
|
+
this.validateEmail(data['email']);
|
|
215
234
|
await this.checkUniqueEmails([data['email']], keys[0]);
|
|
216
235
|
}
|
|
217
236
|
if (data['password']) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.1",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -143,22 +143,22 @@
|
|
|
143
143
|
"ws": "8.12.1",
|
|
144
144
|
"zod": "3.21.4",
|
|
145
145
|
"zod-validation-error": "1.0.1",
|
|
146
|
-
"@directus/app": "10.
|
|
146
|
+
"@directus/app": "10.9.0",
|
|
147
147
|
"@directus/constants": "10.2.3",
|
|
148
148
|
"@directus/errors": "0.0.2",
|
|
149
|
-
"@directus/extensions-sdk": "10.1.
|
|
150
|
-
"@directus/pressure": "1.0.
|
|
149
|
+
"@directus/extensions-sdk": "10.1.11",
|
|
150
|
+
"@directus/pressure": "1.0.10",
|
|
151
151
|
"@directus/schema": "10.0.2",
|
|
152
152
|
"@directus/specs": "10.2.0",
|
|
153
153
|
"@directus/storage": "10.0.5",
|
|
154
|
-
"@directus/storage-driver-azure": "10.0.
|
|
155
|
-
"@directus/storage-driver-cloudinary": "10.0.
|
|
156
|
-
"@directus/storage-driver-gcs": "10.0.
|
|
157
|
-
"@directus/storage-driver-local": "10.0.
|
|
158
|
-
"@directus/storage-driver-s3": "10.0.
|
|
159
|
-
"@directus/storage-driver-supabase": "1.0.
|
|
160
|
-
"@directus/utils": "10.0.
|
|
161
|
-
"@directus/validation": "0.0.
|
|
154
|
+
"@directus/storage-driver-azure": "10.0.11",
|
|
155
|
+
"@directus/storage-driver-cloudinary": "10.0.11",
|
|
156
|
+
"@directus/storage-driver-gcs": "10.0.11",
|
|
157
|
+
"@directus/storage-driver-local": "10.0.11",
|
|
158
|
+
"@directus/storage-driver-s3": "10.0.11",
|
|
159
|
+
"@directus/storage-driver-supabase": "1.0.3",
|
|
160
|
+
"@directus/utils": "10.0.11",
|
|
161
|
+
"@directus/validation": "0.0.6"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@ngneat/falso": "6.4.0",
|