directus 9.9.0 → 9.11.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/README.md +1 -1
- package/dist/app.js +3 -0
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +14 -11
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +14 -11
- package/dist/cli/commands/schema/apply.js +4 -3
- package/dist/controllers/assets.js +8 -9
- package/dist/controllers/files.js +3 -0
- package/dist/database/helpers/date/dialects/sqlite.js +6 -2
- package/dist/database/helpers/fn/dialects/postgres.js +5 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +2 -1
- package/dist/database/migrations/20210506A-rename-interfaces.js +2 -1
- package/dist/database/migrations/20210802A-replace-groups.js +2 -1
- package/dist/database/migrations/20210805A-update-groups.js +2 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +3 -2
- package/dist/database/migrations/20211007A-update-presets.js +5 -4
- package/dist/database/run-ast.js +11 -15
- package/dist/database/system-data/fields/collections.yaml +1 -1
- package/dist/env.js +8 -3
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +1 -0
- package/dist/exceptions/invalid-provider.d.ts +4 -0
- package/dist/exceptions/invalid-provider.js +10 -0
- package/dist/exceptions/range-not-satisfiable.d.ts +2 -2
- package/dist/exceptions/range-not-satisfiable.js +5 -1
- package/dist/middleware/graphql.js +2 -1
- package/dist/services/assets.js +27 -1
- package/dist/services/authentication.js +4 -1
- package/dist/services/collections.js +2 -0
- package/dist/services/fields.js +17 -8
- package/dist/services/graphql.js +75 -34
- package/dist/services/import-export.d.ts +1 -1
- package/dist/services/import-export.js +14 -11
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +20 -6
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +11 -8
- package/dist/services/specifications.js +1 -3
- package/dist/services/users.d.ts +4 -0
- package/dist/services/users.js +24 -1
- package/dist/utils/{apply-query.d.ts → apply-query/index.d.ts} +2 -1
- package/dist/utils/apply-query/index.js +394 -0
- package/dist/utils/apply-query/operators/between.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/between.operator.js +16 -0
- package/dist/utils/apply-query/operators/contains.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/contains.operator.js +9 -0
- package/dist/utils/apply-query/operators/ends-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/ends-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/greather-than-equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/greather-than-equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/greather-than.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/greather-than.operator.js +9 -0
- package/dist/utils/apply-query/operators/in.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/in.operator.js +14 -0
- package/dist/utils/apply-query/operators/index.d.ts +3 -0
- package/dist/utils/apply-query/operators/index.js +72 -0
- package/dist/utils/apply-query/operators/insensitive-contains.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-contains.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-ends-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-ends-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-not-contains.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-not-contains.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-not-ends-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-not-ends-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-not-equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-not-equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-not-starts-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-not-starts-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/insensitive-starts-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/insensitive-starts-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/intersects-bbox.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/intersects-bbox.operator.js +9 -0
- package/dist/utils/apply-query/operators/intersects.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/intersects.operator.js +9 -0
- package/dist/utils/apply-query/operators/is-empty.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/is-empty.operator.js +14 -0
- package/dist/utils/apply-query/operators/is-not-empty.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/is-not-empty.operator.js +14 -0
- package/dist/utils/apply-query/operators/is-not-null.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/is-not-null.operator.js +14 -0
- package/dist/utils/apply-query/operators/is-null.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/is-null.operator.js +14 -0
- package/dist/utils/apply-query/operators/less-than-equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/less-than-equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/less-than.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/less-than.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-between.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-between.operator.js +16 -0
- package/dist/utils/apply-query/operators/not-contains.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-contains.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-ends-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-ends-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-equals.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-equals.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-in.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-in.operator.js +14 -0
- package/dist/utils/apply-query/operators/not-intersects-bbox.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-intersects-bbox.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-intersects.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-intersects.operator.js +9 -0
- package/dist/utils/apply-query/operators/not-starts-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/not-starts-with.operator.js +9 -0
- package/dist/utils/apply-query/operators/operator-register.d.ts +13 -0
- package/dist/utils/apply-query/operators/operator-register.js +7 -0
- package/dist/utils/apply-query/operators/starts-with.operator.d.ts +2 -0
- package/dist/utils/apply-query/operators/starts-with.operator.js +9 -0
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +64 -49
- package/dist/utils/get-ast-from-query.js +10 -4
- package/dist/utils/get-column-path.d.ts +16 -0
- package/dist/utils/get-column-path.js +46 -0
- package/dist/utils/get-default-value.js +4 -3
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +9 -8
- package/dist/utils/get-relation-info.d.ts +7 -0
- package/dist/utils/get-relation-info.js +45 -0
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-schema.js +5 -1
- package/dist/utils/get-snapshot.js +22 -4
- package/dist/utils/merge-permissions-for-share.js +1 -1
- package/dist/utils/parse-json.d.ts +5 -0
- package/dist/utils/parse-json.js +19 -0
- package/dist/utils/reduce-schema.js +18 -11
- package/dist/utils/sanitize-query.d.ts +1 -2
- package/dist/utils/sanitize-query.js +6 -5
- package/package.json +16 -18
- package/dist/utils/apply-query.js +0 -498
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ view, author, and manage your raw database content. Our performant and flexible
|
|
|
16
16
|
schema, and includes rule-based permissions, event/web hooks, custom endpoints, numerous auth options, configurable
|
|
17
17
|
storage adapters, and much more.
|
|
18
18
|
|
|
19
|
-
Current database support includes: PostgreSQL, MySQL, SQLite, MS-SQL Server, OracleDB, MariaDB, and
|
|
19
|
+
Current database support includes: PostgreSQL, MySQL, SQLite, MS-SQL Server, OracleDB, MariaDB, and variants such as AWS
|
|
20
20
|
Aurora/Redshift or Google Cloud Platform SQL.
|
|
21
21
|
|
|
22
22
|
Learn more at...
|
package/dist/app.js
CHANGED
|
@@ -119,6 +119,9 @@ async function createApp() {
|
|
|
119
119
|
connectSrc: ["'self'", 'https://*'],
|
|
120
120
|
},
|
|
121
121
|
}, (0, get_config_from_env_1.getConfigFromEnv)('CONTENT_SECURITY_POLICY_'))));
|
|
122
|
+
if (env_1.default.HSTS_ENABLED) {
|
|
123
|
+
app.use(helmet_1.default.hsts((0, get_config_from_env_1.getConfigFromEnv)('HSTS_', ['HSTS_ENABLED'])));
|
|
124
|
+
}
|
|
122
125
|
await emitter_1.default.emitInit('app.before', { app });
|
|
123
126
|
await emitter_1.default.emitInit('middlewares.before', { app });
|
|
124
127
|
app.use(logger_1.expressLogger);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { Client } from 'openid-client';
|
|
3
|
-
import { LocalAuthDriver } from './local';
|
|
4
3
|
import { UsersService } from '../../services';
|
|
5
4
|
import { AuthDriverOptions, User } from '../../types';
|
|
5
|
+
import { LocalAuthDriver } from './local';
|
|
6
6
|
export declare class OAuth2AuthDriver extends LocalAuthDriver {
|
|
7
7
|
client: Client;
|
|
8
8
|
redirectUrl: string;
|
|
@@ -5,21 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createOAuth2AuthRouter = exports.OAuth2AuthDriver = void 0;
|
|
7
7
|
const express_1 = require("express");
|
|
8
|
-
const
|
|
8
|
+
const flat_1 = __importDefault(require("flat"));
|
|
9
9
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
10
10
|
const ms_1 = __importDefault(require("ms"));
|
|
11
|
-
const
|
|
12
|
-
const local_1 = require("./local");
|
|
11
|
+
const openid_client_1 = require("openid-client");
|
|
13
12
|
const auth_1 = require("../../auth");
|
|
14
13
|
const env_1 = __importDefault(require("../../env"));
|
|
15
|
-
const services_1 = require("../../services");
|
|
16
14
|
const exceptions_1 = require("../../exceptions");
|
|
15
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
17
16
|
const respond_1 = require("../../middleware/respond");
|
|
17
|
+
const services_1 = require("../../services");
|
|
18
18
|
const async_handler_1 = __importDefault(require("../../utils/async-handler"));
|
|
19
|
-
const url_1 = require("../../utils/url");
|
|
20
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
21
|
-
const get_ip_from_req_1 = require("../../utils/get-ip-from-req");
|
|
22
19
|
const get_config_from_env_1 = require("../../utils/get-config-from-env");
|
|
20
|
+
const get_ip_from_req_1 = require("../../utils/get-ip-from-req");
|
|
21
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
22
|
+
const url_1 = require("../../utils/url");
|
|
23
|
+
const local_1 = require("./local");
|
|
23
24
|
class OAuth2AuthDriver extends local_1.LocalAuthDriver {
|
|
24
25
|
constructor(options, config) {
|
|
25
26
|
super(options, config);
|
|
@@ -78,7 +79,6 @@ class OAuth2AuthDriver extends local_1.LocalAuthDriver {
|
|
|
78
79
|
return user === null || user === void 0 ? void 0 : user.id;
|
|
79
80
|
}
|
|
80
81
|
async getUserID(payload) {
|
|
81
|
-
var _a;
|
|
82
82
|
if (!payload.code || !payload.codeVerifier) {
|
|
83
83
|
logger_1.default.trace('[OAuth2] No code or codeVerifier in payload');
|
|
84
84
|
throw new exceptions_1.InvalidCredentialsException();
|
|
@@ -95,9 +95,9 @@ class OAuth2AuthDriver extends local_1.LocalAuthDriver {
|
|
|
95
95
|
// Flatten response to support dot indexes
|
|
96
96
|
userInfo = (0, flat_1.default)(userInfo);
|
|
97
97
|
const { provider, emailKey, identifierKey, allowPublicRegistration } = this.config;
|
|
98
|
-
const email = userInfo[emailKey !== null && emailKey !== void 0 ? emailKey : 'email'];
|
|
98
|
+
const email = userInfo[emailKey !== null && emailKey !== void 0 ? emailKey : 'email'] ? String(userInfo[emailKey !== null && emailKey !== void 0 ? emailKey : 'email']) : undefined;
|
|
99
99
|
// Fallback to email if explicit identifier not found
|
|
100
|
-
const identifier =
|
|
100
|
+
const identifier = userInfo[identifierKey] ? String(userInfo[identifierKey]) : email;
|
|
101
101
|
if (!identifier) {
|
|
102
102
|
logger_1.default.warn(`[OAuth2] Failed to find user identifier for provider "${provider}"`);
|
|
103
103
|
throw new exceptions_1.InvalidCredentialsException();
|
|
@@ -135,7 +135,7 @@ class OAuth2AuthDriver extends local_1.LocalAuthDriver {
|
|
|
135
135
|
let authData = user.auth_data;
|
|
136
136
|
if (typeof authData === 'string') {
|
|
137
137
|
try {
|
|
138
|
-
authData =
|
|
138
|
+
authData = (0, parse_json_1.parseJSON)(authData);
|
|
139
139
|
}
|
|
140
140
|
catch {
|
|
141
141
|
logger_1.default.warn(`[OAuth2] Session data isn't valid JSON: ${authData}`);
|
|
@@ -243,6 +243,9 @@ function createOAuth2AuthRouter(providerName) {
|
|
|
243
243
|
else if (error instanceof exceptions_1.InvalidTokenException) {
|
|
244
244
|
reason = 'INVALID_TOKEN';
|
|
245
245
|
}
|
|
246
|
+
else if (error instanceof exceptions_1.InvalidProviderException) {
|
|
247
|
+
reason = 'INVALID_PROVIDER';
|
|
248
|
+
}
|
|
246
249
|
else {
|
|
247
250
|
logger_1.default.warn(error, `[OAuth2] Unexpected error during OAuth2 login`);
|
|
248
251
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { Client } from 'openid-client';
|
|
3
|
-
import { LocalAuthDriver } from './local';
|
|
4
3
|
import { UsersService } from '../../services';
|
|
5
4
|
import { AuthDriverOptions, User } from '../../types';
|
|
5
|
+
import { LocalAuthDriver } from './local';
|
|
6
6
|
export declare class OpenIDAuthDriver extends LocalAuthDriver {
|
|
7
7
|
client: Promise<Client>;
|
|
8
8
|
redirectUrl: string;
|
|
@@ -5,21 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createOpenIDAuthRouter = exports.OpenIDAuthDriver = void 0;
|
|
7
7
|
const express_1 = require("express");
|
|
8
|
-
const
|
|
8
|
+
const flat_1 = __importDefault(require("flat"));
|
|
9
9
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
10
10
|
const ms_1 = __importDefault(require("ms"));
|
|
11
|
-
const
|
|
12
|
-
const local_1 = require("./local");
|
|
11
|
+
const openid_client_1 = require("openid-client");
|
|
13
12
|
const auth_1 = require("../../auth");
|
|
14
13
|
const env_1 = __importDefault(require("../../env"));
|
|
15
|
-
const services_1 = require("../../services");
|
|
16
14
|
const exceptions_1 = require("../../exceptions");
|
|
15
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
17
16
|
const respond_1 = require("../../middleware/respond");
|
|
17
|
+
const services_1 = require("../../services");
|
|
18
18
|
const async_handler_1 = __importDefault(require("../../utils/async-handler"));
|
|
19
|
-
const url_1 = require("../../utils/url");
|
|
20
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
21
|
-
const get_ip_from_req_1 = require("../../utils/get-ip-from-req");
|
|
22
19
|
const get_config_from_env_1 = require("../../utils/get-config-from-env");
|
|
20
|
+
const get_ip_from_req_1 = require("../../utils/get-ip-from-req");
|
|
21
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
22
|
+
const url_1 = require("../../utils/url");
|
|
23
|
+
const local_1 = require("./local");
|
|
23
24
|
class OpenIDAuthDriver extends local_1.LocalAuthDriver {
|
|
24
25
|
constructor(options, config) {
|
|
25
26
|
super(options, config);
|
|
@@ -85,7 +86,6 @@ class OpenIDAuthDriver extends local_1.LocalAuthDriver {
|
|
|
85
86
|
return user === null || user === void 0 ? void 0 : user.id;
|
|
86
87
|
}
|
|
87
88
|
async getUserID(payload) {
|
|
88
|
-
var _a;
|
|
89
89
|
if (!payload.code || !payload.codeVerifier) {
|
|
90
90
|
logger_1.default.trace('[OpenID] No code or codeVerifier in payload');
|
|
91
91
|
throw new exceptions_1.InvalidCredentialsException();
|
|
@@ -109,9 +109,9 @@ class OpenIDAuthDriver extends local_1.LocalAuthDriver {
|
|
|
109
109
|
// Flatten response to support dot indexes
|
|
110
110
|
userInfo = (0, flat_1.default)(userInfo);
|
|
111
111
|
const { provider, identifierKey, allowPublicRegistration, requireVerifiedEmail } = this.config;
|
|
112
|
-
const email = userInfo.email;
|
|
112
|
+
const email = userInfo.email ? String(userInfo.email) : undefined;
|
|
113
113
|
// Fallback to email if explicit identifier not found
|
|
114
|
-
const identifier =
|
|
114
|
+
const identifier = userInfo[identifierKey !== null && identifierKey !== void 0 ? identifierKey : 'sub'] ? String(userInfo[identifierKey !== null && identifierKey !== void 0 ? identifierKey : 'sub']) : email;
|
|
115
115
|
if (!identifier) {
|
|
116
116
|
logger_1.default.warn(`[OpenID] Failed to find user identifier for provider "${provider}"`);
|
|
117
117
|
throw new exceptions_1.InvalidCredentialsException();
|
|
@@ -150,7 +150,7 @@ class OpenIDAuthDriver extends local_1.LocalAuthDriver {
|
|
|
150
150
|
let authData = user.auth_data;
|
|
151
151
|
if (typeof authData === 'string') {
|
|
152
152
|
try {
|
|
153
|
-
authData =
|
|
153
|
+
authData = (0, parse_json_1.parseJSON)(authData);
|
|
154
154
|
}
|
|
155
155
|
catch {
|
|
156
156
|
logger_1.default.warn(`[OpenID] Session data isn't valid JSON: ${authData}`);
|
|
@@ -260,6 +260,9 @@ function createOpenIDAuthRouter(providerName) {
|
|
|
260
260
|
else if (error instanceof exceptions_1.InvalidTokenException) {
|
|
261
261
|
reason = 'INVALID_TOKEN';
|
|
262
262
|
}
|
|
263
|
+
else if (error instanceof exceptions_1.InvalidProviderException) {
|
|
264
|
+
reason = 'INVALID_PROVIDER';
|
|
265
|
+
}
|
|
263
266
|
else {
|
|
264
267
|
logger_1.default.warn(error, `[OpenID] Unexpected error during OpenID login`);
|
|
265
268
|
}
|
|
@@ -28,12 +28,13 @@ const fs_1 = require("fs");
|
|
|
28
28
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
29
29
|
const js_yaml_1 = require("js-yaml");
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const cache_1 = require("../../../cache");
|
|
31
32
|
const database_1 = __importStar(require("../../../database"));
|
|
32
33
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
34
|
+
const apply_snapshot_1 = require("../../../utils/apply-snapshot");
|
|
33
35
|
const get_snapshot_1 = require("../../../utils/get-snapshot");
|
|
34
36
|
const get_snapshot_diff_1 = require("../../../utils/get-snapshot-diff");
|
|
35
|
-
const
|
|
36
|
-
const cache_1 = require("../../../cache");
|
|
37
|
+
const parse_json_1 = require("../../../utils/parse-json");
|
|
37
38
|
async function apply(snapshotPath, options) {
|
|
38
39
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
39
40
|
const filename = path_1.default.resolve(process.cwd(), snapshotPath);
|
|
@@ -52,7 +53,7 @@ async function apply(snapshotPath, options) {
|
|
|
52
53
|
snapshot = (await (0, js_yaml_1.load)(fileContents));
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
|
-
snapshot =
|
|
56
|
+
snapshot = (0, parse_json_1.parseJSON)(fileContents);
|
|
56
57
|
}
|
|
57
58
|
const currentSnapshot = await (0, get_snapshot_1.getSnapshot)({ database });
|
|
58
59
|
const snapshotDiff = (0, get_snapshot_diff_1.getSnapshotDiff)(currentSnapshot, snapshot);
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const express_1 = require("express");
|
|
7
|
+
const helmet_1 = __importDefault(require("helmet"));
|
|
7
8
|
const lodash_1 = require("lodash");
|
|
8
9
|
const ms_1 = __importDefault(require("ms"));
|
|
9
10
|
const constants_1 = require("../constants");
|
|
@@ -14,9 +15,8 @@ const use_collection_1 = __importDefault(require("../middleware/use-collection")
|
|
|
14
15
|
const services_1 = require("../services");
|
|
15
16
|
const assets_1 = require("../types/assets");
|
|
16
17
|
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
17
|
-
const helmet_1 = __importDefault(require("helmet"));
|
|
18
|
-
const lodash_2 = require("lodash");
|
|
19
18
|
const get_config_from_env_1 = require("../utils/get-config-from-env");
|
|
19
|
+
const parse_json_1 = require("../utils/parse-json");
|
|
20
20
|
const router = (0, express_1.Router)();
|
|
21
21
|
router.use((0, use_collection_1.default)('directus_files'));
|
|
22
22
|
router.get('/:pk',
|
|
@@ -41,7 +41,7 @@ router.get('/:pk',
|
|
|
41
41
|
let transforms;
|
|
42
42
|
// Try parse the JSON array
|
|
43
43
|
try {
|
|
44
|
-
transforms =
|
|
44
|
+
transforms = (0, parse_json_1.parseJSON)(transformation['transforms']);
|
|
45
45
|
}
|
|
46
46
|
catch {
|
|
47
47
|
throw new exceptions_1.InvalidQueryException(`"transforms" Parameter needs to be a JSON array of allowed transformations.`);
|
|
@@ -91,7 +91,7 @@ router.get('/:pk',
|
|
|
91
91
|
return next();
|
|
92
92
|
throw new exceptions_1.InvalidQueryException(`Dynamic asset generation has been disabled for this project.`);
|
|
93
93
|
}
|
|
94
|
-
}), helmet_1.default.contentSecurityPolicy((0,
|
|
94
|
+
}), helmet_1.default.contentSecurityPolicy((0, lodash_1.merge)({
|
|
95
95
|
useDefaults: false,
|
|
96
96
|
directives: {
|
|
97
97
|
defaultSrc: ['none'],
|
|
@@ -110,11 +110,10 @@ router.get('/:pk',
|
|
|
110
110
|
: res.locals.transformation;
|
|
111
111
|
let range = undefined;
|
|
112
112
|
if (req.headers.range) {
|
|
113
|
-
|
|
114
|
-
const rangeParts = req.headers.range.substring(6).split('-');
|
|
113
|
+
const rangeParts = /bytes=([0-9]*)-([0-9]*)/.exec(req.headers.range);
|
|
115
114
|
range = {
|
|
116
|
-
start: rangeParts[
|
|
117
|
-
end: rangeParts[
|
|
115
|
+
start: (rangeParts === null || rangeParts === void 0 ? void 0 : rangeParts[1]) ? Number(rangeParts[1]) : undefined,
|
|
116
|
+
end: (rangeParts === null || rangeParts === void 0 ? void 0 : rangeParts[2]) ? Number(rangeParts[2]) : undefined,
|
|
118
117
|
};
|
|
119
118
|
if (Number.isNaN(range.start) || Number.isNaN(range.end)) {
|
|
120
119
|
throw new exceptions_1.RangeNotSatisfiableException(range);
|
|
@@ -134,7 +133,7 @@ router.get('/:pk',
|
|
|
134
133
|
if (range) {
|
|
135
134
|
res.setHeader('Content-Range', `bytes ${range.start}-${range.end || stat.size - 1}/${stat.size}`);
|
|
136
135
|
res.status(206);
|
|
137
|
-
res.setHeader('Content-Length', (range.end ? range.end + 1 : stat.size) - range.start);
|
|
136
|
+
res.setHeader('Content-Length', (range.end ? range.end + 1 : stat.size) - (range.start || 0));
|
|
138
137
|
}
|
|
139
138
|
else {
|
|
140
139
|
res.setHeader('Content-Length', stat.size);
|
|
@@ -58,6 +58,9 @@ const multipartHandler = (req, res, next) => {
|
|
|
58
58
|
payload[fieldname] = fieldValue;
|
|
59
59
|
});
|
|
60
60
|
busboy.on('file', async (fieldname, fileStream, filename, encoding, mimetype) => {
|
|
61
|
+
if (!filename) {
|
|
62
|
+
return busboy.emit('error', new exceptions_1.InvalidPayloadException(`File is missing filename`));
|
|
63
|
+
}
|
|
61
64
|
fileCount++;
|
|
62
65
|
if (!payload.title) {
|
|
63
66
|
payload.title = (0, format_title_1.default)(path_1.default.parse(filename).name);
|
|
@@ -4,8 +4,12 @@ exports.DateHelperSQLite = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
class DateHelperSQLite extends types_1.DateHelper {
|
|
6
6
|
parse(date) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Return the time as string
|
|
8
|
+
if (date.length <= 8 && date.includes(':')) {
|
|
9
|
+
return date;
|
|
10
|
+
}
|
|
11
|
+
// Return dates in epoch milliseconds
|
|
12
|
+
return String(new Date(date).getTime());
|
|
9
13
|
}
|
|
10
14
|
fieldFlagForField(fieldType) {
|
|
11
15
|
switch (fieldType) {
|
|
@@ -31,7 +31,11 @@ class FnHelperPostgres extends types_1.FnHelper {
|
|
|
31
31
|
var _a, _b, _c, _d, _e;
|
|
32
32
|
const type = (_e = (_d = (_c = (_b = (_a = this.schema.collections) === null || _a === void 0 ? void 0 : _a[table]) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c[column]) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : 'unknown';
|
|
33
33
|
if (type === 'json') {
|
|
34
|
-
|
|
34
|
+
const { dbType } = this.schema.collections[table].fields[column];
|
|
35
|
+
return this.knex.raw(dbType === 'jsonb' ? 'jsonb_array_length(??.??)' : 'json_array_length(??.??)', [
|
|
36
|
+
table,
|
|
37
|
+
column,
|
|
38
|
+
]);
|
|
35
39
|
}
|
|
36
40
|
if (type === 'alias') {
|
|
37
41
|
return this._relationalCount(table, column);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
4
5
|
async function up(knex) {
|
|
5
6
|
var _a;
|
|
6
7
|
await knex.schema.alterTable('directus_relations', (table) => {
|
|
@@ -11,7 +12,7 @@ async function up(knex) {
|
|
|
11
12
|
.from('directus_fields')
|
|
12
13
|
.whereIn('interface', ['one-to-many', 'm2a-builder', 'many-to-many']);
|
|
13
14
|
for (const field of fieldsWithSort) {
|
|
14
|
-
const options = typeof field.options === 'string' ?
|
|
15
|
+
const options = typeof field.options === 'string' ? (0, parse_json_1.parseJSON)(field.options) : (_a = field.options) !== null && _a !== void 0 ? _a : {};
|
|
15
16
|
if ('sortField' in options) {
|
|
16
17
|
await knex('directus_relations')
|
|
17
18
|
.update({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
4
5
|
// [before, after, after-option additions]
|
|
5
6
|
const changes = [
|
|
6
7
|
['button-links', 'presentation-links'],
|
|
@@ -54,7 +55,7 @@ async function up(knex) {
|
|
|
54
55
|
.from('directus_fields')
|
|
55
56
|
.where({ interface: before });
|
|
56
57
|
for (const { id, options: existingOptionsRaw } of fields) {
|
|
57
|
-
const existingOptions = typeof existingOptionsRaw === 'string' ?
|
|
58
|
+
const existingOptions = typeof existingOptionsRaw === 'string' ? (0, parse_json_1.parseJSON)(existingOptionsRaw) : existingOptionsRaw;
|
|
58
59
|
const newOptions = {
|
|
59
60
|
...(existingOptions || {}),
|
|
60
61
|
...options,
|
|
@@ -5,13 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.down = exports.up = void 0;
|
|
7
7
|
const logger_1 = __importDefault(require("../../logger"));
|
|
8
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
8
9
|
async function up(knex) {
|
|
9
10
|
const dividerGroups = await knex.select('*').from('directus_fields').where('interface', '=', 'group-divider');
|
|
10
11
|
for (const dividerGroup of dividerGroups) {
|
|
11
12
|
const newOptions = { showHeader: true };
|
|
12
13
|
if (dividerGroup.options) {
|
|
13
14
|
try {
|
|
14
|
-
const options = typeof dividerGroup.options === 'string' ?
|
|
15
|
+
const options = typeof dividerGroup.options === 'string' ? (0, parse_json_1.parseJSON)(dividerGroup.options) : dividerGroup.options;
|
|
15
16
|
if (options.icon)
|
|
16
17
|
newOptions.headerIcon = options.icon;
|
|
17
18
|
if (options.color)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
4
5
|
async function up(knex) {
|
|
5
6
|
const groups = await knex.select('*').from('directus_fields').where({ interface: 'group-standard' });
|
|
6
7
|
const raw = [];
|
|
7
8
|
const detail = [];
|
|
8
9
|
for (const group of groups) {
|
|
9
|
-
const options = typeof group.options === 'string' ?
|
|
10
|
+
const options = typeof group.options === 'string' ? (0, parse_json_1.parseJSON)(group.options) : group.options || {};
|
|
10
11
|
if (options.showHeader === true) {
|
|
11
12
|
detail.push(group);
|
|
12
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
4
5
|
// Change image metadata structure to match the output from 'exifr'
|
|
5
6
|
async function up(knex) {
|
|
6
7
|
const files = await knex
|
|
@@ -10,7 +11,7 @@ async function up(knex) {
|
|
|
10
11
|
for (const { id, metadata } of files) {
|
|
11
12
|
let prevMetadata;
|
|
12
13
|
try {
|
|
13
|
-
prevMetadata =
|
|
14
|
+
prevMetadata = (0, parse_json_1.parseJSON)(metadata);
|
|
14
15
|
}
|
|
15
16
|
catch {
|
|
16
17
|
continue;
|
|
@@ -54,7 +55,7 @@ async function down(knex) {
|
|
|
54
55
|
.whereNotNull('metadata')
|
|
55
56
|
.whereNot('metadata', '{}');
|
|
56
57
|
for (const { id, metadata } of files) {
|
|
57
|
-
const prevMetadata =
|
|
58
|
+
const prevMetadata = (0, parse_json_1.parseJSON)(metadata);
|
|
58
59
|
// Update only required if metadata has keys other than 'icc' and 'iptc'
|
|
59
60
|
if (Object.keys(prevMetadata).filter((key) => key !== 'icc' && key !== 'iptc').length > 0) {
|
|
60
61
|
// Put all data under 'exif' and rename/move keys afterwards
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
4
|
const nanoid_1 = require("nanoid");
|
|
5
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
5
6
|
async function up(knex) {
|
|
6
7
|
var _a;
|
|
7
8
|
await knex.schema.alterTable('directus_presets', (table) => {
|
|
@@ -12,7 +13,7 @@ async function up(knex) {
|
|
|
12
13
|
.from('directus_presets');
|
|
13
14
|
for (const preset of presets) {
|
|
14
15
|
if (preset.filters) {
|
|
15
|
-
const oldFilters = (_a = (typeof preset.filters === 'string' ?
|
|
16
|
+
const oldFilters = (_a = (typeof preset.filters === 'string' ? (0, parse_json_1.parseJSON)(preset.filters) : preset.filters)) !== null && _a !== void 0 ? _a : [];
|
|
16
17
|
if (oldFilters.length === 0)
|
|
17
18
|
continue;
|
|
18
19
|
const newFilter = {
|
|
@@ -34,7 +35,7 @@ async function up(knex) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
if (preset.layout_query) {
|
|
37
|
-
const layoutQuery = typeof preset.layout_query === 'string' ?
|
|
38
|
+
const layoutQuery = typeof preset.layout_query === 'string' ? (0, parse_json_1.parseJSON)(preset.layout_query) : preset.layout_query;
|
|
38
39
|
for (const [layout, query] of Object.entries(layoutQuery)) {
|
|
39
40
|
if (query.sort) {
|
|
40
41
|
query.sort = [query.sort];
|
|
@@ -61,7 +62,7 @@ async function down(knex) {
|
|
|
61
62
|
.from('directus_presets');
|
|
62
63
|
for (const preset of presets) {
|
|
63
64
|
if (preset.filter) {
|
|
64
|
-
const newFilter = (_a = (typeof preset.filter === 'string' ?
|
|
65
|
+
const newFilter = (_a = (typeof preset.filter === 'string' ? (0, parse_json_1.parseJSON)(preset.filter) : preset.filter)) !== null && _a !== void 0 ? _a : {};
|
|
65
66
|
if (Object.keys(newFilter).length === 0)
|
|
66
67
|
continue;
|
|
67
68
|
const oldFilters = [];
|
|
@@ -85,7 +86,7 @@ async function down(knex) {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
if (preset.layout_query) {
|
|
88
|
-
const layoutQuery = typeof preset.layout_query === 'string' ?
|
|
89
|
+
const layoutQuery = typeof preset.layout_query === 'string' ? (0, parse_json_1.parseJSON)(preset.layout_query) : preset.layout_query;
|
|
89
90
|
for (const [layout, query] of Object.entries(layoutQuery)) {
|
|
90
91
|
if (query.sort && Array.isArray(query.sort)) {
|
|
91
92
|
query.sort = (_l = (_k = query.sort) === null || _k === void 0 ? void 0 : _k[0]) !== null && _l !== void 0 ? _l : null;
|
package/dist/database/run-ast.js
CHANGED
|
@@ -93,21 +93,16 @@ async function parseCurrentLevel(schema, collection, children, query) {
|
|
|
93
93
|
const nestedCollectionNodes = [];
|
|
94
94
|
for (const child of children) {
|
|
95
95
|
if (child.type === 'field') {
|
|
96
|
-
const
|
|
97
|
-
if (columnsInCollection.includes(
|
|
98
|
-
columnsToSelectInternal.push(child.
|
|
99
|
-
if (query.alias) {
|
|
100
|
-
columnsToSelectInternal.push(...Object.entries(query.alias)
|
|
101
|
-
.filter(([_key, value]) => value === child.name)
|
|
102
|
-
.map(([key]) => key));
|
|
103
|
-
}
|
|
96
|
+
const fieldName = (0, strip_function_1.stripFunction)(child.name);
|
|
97
|
+
if (columnsInCollection.includes(fieldName)) {
|
|
98
|
+
columnsToSelectInternal.push(child.fieldKey);
|
|
104
99
|
}
|
|
105
100
|
continue;
|
|
106
101
|
}
|
|
107
102
|
if (!child.relation)
|
|
108
103
|
continue;
|
|
109
104
|
if (child.type === 'm2o') {
|
|
110
|
-
columnsToSelectInternal.push(child.
|
|
105
|
+
columnsToSelectInternal.push(child.relation.field);
|
|
111
106
|
}
|
|
112
107
|
if (child.type === 'a2o') {
|
|
113
108
|
columnsToSelectInternal.push(child.relation.field);
|
|
@@ -137,6 +132,11 @@ async function parseCurrentLevel(schema, collection, children, query) {
|
|
|
137
132
|
function getColumnPreprocessor(knex, schema, table) {
|
|
138
133
|
const helpers = (0, helpers_1.getHelpers)(knex);
|
|
139
134
|
return function (fieldNode) {
|
|
135
|
+
var _a;
|
|
136
|
+
let alias = undefined;
|
|
137
|
+
if (fieldNode.name !== fieldNode.fieldKey) {
|
|
138
|
+
alias = fieldNode.fieldKey;
|
|
139
|
+
}
|
|
140
140
|
let field;
|
|
141
141
|
if (fieldNode.type === 'field') {
|
|
142
142
|
field = schema.collections[table].fields[(0, strip_function_1.stripFunction)(fieldNode.name)];
|
|
@@ -144,11 +144,7 @@ function getColumnPreprocessor(knex, schema, table) {
|
|
|
144
144
|
else {
|
|
145
145
|
field = schema.collections[fieldNode.relation.collection].fields[fieldNode.relation.field];
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
if (fieldNode.name !== fieldNode.fieldKey) {
|
|
149
|
-
alias = fieldNode.fieldKey;
|
|
150
|
-
}
|
|
151
|
-
if (field.type.startsWith('geometry')) {
|
|
147
|
+
if ((_a = field === null || field === void 0 ? void 0 : field.type) === null || _a === void 0 ? void 0 : _a.startsWith('geometry')) {
|
|
152
148
|
return helpers.st.asText(table, field.field);
|
|
153
149
|
}
|
|
154
150
|
return (0, get_column_1.getColumn)(knex, table, fieldNode.name, alias, schema);
|
|
@@ -221,7 +217,7 @@ function mergeWithParentItems(schema, nestedItem, parentItem, nestedNode) {
|
|
|
221
217
|
for (const parentItem of parentItems) {
|
|
222
218
|
const itemChild = nestedItems.find((nestedItem) => {
|
|
223
219
|
return (nestedItem[schema.collections[nestedNode.relation.related_collection].primary] ==
|
|
224
|
-
parentItem[nestedNode.
|
|
220
|
+
parentItem[nestedNode.relation.field]);
|
|
225
221
|
});
|
|
226
222
|
parentItem[nestedNode.fieldKey] = itemChild || null;
|
|
227
223
|
}
|
package/dist/env.js
CHANGED
|
@@ -14,6 +14,7 @@ const lodash_1 = require("lodash");
|
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
15
|
const require_yaml_1 = require("./utils/require-yaml");
|
|
16
16
|
const utils_1 = require("@directus/shared/utils");
|
|
17
|
+
const parse_json_1 = require("./utils/parse-json");
|
|
17
18
|
const acceptedEnvTypes = ['string', 'number', 'regex', 'array', 'json'];
|
|
18
19
|
const defaults = {
|
|
19
20
|
CONFIG_PATH: path_1.default.resolve(process.cwd(), '.env'),
|
|
@@ -70,6 +71,7 @@ const defaults = {
|
|
|
70
71
|
RELATIONAL_BATCH_SIZE: 25000,
|
|
71
72
|
EXPORT_BATCH_SIZE: 5000,
|
|
72
73
|
FILE_METADATA_ALLOW_LIST: 'ifd0.Make,ifd0.Model,exif.FNumber,exif.ExposureTime,exif.FocalLength,exif.ISO',
|
|
74
|
+
GRAPHQL_INTROSPECTION: true,
|
|
73
75
|
};
|
|
74
76
|
// Allows us to force certain environment variable into a type, instead of relying
|
|
75
77
|
// on the auto-parsed type in processValues. ref #3705
|
|
@@ -84,11 +86,12 @@ const typeMap = {
|
|
|
84
86
|
DB_EXCLUDE_TABLES: 'array',
|
|
85
87
|
IMPORT_IP_DENY_LIST: 'array',
|
|
86
88
|
FILE_METADATA_ALLOW_LIST: 'array',
|
|
89
|
+
GRAPHQL_INTROSPECTION: 'boolean',
|
|
87
90
|
};
|
|
88
91
|
let env = {
|
|
89
92
|
...defaults,
|
|
90
|
-
...getEnv(),
|
|
91
93
|
...process.env,
|
|
94
|
+
...getEnv(),
|
|
92
95
|
};
|
|
93
96
|
process.env = env;
|
|
94
97
|
env = processValues(env);
|
|
@@ -100,8 +103,8 @@ exports.default = env;
|
|
|
100
103
|
function refreshEnv() {
|
|
101
104
|
env = {
|
|
102
105
|
...defaults,
|
|
103
|
-
...getEnv(),
|
|
104
106
|
...process.env,
|
|
107
|
+
...getEnv(),
|
|
105
108
|
};
|
|
106
109
|
process.env = env;
|
|
107
110
|
env = processValues(env);
|
|
@@ -209,6 +212,8 @@ function processValues(env) {
|
|
|
209
212
|
case 'json':
|
|
210
213
|
env[key] = tryJSON(value);
|
|
211
214
|
break;
|
|
215
|
+
case 'boolean':
|
|
216
|
+
env[key] = value === 'true' || value === true || value === '1' || value === 1;
|
|
212
217
|
}
|
|
213
218
|
continue;
|
|
214
219
|
}
|
|
@@ -251,7 +256,7 @@ function processValues(env) {
|
|
|
251
256
|
}
|
|
252
257
|
function tryJSON(value) {
|
|
253
258
|
try {
|
|
254
|
-
return
|
|
259
|
+
return (0, parse_json_1.parseJSON)(value);
|
|
255
260
|
}
|
|
256
261
|
catch {
|
|
257
262
|
return value;
|
|
@@ -7,6 +7,7 @@ export * from './invalid-credentials';
|
|
|
7
7
|
export * from './invalid-ip';
|
|
8
8
|
export * from './invalid-otp';
|
|
9
9
|
export * from './invalid-payload';
|
|
10
|
+
export * from './invalid-provider';
|
|
10
11
|
export * from './invalid-query';
|
|
11
12
|
export * from './invalid-token';
|
|
12
13
|
export * from './method-not-allowed';
|
package/dist/exceptions/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./invalid-credentials"), exports);
|
|
|
19
19
|
__exportStar(require("./invalid-ip"), exports);
|
|
20
20
|
__exportStar(require("./invalid-otp"), exports);
|
|
21
21
|
__exportStar(require("./invalid-payload"), exports);
|
|
22
|
+
__exportStar(require("./invalid-provider"), exports);
|
|
22
23
|
__exportStar(require("./invalid-query"), exports);
|
|
23
24
|
__exportStar(require("./invalid-token"), exports);
|
|
24
25
|
__exportStar(require("./method-not-allowed"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidProviderException = void 0;
|
|
4
|
+
const exceptions_1 = require("@directus/shared/exceptions");
|
|
5
|
+
class InvalidProviderException extends exceptions_1.BaseException {
|
|
6
|
+
constructor(message = 'Invalid provider.') {
|
|
7
|
+
super(message, 403, 'INVALID_PROVIDER');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.InvalidProviderException = InvalidProviderException;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Range } from '@directus/drive';
|
|
2
1
|
import { BaseException } from '@directus/shared/exceptions';
|
|
2
|
+
import { Range } from '@directus/drive';
|
|
3
3
|
export declare class RangeNotSatisfiableException extends BaseException {
|
|
4
|
-
constructor(range
|
|
4
|
+
constructor(range?: Range);
|
|
5
5
|
}
|
|
@@ -4,7 +4,11 @@ exports.RangeNotSatisfiableException = void 0;
|
|
|
4
4
|
const exceptions_1 = require("@directus/shared/exceptions");
|
|
5
5
|
class RangeNotSatisfiableException extends exceptions_1.BaseException {
|
|
6
6
|
constructor(range) {
|
|
7
|
-
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const rangeString = range && ((range === null || range === void 0 ? void 0 : range.start) !== undefined || (range === null || range === void 0 ? void 0 : range.end) !== undefined)
|
|
9
|
+
? `"${(_a = range.start) !== null && _a !== void 0 ? _a : ''}-${(_b = range.end) !== null && _b !== void 0 ? _b : ''}" `
|
|
10
|
+
: '';
|
|
11
|
+
super(`Range ${rangeString}is invalid or the file's size doesn't match the requested range.`, 416, 'RANGE_NOT_SATISFIABLE');
|
|
8
12
|
}
|
|
9
13
|
}
|
|
10
14
|
exports.RangeNotSatisfiableException = RangeNotSatisfiableException;
|