directus 9.14.5 → 9.16.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/__utils__/items-utils.d.ts +2 -0
- package/dist/__utils__/items-utils.js +36 -0
- package/dist/__utils__/schemas.d.ts +13 -0
- package/dist/__utils__/schemas.js +304 -0
- package/dist/__utils__/snapshots.d.ts +5 -0
- package/dist/__utils__/snapshots.js +897 -0
- package/dist/app.js +2 -1
- package/dist/auth/drivers/ldap.js +18 -8
- package/dist/auth/drivers/oauth2.js +19 -9
- package/dist/auth/drivers/openid.js +19 -9
- package/dist/cache.d.ts +3 -0
- package/dist/cache.js +21 -2
- package/dist/cli/index.test.d.ts +1 -0
- package/dist/cli/index.test.js +58 -0
- package/dist/cli/utils/create-env/env-stub.liquid +2 -2
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/controllers/assets.js +27 -1
- package/dist/controllers/extensions.js +3 -2
- package/dist/controllers/files.test.d.ts +1 -0
- package/dist/controllers/files.test.js +49 -0
- package/dist/controllers/server.js +0 -1
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +3 -14
- package/dist/database/helpers/schema/dialects/cockroachdb.js +2 -8
- package/dist/database/helpers/schema/dialects/oracle.d.ts +3 -10
- package/dist/database/helpers/schema/dialects/oracle.js +2 -5
- package/dist/database/helpers/schema/types.d.ts +8 -18
- package/dist/database/helpers/schema/types.js +7 -36
- package/dist/database/migrations/20201105B-change-webhook-url-type.js +3 -2
- package/dist/database/migrations/20210312A-webhooks-collections-text.js +3 -2
- package/dist/database/migrations/20210415A-make-filesize-nullable.js +2 -2
- package/dist/database/migrations/20210510A-restructure-relations.js +3 -3
- package/dist/database/migrations/20210903A-add-auth-provider.js +2 -2
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.js +4 -2
- package/dist/database/migrations/20210920A-webhooks-url-not-null.js +2 -2
- package/dist/database/migrations/20220303A-remove-default-project-color.js +2 -2
- package/dist/database/migrations/20220325B-add-default-language.js +2 -2
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.js +2 -2
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +3 -0
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.js +19 -0
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +3 -0
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.js +15 -0
- package/dist/database/migrations/run.test.d.ts +1 -0
- package/dist/database/migrations/run.test.js +92 -0
- package/dist/database/system-data/fields/settings.yaml +33 -0
- package/dist/env.js +8 -0
- package/dist/env.test.d.ts +8 -0
- package/dist/env.test.js +39 -0
- package/dist/extensions.d.ts +2 -2
- package/dist/extensions.js +10 -9
- package/dist/flows.js +2 -1
- package/dist/logger.js +0 -1
- package/dist/middleware/authenticate.test.d.ts +1 -0
- package/dist/middleware/authenticate.test.js +174 -0
- package/dist/middleware/cache.js +3 -3
- package/dist/middleware/extract-token.test.d.ts +1 -0
- package/dist/middleware/extract-token.test.js +60 -0
- package/dist/middleware/respond.js +2 -2
- package/dist/operations/exec/index.d.ts +5 -0
- package/dist/operations/exec/index.js +26 -0
- package/dist/operations/exec/index.test.d.ts +1 -0
- package/dist/operations/exec/index.test.js +95 -0
- package/dist/operations/item-create/index.js +1 -1
- package/dist/operations/item-delete/index.js +2 -2
- package/dist/operations/item-read/index.js +2 -2
- package/dist/operations/item-update/index.js +3 -3
- package/dist/operations/notification/index.js +9 -6
- package/dist/operations/request/index.js +22 -3
- package/dist/services/assets.d.ts +1 -1
- package/dist/services/assets.js +7 -2
- package/dist/services/authorization.js +2 -1
- package/dist/services/files.js +3 -2
- package/dist/services/files.test.d.ts +1 -0
- package/dist/services/files.test.js +53 -0
- package/dist/services/flows.js +4 -0
- package/dist/services/graphql/index.d.ts +2 -2
- package/dist/services/graphql/index.js +59 -40
- package/dist/services/graphql/types/hash.d.ts +2 -0
- package/dist/services/graphql/types/hash.js +9 -0
- package/dist/services/items.js +83 -39
- package/dist/services/items.test.d.ts +1 -0
- package/dist/services/items.test.js +765 -0
- package/dist/services/payload.d.ts +7 -4
- package/dist/services/payload.js +35 -8
- package/dist/services/payload.test.d.ts +1 -0
- package/dist/services/payload.test.js +94 -0
- package/dist/services/server.js +5 -3
- package/dist/services/specifications.js +1 -6
- package/dist/services/specifications.test.d.ts +1 -0
- package/dist/services/specifications.test.js +96 -0
- package/dist/types/items.d.ts +11 -0
- package/dist/utils/apply-query.js +15 -0
- package/dist/utils/apply-snapshot.js +15 -0
- package/dist/utils/apply-snapshot.test.d.ts +1 -0
- package/dist/utils/apply-snapshot.test.js +305 -0
- package/dist/utils/calculate-field-depth.test.d.ts +1 -0
- package/dist/utils/calculate-field-depth.test.js +76 -0
- package/dist/utils/compress.d.ts +3 -0
- package/dist/utils/compress.js +17 -0
- package/dist/utils/filter-items.test.d.ts +1 -0
- package/dist/utils/filter-items.test.js +60 -0
- package/dist/utils/get-ast-from-query.js +1 -1
- package/dist/utils/get-cache-key.test.d.ts +1 -0
- package/dist/utils/get-cache-key.test.js +53 -0
- package/dist/utils/get-column-path.test.d.ts +1 -0
- package/dist/utils/get-column-path.test.js +136 -0
- package/dist/utils/get-config-from-env.test.d.ts +1 -0
- package/dist/utils/get-config-from-env.test.js +19 -0
- package/dist/utils/get-graphql-type.d.ts +1 -1
- package/dist/utils/get-graphql-type.js +7 -1
- package/dist/utils/get-os-info.d.ts +9 -0
- package/dist/utils/get-os-info.js +47 -0
- package/dist/utils/get-permissions.js +2 -2
- package/dist/utils/get-relation-info.test.d.ts +1 -0
- package/dist/utils/get-relation-info.test.js +88 -0
- package/dist/utils/get-relation-type.test.d.ts +1 -0
- package/dist/utils/get-relation-type.test.js +69 -0
- package/dist/utils/get-schema.js +1 -2
- package/dist/utils/get-string-byte-size.test.d.ts +1 -0
- package/dist/utils/get-string-byte-size.test.js +8 -0
- package/dist/utils/is-directus-jwt.test.d.ts +1 -0
- package/dist/utils/is-directus-jwt.test.js +26 -0
- package/dist/utils/jwt.test.d.ts +1 -0
- package/dist/utils/jwt.test.js +36 -0
- package/dist/utils/merge-permissions.test.d.ts +1 -0
- package/dist/utils/merge-permissions.test.js +80 -0
- package/dist/utils/validate-keys.test.d.ts +1 -0
- package/dist/utils/validate-keys.test.js +97 -0
- package/package.json +12 -11
package/dist/app.js
CHANGED
|
@@ -168,7 +168,7 @@ async function createApp() {
|
|
|
168
168
|
res.send(constants_1.ROBOTSTXT);
|
|
169
169
|
});
|
|
170
170
|
if (env_1.default.SERVE_APP) {
|
|
171
|
-
const adminPath = require.resolve('@directus/app');
|
|
171
|
+
const adminPath = require.resolve('@directus/app', require.main ? { paths: [require.main.filename] } : undefined);
|
|
172
172
|
const adminUrl = new url_1.Url(env_1.default.PUBLIC_URL).addPath('admin');
|
|
173
173
|
// Set the App's base path according to the APIs public URL
|
|
174
174
|
const html = await fs_extra_1.default.readFile(adminPath, 'utf8');
|
|
@@ -190,6 +190,7 @@ async function createApp() {
|
|
|
190
190
|
if (env_1.default.RATE_LIMITER_ENABLED === true) {
|
|
191
191
|
app.use(rate_limiter_1.default);
|
|
192
192
|
}
|
|
193
|
+
app.get('/server/ping', (req, res) => res.send('pong'));
|
|
193
194
|
app.use(authenticate_1.default);
|
|
194
195
|
app.use(check_ip_1.checkIP);
|
|
195
196
|
app.use(sanitize_query_1.default);
|
|
@@ -34,6 +34,7 @@ const get_ip_from_req_1 = require("../../utils/get-ip-from-req");
|
|
|
34
34
|
const joi_1 = __importDefault(require("joi"));
|
|
35
35
|
const auth_1 = require("../auth");
|
|
36
36
|
const exceptions_1 = require("../../exceptions");
|
|
37
|
+
const record_not_unique_1 = require("../../exceptions/database/record-not-unique");
|
|
37
38
|
const services_1 = require("../../services");
|
|
38
39
|
const async_handler_1 = __importDefault(require("../../utils/async-handler"));
|
|
39
40
|
const env_1 = __importDefault(require("../../env"));
|
|
@@ -218,14 +219,23 @@ class LDAPAuthDriver extends auth_1.AuthDriver {
|
|
|
218
219
|
if (!userInfo) {
|
|
219
220
|
throw new exceptions_1.InvalidCredentialsException();
|
|
220
221
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
try {
|
|
223
|
+
await this.usersService.createOne({
|
|
224
|
+
provider: this.config.provider,
|
|
225
|
+
first_name: userInfo.firstName,
|
|
226
|
+
last_name: userInfo.lastName,
|
|
227
|
+
email: userInfo.email,
|
|
228
|
+
external_identifier: userInfo.dn,
|
|
229
|
+
role: (_c = userRole === null || userRole === void 0 ? void 0 : userRole.id) !== null && _c !== void 0 ? _c : defaultRoleId,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
if (e instanceof record_not_unique_1.RecordNotUniqueException) {
|
|
234
|
+
logger_1.default.warn(e, '[LDAP] Failed to register user. User not unique');
|
|
235
|
+
throw new exceptions_1.InvalidProviderException();
|
|
236
|
+
}
|
|
237
|
+
throw e;
|
|
238
|
+
}
|
|
229
239
|
return (await this.fetchUserId(userInfo.dn));
|
|
230
240
|
}
|
|
231
241
|
async verify(user, password) {
|
|
@@ -14,6 +14,7 @@ const openid_client_1 = require("openid-client");
|
|
|
14
14
|
const auth_1 = require("../../auth");
|
|
15
15
|
const env_1 = __importDefault(require("../../env"));
|
|
16
16
|
const exceptions_2 = require("../../exceptions");
|
|
17
|
+
const record_not_unique_1 = require("../../exceptions/database/record-not-unique");
|
|
17
18
|
const logger_1 = __importDefault(require("../../logger"));
|
|
18
19
|
const respond_1 = require("../../middleware/respond");
|
|
19
20
|
const services_1 = require("../../services");
|
|
@@ -118,15 +119,24 @@ class OAuth2AuthDriver extends local_1.LocalAuthDriver {
|
|
|
118
119
|
logger_1.default.trace(`[OAuth2] User doesn't exist, and public registration not allowed for provider "${provider}"`);
|
|
119
120
|
throw new exceptions_2.InvalidCredentialsException();
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
try {
|
|
123
|
+
await this.usersService.createOne({
|
|
124
|
+
provider,
|
|
125
|
+
first_name: userInfo[this.config.firstNameKey],
|
|
126
|
+
last_name: userInfo[this.config.lastNameKey],
|
|
127
|
+
email: email,
|
|
128
|
+
external_identifier: identifier,
|
|
129
|
+
role: this.config.defaultRoleId,
|
|
130
|
+
auth_data: tokenSet.refresh_token && JSON.stringify({ refreshToken: tokenSet.refresh_token }),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
if (e instanceof record_not_unique_1.RecordNotUniqueException) {
|
|
135
|
+
logger_1.default.warn(e, '[OAuth2] Failed to register user. User not unique');
|
|
136
|
+
throw new exceptions_2.InvalidProviderException();
|
|
137
|
+
}
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
130
140
|
return (await this.fetchUserId(identifier));
|
|
131
141
|
}
|
|
132
142
|
async login(user) {
|
|
@@ -14,6 +14,7 @@ const openid_client_1 = require("openid-client");
|
|
|
14
14
|
const auth_1 = require("../../auth");
|
|
15
15
|
const env_1 = __importDefault(require("../../env"));
|
|
16
16
|
const exceptions_2 = require("../../exceptions");
|
|
17
|
+
const record_not_unique_1 = require("../../exceptions/database/record-not-unique");
|
|
17
18
|
const logger_1 = __importDefault(require("../../logger"));
|
|
18
19
|
const respond_1 = require("../../middleware/respond");
|
|
19
20
|
const services_1 = require("../../services");
|
|
@@ -136,15 +137,24 @@ class OpenIDAuthDriver extends local_1.LocalAuthDriver {
|
|
|
136
137
|
logger_1.default.trace(`[OpenID] User doesn't exist, and public registration not allowed for provider "${provider}"`);
|
|
137
138
|
throw new exceptions_2.InvalidCredentialsException();
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
try {
|
|
141
|
+
await this.usersService.createOne({
|
|
142
|
+
provider,
|
|
143
|
+
first_name: userInfo.given_name,
|
|
144
|
+
last_name: userInfo.family_name,
|
|
145
|
+
email: email,
|
|
146
|
+
external_identifier: identifier,
|
|
147
|
+
role: this.config.defaultRoleId,
|
|
148
|
+
auth_data: tokenSet.refresh_token && JSON.stringify({ refreshToken: tokenSet.refresh_token }),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
if (e instanceof record_not_unique_1.RecordNotUniqueException) {
|
|
153
|
+
logger_1.default.warn(e, '[OpenID] Failed to register user. User not unique');
|
|
154
|
+
throw new exceptions_2.InvalidProviderException();
|
|
155
|
+
}
|
|
156
|
+
throw e;
|
|
157
|
+
}
|
|
148
158
|
return (await this.fetchUserId(identifier));
|
|
149
159
|
}
|
|
150
160
|
async login(user) {
|
package/dist/cache.d.ts
CHANGED
|
@@ -7,3 +7,6 @@ export declare function getCache(): {
|
|
|
7
7
|
export declare function flushCaches(forced?: boolean): Promise<void>;
|
|
8
8
|
export declare function clearSystemCache(forced?: boolean): Promise<void>;
|
|
9
9
|
export declare function setSystemCache(key: string, value: any, ttl?: number): Promise<void>;
|
|
10
|
+
export declare function getSystemCache(key: string): Promise<Record<string, any>>;
|
|
11
|
+
export declare function setCacheValue(cache: Keyv, key: string, value: Record<string, any> | Record<string, any>[], ttl?: number): Promise<void>;
|
|
12
|
+
export declare function getCacheValue(cache: Keyv, key: string): Promise<any>;
|
package/dist/cache.js
CHANGED
|
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setSystemCache = exports.clearSystemCache = exports.flushCaches = exports.getCache = void 0;
|
|
6
|
+
exports.getCacheValue = exports.setCacheValue = exports.getSystemCache = exports.setSystemCache = exports.clearSystemCache = exports.flushCaches = exports.getCache = void 0;
|
|
7
7
|
const keyv_1 = __importDefault(require("keyv"));
|
|
8
8
|
const ms_1 = __importDefault(require("ms"));
|
|
9
9
|
const env_1 = __importDefault(require("./env"));
|
|
10
10
|
const logger_1 = __importDefault(require("./logger"));
|
|
11
11
|
const get_config_from_env_1 = require("./utils/get-config-from-env");
|
|
12
12
|
const validate_env_1 = require("./utils/validate-env");
|
|
13
|
+
const compress_1 = require("./utils/compress");
|
|
13
14
|
let cache = null;
|
|
14
15
|
let systemCache = null;
|
|
15
16
|
let lockCache = null;
|
|
@@ -49,10 +50,28 @@ exports.clearSystemCache = clearSystemCache;
|
|
|
49
50
|
async function setSystemCache(key, value, ttl) {
|
|
50
51
|
const { systemCache, lockCache } = getCache();
|
|
51
52
|
if (!(await lockCache.get('system-cache-lock'))) {
|
|
52
|
-
await systemCache
|
|
53
|
+
await setCacheValue(systemCache, key, value, ttl);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
exports.setSystemCache = setSystemCache;
|
|
57
|
+
async function getSystemCache(key) {
|
|
58
|
+
const { systemCache } = getCache();
|
|
59
|
+
return await getCacheValue(systemCache, key);
|
|
60
|
+
}
|
|
61
|
+
exports.getSystemCache = getSystemCache;
|
|
62
|
+
async function setCacheValue(cache, key, value, ttl) {
|
|
63
|
+
const compressed = await (0, compress_1.compress)(value);
|
|
64
|
+
await cache.set(key, compressed, ttl);
|
|
65
|
+
}
|
|
66
|
+
exports.setCacheValue = setCacheValue;
|
|
67
|
+
async function getCacheValue(cache, key) {
|
|
68
|
+
const value = await cache.get(key);
|
|
69
|
+
if (!value)
|
|
70
|
+
return undefined;
|
|
71
|
+
const decompressed = await (0, compress_1.decompress)(value);
|
|
72
|
+
return decompressed;
|
|
73
|
+
}
|
|
74
|
+
exports.getCacheValue = getCacheValue;
|
|
56
75
|
function getKeyvInstance(ttl, namespaceSuffix) {
|
|
57
76
|
switch (env_1.default.CACHE_STORE) {
|
|
58
77
|
case 'redis':
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("./index");
|
|
4
|
+
jest.mock('../../src/env', () => ({
|
|
5
|
+
...jest.requireActual('../../src/env').default,
|
|
6
|
+
EXTENSIONS_PATH: '',
|
|
7
|
+
SERVE_APP: false,
|
|
8
|
+
DB_CLIENT: 'pg',
|
|
9
|
+
DB_HOST: 'localhost',
|
|
10
|
+
DB_PORT: 5432,
|
|
11
|
+
DB_DATABASE: 'directus',
|
|
12
|
+
DB_USER: 'postgres',
|
|
13
|
+
DB_PASSWORD: 'psql1234',
|
|
14
|
+
}));
|
|
15
|
+
jest.mock('@directus/shared/utils/node/get-extensions', () => ({
|
|
16
|
+
getPackageExtensions: jest.fn(() => Promise.resolve([])),
|
|
17
|
+
getLocalExtensions: jest.fn(() => Promise.resolve([customCliExtension])),
|
|
18
|
+
}));
|
|
19
|
+
jest.mock(`/hooks/custom-cli/index.js`, () => customCliHook, { virtual: true });
|
|
20
|
+
const customCliExtension = {
|
|
21
|
+
path: `/hooks/custom-cli`,
|
|
22
|
+
name: 'custom-cli',
|
|
23
|
+
type: 'hook',
|
|
24
|
+
entrypoint: 'index.js',
|
|
25
|
+
local: true,
|
|
26
|
+
};
|
|
27
|
+
const beforeHook = jest.fn();
|
|
28
|
+
const afterAction = jest.fn();
|
|
29
|
+
const afterHook = jest.fn(({ program }) => {
|
|
30
|
+
program.command('custom').action(afterAction);
|
|
31
|
+
});
|
|
32
|
+
const customCliHook = ({ init }) => {
|
|
33
|
+
init('cli.before', beforeHook);
|
|
34
|
+
init('cli.after', afterHook);
|
|
35
|
+
};
|
|
36
|
+
const writeOut = jest.fn();
|
|
37
|
+
const writeErr = jest.fn();
|
|
38
|
+
const setup = async () => {
|
|
39
|
+
const program = await (0, index_1.createCli)();
|
|
40
|
+
program.exitOverride();
|
|
41
|
+
program.configureOutput({ writeOut, writeErr });
|
|
42
|
+
return program;
|
|
43
|
+
};
|
|
44
|
+
beforeEach(jest.clearAllMocks);
|
|
45
|
+
describe('cli hooks', () => {
|
|
46
|
+
test('should call hooks before and after creating the cli', async () => {
|
|
47
|
+
const program = await setup();
|
|
48
|
+
expect(beforeHook).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(beforeHook).toHaveBeenCalledWith({ event: 'cli.before', program });
|
|
50
|
+
expect(afterHook).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(afterHook).toHaveBeenCalledWith({ event: 'cli.after', program });
|
|
52
|
+
});
|
|
53
|
+
test('should be able to add a custom cli command', async () => {
|
|
54
|
+
const program = await setup();
|
|
55
|
+
program.parseAsync(['custom'], { from: 'user' });
|
|
56
|
+
expect(afterAction).toHaveBeenCalledTimes(1);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -296,10 +296,10 @@ EMAIL_SENDMAIL_PATH="/usr/sbin/sendmail"
|
|
|
296
296
|
## Email (Sendmail Transport)
|
|
297
297
|
|
|
298
298
|
# What new line style to use in sendmail ["unix"]
|
|
299
|
-
EMAIL_SENDMAIL_NEW_LINE="unix"
|
|
299
|
+
# EMAIL_SENDMAIL_NEW_LINE="unix"
|
|
300
300
|
|
|
301
301
|
# Path to your sendmail executable ["/usr/sbin/sendmail"]
|
|
302
|
-
EMAIL_SENDMAIL_PATH="/usr/sbin/sendmail"
|
|
302
|
+
# EMAIL_SENDMAIL_PATH="/usr/sbin/sendmail"
|
|
303
303
|
|
|
304
304
|
## Email (SMTP Transport)
|
|
305
305
|
# EMAIL_SMTP_HOST="localhost"
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const FILTER_VARIABLES: string[];
|
|
|
5
5
|
export declare const ALIAS_TYPES: string[];
|
|
6
6
|
export declare const DEFAULT_AUTH_PROVIDER = "default";
|
|
7
7
|
export declare const COLUMN_TRANSFORMS: string[];
|
|
8
|
+
export declare const GENERATE_SPECIAL: string[];
|
|
8
9
|
export declare const UUID_REGEX = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
9
10
|
export declare const COOKIE_OPTIONS: {
|
|
10
11
|
httpOnly: boolean;
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ROBOTSTXT = exports.COOKIE_OPTIONS = exports.UUID_REGEX = exports.COLUMN_TRANSFORMS = exports.DEFAULT_AUTH_PROVIDER = exports.ALIAS_TYPES = exports.FILTER_VARIABLES = exports.ASSET_TRANSFORM_QUERY_KEYS = exports.SYSTEM_ASSET_ALLOW_LIST = void 0;
|
|
7
|
+
exports.ROBOTSTXT = exports.COOKIE_OPTIONS = exports.UUID_REGEX = exports.GENERATE_SPECIAL = exports.COLUMN_TRANSFORMS = exports.DEFAULT_AUTH_PROVIDER = exports.ALIAS_TYPES = exports.FILTER_VARIABLES = exports.ASSET_TRANSFORM_QUERY_KEYS = exports.SYSTEM_ASSET_ALLOW_LIST = void 0;
|
|
8
8
|
const env_1 = __importDefault(require("./env"));
|
|
9
9
|
const ms_1 = __importDefault(require("ms"));
|
|
10
10
|
exports.SYSTEM_ASSET_ALLOW_LIST = [
|
|
@@ -47,6 +47,7 @@ exports.FILTER_VARIABLES = ['$NOW', '$CURRENT_USER', '$CURRENT_ROLE'];
|
|
|
47
47
|
exports.ALIAS_TYPES = ['alias', 'o2m', 'm2m', 'm2a', 'o2a', 'files', 'translations'];
|
|
48
48
|
exports.DEFAULT_AUTH_PROVIDER = 'default';
|
|
49
49
|
exports.COLUMN_TRANSFORMS = ['year', 'month', 'day', 'weekday', 'hour', 'minute', 'second'];
|
|
50
|
+
exports.GENERATE_SPECIAL = ['uuid', 'date-created', 'role-created', 'user-created'];
|
|
50
51
|
exports.UUID_REGEX = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
|
51
52
|
exports.COOKIE_OPTIONS = {
|
|
52
53
|
httpOnly: true,
|
|
@@ -12,6 +12,7 @@ const constants_1 = require("../constants");
|
|
|
12
12
|
const database_1 = __importDefault(require("../database"));
|
|
13
13
|
const env_1 = __importDefault(require("../env"));
|
|
14
14
|
const exceptions_1 = require("../exceptions");
|
|
15
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
15
16
|
const use_collection_1 = __importDefault(require("../middleware/use-collection"));
|
|
16
17
|
const services_1 = require("../services");
|
|
17
18
|
const assets_1 = require("../types/assets");
|
|
@@ -147,6 +148,31 @@ router.get('/:pk/:filename?',
|
|
|
147
148
|
res.setHeader('Content-Length', stat.size);
|
|
148
149
|
return res.end();
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
+
let isDataSent = false;
|
|
152
|
+
stream.on('data', (chunk) => {
|
|
153
|
+
isDataSent = true;
|
|
154
|
+
res.write(chunk);
|
|
155
|
+
});
|
|
156
|
+
stream.on('end', () => {
|
|
157
|
+
res.end();
|
|
158
|
+
});
|
|
159
|
+
stream.on('error', (e) => {
|
|
160
|
+
logger_1.default.error(e, `Couldn't stream file ${file.id} to the client`);
|
|
161
|
+
if (!isDataSent) {
|
|
162
|
+
res.removeHeader('Content-Type');
|
|
163
|
+
res.removeHeader('Content-Disposition');
|
|
164
|
+
res.removeHeader('Cache-Control');
|
|
165
|
+
res.status(500).json({
|
|
166
|
+
errors: [
|
|
167
|
+
{
|
|
168
|
+
message: 'An unexpected error occurred.',
|
|
169
|
+
extensions: {
|
|
170
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
151
177
|
}));
|
|
152
178
|
exports.default = router;
|
|
@@ -9,13 +9,14 @@ const exceptions_1 = require("../exceptions");
|
|
|
9
9
|
const extensions_1 = require("../extensions");
|
|
10
10
|
const respond_1 = require("../middleware/respond");
|
|
11
11
|
const utils_1 = require("@directus/shared/utils");
|
|
12
|
+
const constants_1 = require("@directus/shared/constants");
|
|
12
13
|
const ms_1 = __importDefault(require("ms"));
|
|
13
14
|
const env_1 = __importDefault(require("../env"));
|
|
14
15
|
const get_cache_headers_1 = require("../utils/get-cache-headers");
|
|
15
16
|
const router = (0, express_1.Router)();
|
|
16
17
|
router.get('/:type', (0, async_handler_1.default)(async (req, res, next) => {
|
|
17
18
|
const type = (0, utils_1.depluralize)(req.params.type);
|
|
18
|
-
if (!(0, utils_1.
|
|
19
|
+
if (!(0, utils_1.isIn)(type, constants_1.APP_OR_HYBRID_EXTENSION_TYPES)) {
|
|
19
20
|
throw new exceptions_1.RouteNotFoundException(req.path);
|
|
20
21
|
}
|
|
21
22
|
const extensionManager = (0, extensions_1.getExtensionManager)();
|
|
@@ -27,7 +28,7 @@ router.get('/:type', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
27
28
|
}), respond_1.respond);
|
|
28
29
|
router.get('/:type/index.js', (0, async_handler_1.default)(async (req, res) => {
|
|
29
30
|
const type = (0, utils_1.depluralize)(req.params.type);
|
|
30
|
-
if (!(0, utils_1.
|
|
31
|
+
if (!(0, utils_1.isIn)(type, constants_1.APP_OR_HYBRID_EXTENSION_TYPES)) {
|
|
31
32
|
throw new exceptions_1.RouteNotFoundException(req.path);
|
|
32
33
|
}
|
|
33
34
|
const extensionManager = (0, extensions_1.getExtensionManager)();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
jest.mock('../../src/cache');
|
|
8
|
+
jest.mock('../../src/database');
|
|
9
|
+
jest.mock('../../src/utils/validate-env');
|
|
10
|
+
const files_1 = require("./files");
|
|
11
|
+
const invalid_payload_1 = require("../exceptions/invalid-payload");
|
|
12
|
+
const stream_1 = require("stream");
|
|
13
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
14
|
+
describe('multipartHandler', () => {
|
|
15
|
+
it(`Errors out if request doesn't contain any files to upload`, () => {
|
|
16
|
+
const fakeForm = new form_data_1.default();
|
|
17
|
+
fakeForm.append('field', 'test');
|
|
18
|
+
const req = {
|
|
19
|
+
headers: fakeForm.getHeaders(),
|
|
20
|
+
is: jest.fn().mockReturnValue(true),
|
|
21
|
+
body: fakeForm.getBuffer(),
|
|
22
|
+
params: {},
|
|
23
|
+
pipe: (input) => stream.pipe(input),
|
|
24
|
+
};
|
|
25
|
+
const stream = new stream_1.PassThrough();
|
|
26
|
+
stream.push(fakeForm.getBuffer());
|
|
27
|
+
(0, files_1.multipartHandler)(req, {}, (err) => {
|
|
28
|
+
expect(err.message).toBe('No files where included in the body');
|
|
29
|
+
expect(err).toBeInstanceOf(invalid_payload_1.InvalidPayloadException);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
it(`Errors out if uploaded file doesn't include the filename`, () => {
|
|
33
|
+
const fakeForm = new form_data_1.default();
|
|
34
|
+
fakeForm.append('file', Buffer.from('<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 243 266" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g id="Calligraphy"><path d="M67.097,135.868c0,3.151 0.598,14.121 -11.586,14.121c-17.076,0 -15.95,-12.947 -15.95,-12.947c0,-2.521 4.597,-5.638 4.597,-7.318c0,-0.63 0.041,-3.519 -2.27,-3.519c-5.671,0 -5.671,10.083 -5.671,10.083c0,0 0.419,15.336 19.116,15.336c20.205,0 30.04,-23.712 30.04,-30.88c0,-18.197 -51.112,-27.701 -51.112,-57.949c0,1.575 -2.205,-13.864 14.18,-13.864c28.358,0 44.426,42.536 44.426,71.524c0,28.988 -16.699,55.455 -16.699,55.455c0,0 33.4,-25.837 33.4,-76.25c0,-70.264 -46.003,-69.634 -46.003,-69.634c-4.792,0 -7.602,-0.241 -28.398,20.555c-20.797,20.797 -17.646,29.83 -17.646,29.83c0,31.93 49.576,32.35 49.576,55.457Z" style="fill-rule:nonzero;"/><path d="M241.886,174.861c-1.602,-9.142 -15.448,-9.916 -22.675,-9.682c-0.7,-0.003 -1.172,0.02 -1.327,0.03c-8.804,0.01 -19.314,4.179 -33.072,13.115c-3.554,2.308 -7.19,4.847 -10.902,7.562c-6.979,-31.39 -13.852,-63.521 -28.033,-63.521c20.415,-20.119 22.19,-16.272 22.19,-39.054c0,-11.244 14.498,-21.35 14.498,-21.35l-0.296,-2.024c-19.193,5.304 -37.307,-8.577 -42.2,-12.755c5.375,-9.663 9.584,-12.565 9.584,-12.565c1.891,-20.377 15.965,-27.31 15.965,-27.31c1.681,-4.201 6.092,-7.142 6.092,-7.142c-70.162,22.267 -54.247,189.298 -54.247,189.298c-0.475,-55.91 5.238,-92.242 11.977,-115.55c9.094,8.248 24.425,11.765 24.425,11.765c-7.396,3.55 -5.324,12.13 -5.324,19.527c0,7.397 -3.848,10.651 -3.848,10.651l-21.893,22.782c17.043,0.294 23.638,31.657 30.689,63.056c-2.548,2.042 -5.125,4.12 -7.728,6.219c-16.396,13.223 -33.351,26.897 -50.266,37.354c-19.086,11.797 -35.151,17.533 -49.116,17.533c-25.25,0 -44.118,-24.368 -44.118,-46.154c0,-9.838 3.227,-17.831 5.935,-22.805c2.935,-5.39 5.911,-8.503 5.967,-8.561c0.001,0 0.001,0 0.001,-0.001l-0.013,-0.012c1.803,-1.885 4.841,-5.181 10.423,-5.181c20.715,0 27.475,40.776 55.603,40.776c24.857,0 31.834,-20.497 37.286,-31.399c0,0 -8.94,11.12 -21.587,11.12c-27.038,0 -35.323,-40.557 -55.166,-40.557c-13.41,0 -22.743,15.506 -31.029,27.281c0,0 0.018,-0.001 0.048,-0.003c-1.02,1.415 -2.214,3.233 -3.41,5.425c-2.847,5.21 -6.239,13.587 -6.239,23.917c0,22.816 19.801,48.334 46.299,48.334c14.381,0 30.822,-5.84 50.262,-17.858c17.033,-10.529 34.04,-24.246 50.489,-37.511c2.309,-1.862 4.607,-3.715 6.891,-5.549c6.952,30.814 14.606,60.912 33.278,60.912c14.794,0 26.923,-25.445 26.923,-25.445c-7.987,7.101 -13.313,5.621 -13.313,5.621c-13.139,0.379 -19.937,-27.594 -26.48,-56.931c16.455,-12.099 31.46,-20.829 43.488,-20.829l0.072,-0.003c0.082,-0.005 5.246,-0.305 9.957,1.471c-2.95,1.636 -4.947,4.782 -4.947,8.394c0,5.299 4.296,9.594 9.594,9.594c5.298,0 9.594,-4.295 9.594,-9.594c0,-0.826 -0.104,-1.627 -0.301,-2.391Z" style="fill-rule:nonzero;"/></g></svg>'));
|
|
35
|
+
const req = {
|
|
36
|
+
headers: fakeForm.getHeaders(),
|
|
37
|
+
is: jest.fn().mockReturnValue(true),
|
|
38
|
+
body: fakeForm.getBuffer(),
|
|
39
|
+
params: {},
|
|
40
|
+
pipe: (input) => stream.pipe(input),
|
|
41
|
+
};
|
|
42
|
+
const stream = new stream_1.PassThrough();
|
|
43
|
+
stream.push(fakeForm.getBuffer());
|
|
44
|
+
(0, files_1.multipartHandler)(req, {}, (err) => {
|
|
45
|
+
expect(err.message).toBe('File is missing filename');
|
|
46
|
+
expect(err).toBeInstanceOf(invalid_payload_1.InvalidPayloadException);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -36,7 +36,6 @@ router.get('/specs/graphql/:scope?', (0, async_handler_1.default)(async (req, re
|
|
|
36
36
|
res.attachment(filename);
|
|
37
37
|
res.send(result);
|
|
38
38
|
}));
|
|
39
|
-
router.get('/ping', (req, res) => res.send('pong'));
|
|
40
39
|
router.get('/info', (0, async_handler_1.default)(async (req, res, next) => {
|
|
41
40
|
const service = new services_1.ServerService({
|
|
42
41
|
accountability: req.accountability,
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
+
import { Options, SchemaHelper } from '../types';
|
|
2
3
|
export declare class SchemaHelperCockroachDb extends SchemaHelper {
|
|
3
|
-
|
|
4
|
-
nullable?: boolean;
|
|
5
|
-
default?: any;
|
|
6
|
-
}): Promise<void>;
|
|
7
|
-
changeToString(table: string, column: string, options?: {
|
|
8
|
-
nullable?: boolean;
|
|
9
|
-
default?: any;
|
|
10
|
-
length?: number;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
changeToInteger(table: string, column: string, options?: {
|
|
13
|
-
nullable?: boolean;
|
|
14
|
-
default?: any;
|
|
15
|
-
}): Promise<void>;
|
|
4
|
+
changeToType(table: string, column: string, type: typeof KNEX_TYPES[number], options?: Options): Promise<void>;
|
|
16
5
|
}
|
|
@@ -3,14 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SchemaHelperCockroachDb = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
class SchemaHelperCockroachDb extends types_1.SchemaHelper {
|
|
6
|
-
async
|
|
7
|
-
await this.changeToTypeByCopy(table, column,
|
|
8
|
-
}
|
|
9
|
-
async changeToString(table, column, options = {}) {
|
|
10
|
-
await this.changeToTypeByCopy(table, column, options, (builder, column, options) => builder.string(column, options.length));
|
|
11
|
-
}
|
|
12
|
-
async changeToInteger(table, column, options = {}) {
|
|
13
|
-
await this.changeToTypeByCopy(table, column, options, (builder, column) => builder.integer(column));
|
|
6
|
+
async changeToType(table, column, type, options = {}) {
|
|
7
|
+
await this.changeToTypeByCopy(table, column, type, options);
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
10
|
exports.SchemaHelperCockroachDb = SchemaHelperCockroachDb;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
+
import { Options, SchemaHelper } from '../types';
|
|
2
3
|
export declare class SchemaHelperOracle extends SchemaHelper {
|
|
3
|
-
|
|
4
|
-
nullable?: boolean;
|
|
5
|
-
default?: any;
|
|
6
|
-
}): Promise<void>;
|
|
7
|
-
changeToString(table: string, column: string, options?: {
|
|
8
|
-
nullable?: boolean;
|
|
9
|
-
default?: any;
|
|
10
|
-
length?: number;
|
|
11
|
-
}): Promise<void>;
|
|
4
|
+
changeToType(table: string, column: string, type: typeof KNEX_TYPES[number], options?: Options): Promise<void>;
|
|
12
5
|
}
|
|
@@ -3,11 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SchemaHelperOracle = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
class SchemaHelperOracle extends types_1.SchemaHelper {
|
|
6
|
-
async
|
|
7
|
-
await this.changeToTypeByCopy(table, column,
|
|
8
|
-
}
|
|
9
|
-
async changeToString(table, column, options = {}) {
|
|
10
|
-
await this.changeToTypeByCopy(table, column, options, (builder, column, options) => builder.string(column, options.length));
|
|
6
|
+
async changeToType(table, column, type, options = {}) {
|
|
7
|
+
await this.changeToTypeByCopy(table, column, type, options);
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
10
|
exports.SchemaHelperOracle = SchemaHelperOracle;
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
import { DatabaseHelper } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
3
3
|
declare type Clients = 'mysql' | 'postgres' | 'cockroachdb' | 'sqlite' | 'oracle' | 'mssql' | 'redshift';
|
|
4
|
+
export declare type Options = {
|
|
5
|
+
nullable?: boolean;
|
|
6
|
+
default?: any;
|
|
7
|
+
length?: number;
|
|
8
|
+
};
|
|
4
9
|
export declare abstract class SchemaHelper extends DatabaseHelper {
|
|
5
10
|
isOneOfClients(clients: Clients[]): boolean;
|
|
6
11
|
changeNullable(table: string, column: string, nullable: boolean): Promise<void>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
default?: any;
|
|
10
|
-
}): Promise<void>;
|
|
11
|
-
changeToInteger(table: string, column: string, options?: {
|
|
12
|
-
nullable?: boolean;
|
|
13
|
-
default?: any;
|
|
14
|
-
}): Promise<void>;
|
|
15
|
-
changeToString(table: string, column: string, options?: {
|
|
16
|
-
nullable?: boolean;
|
|
17
|
-
default?: any;
|
|
18
|
-
length?: number;
|
|
19
|
-
}): Promise<void>;
|
|
20
|
-
protected changeToTypeByCopy<Options extends {
|
|
21
|
-
nullable?: boolean;
|
|
22
|
-
default?: any;
|
|
23
|
-
}>(table: string, column: string, options: Options, cb: (builder: Knex.CreateTableBuilder, column: string, options: Options) => Knex.ColumnBuilder): Promise<void>;
|
|
12
|
+
changeToType(table: string, column: string, type: typeof KNEX_TYPES[number], options?: Options): Promise<void>;
|
|
13
|
+
protected changeToTypeByCopy(table: string, column: string, type: typeof KNEX_TYPES[number], options: Options): Promise<void>;
|
|
24
14
|
preColumnDelete(): Promise<boolean>;
|
|
25
15
|
postColumnDelete(): Promise<void>;
|
|
26
16
|
}
|
|
@@ -17,9 +17,9 @@ class SchemaHelper extends types_1.DatabaseHelper {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
async
|
|
20
|
+
async changeToType(table, column, type, options = {}) {
|
|
21
21
|
await this.knex.schema.alterTable(table, (builder) => {
|
|
22
|
-
const b = builder.string(column);
|
|
22
|
+
const b = type === 'string' ? builder.string(column, options.length) : builder[type](column);
|
|
23
23
|
if (options.nullable === true) {
|
|
24
24
|
b.nullable();
|
|
25
25
|
}
|
|
@@ -32,39 +32,10 @@ class SchemaHelper extends types_1.DatabaseHelper {
|
|
|
32
32
|
b.alter();
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async
|
|
35
|
+
async changeToTypeByCopy(table, column, type, options) {
|
|
36
|
+
const tempName = `${column}__temp`;
|
|
36
37
|
await this.knex.schema.alterTable(table, (builder) => {
|
|
37
|
-
const
|
|
38
|
-
if (options.nullable === true) {
|
|
39
|
-
b.nullable();
|
|
40
|
-
}
|
|
41
|
-
if (options.nullable === false) {
|
|
42
|
-
b.notNullable();
|
|
43
|
-
}
|
|
44
|
-
if (options.default !== undefined) {
|
|
45
|
-
b.defaultTo(options.default);
|
|
46
|
-
}
|
|
47
|
-
b.alter();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async changeToString(table, column, options = {}) {
|
|
51
|
-
await this.knex.schema.alterTable(table, (builder) => {
|
|
52
|
-
const b = builder.string(column, options.length);
|
|
53
|
-
if (options.nullable === true) {
|
|
54
|
-
b.nullable();
|
|
55
|
-
}
|
|
56
|
-
if (options.nullable === false) {
|
|
57
|
-
b.notNullable();
|
|
58
|
-
}
|
|
59
|
-
if (options.default !== undefined) {
|
|
60
|
-
b.defaultTo(options.default);
|
|
61
|
-
}
|
|
62
|
-
b.alter();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async changeToTypeByCopy(table, column, options, cb) {
|
|
66
|
-
await this.knex.schema.alterTable(table, (builder) => {
|
|
67
|
-
const col = cb(builder, `${column}__temp`, options);
|
|
38
|
+
const col = type === 'string' ? builder.string(tempName, options.length) : builder[type](tempName);
|
|
68
39
|
if (options.default !== undefined) {
|
|
69
40
|
col.defaultTo(options.default);
|
|
70
41
|
}
|
|
@@ -72,12 +43,12 @@ class SchemaHelper extends types_1.DatabaseHelper {
|
|
|
72
43
|
// the table)
|
|
73
44
|
col.nullable();
|
|
74
45
|
});
|
|
75
|
-
await this.knex(table).update(
|
|
46
|
+
await this.knex(table).update(tempName, this.knex.ref(column));
|
|
76
47
|
await this.knex.schema.alterTable(table, (builder) => {
|
|
77
48
|
builder.dropColumn(column);
|
|
78
49
|
});
|
|
79
50
|
await this.knex.schema.alterTable(table, (builder) => {
|
|
80
|
-
builder.renameColumn(
|
|
51
|
+
builder.renameColumn(tempName, column);
|
|
81
52
|
});
|
|
82
53
|
// We're altering the temporary column here. That starts nullable, so we only want to set it
|
|
83
54
|
// to NOT NULL when applicable
|
|
@@ -4,11 +4,12 @@ exports.down = exports.up = void 0;
|
|
|
4
4
|
const helpers_1 = require("../helpers");
|
|
5
5
|
async function up(knex) {
|
|
6
6
|
const helper = (0, helpers_1.getHelpers)(knex).schema;
|
|
7
|
-
|
|
7
|
+
const type = helper.isOneOfClients(['oracle', 'cockroachdb']) ? 'text' : 'string';
|
|
8
|
+
await helper.changeToType('directus_webhooks', 'url', type);
|
|
8
9
|
}
|
|
9
10
|
exports.up = up;
|
|
10
11
|
async function down(knex) {
|
|
11
|
-
await (0, helpers_1.getHelpers)(knex).schema.
|
|
12
|
+
await (0, helpers_1.getHelpers)(knex).schema.changeToType('directus_webhooks', 'url', 'string', {
|
|
12
13
|
nullable: false,
|
|
13
14
|
length: 255,
|
|
14
15
|
});
|
|
@@ -4,11 +4,12 @@ exports.down = exports.up = void 0;
|
|
|
4
4
|
const helpers_1 = require("../helpers");
|
|
5
5
|
async function up(knex) {
|
|
6
6
|
const helper = (0, helpers_1.getHelpers)(knex).schema;
|
|
7
|
-
|
|
7
|
+
const type = helper.isOneOfClients(['oracle', 'cockroachdb']) ? 'text' : 'string';
|
|
8
|
+
await helper.changeToType('directus_webhooks', 'collections', type);
|
|
8
9
|
}
|
|
9
10
|
exports.up = up;
|
|
10
11
|
async function down(knex) {
|
|
11
|
-
await (0, helpers_1.getHelpers)(knex).schema.
|
|
12
|
+
await (0, helpers_1.getHelpers)(knex).schema.changeToType('directus_webhooks', 'collections', 'string', {
|
|
12
13
|
nullable: false,
|
|
13
14
|
length: 255,
|
|
14
15
|
});
|