directus 9.20.4 → 9.21.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/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/controllers/extensions.js +4 -13
- package/dist/database/helpers/date/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/date/dialects/sqlite.js +4 -0
- package/dist/database/helpers/date/types.d.ts +1 -1
- package/dist/database/helpers/date/types.js +4 -0
- package/dist/database/helpers/fn/dialects/mssql.d.ts +8 -8
- package/dist/database/helpers/fn/dialects/mssql.js +22 -16
- package/dist/database/helpers/fn/dialects/mysql.d.ts +8 -8
- package/dist/database/helpers/fn/dialects/mysql.js +22 -16
- package/dist/database/helpers/fn/dialects/postgres.d.ts +8 -8
- package/dist/database/helpers/fn/dialects/postgres.js +22 -16
- package/dist/database/helpers/fn/types.d.ts +1 -1
- package/dist/database/helpers/index.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -0
- package/dist/database/helpers/schema/dialects/cockroachdb.js +11 -0
- package/dist/database/helpers/schema/types.d.ts +3 -2
- package/dist/database/helpers/schema/types.js +5 -0
- package/dist/database/migrations/run.js +29 -3
- package/dist/database/run-ast.d.ts +1 -1
- package/dist/database/run-ast.js +1 -1
- package/dist/env.d.ts +4 -0
- package/dist/env.js +9 -4
- package/dist/env.test.d.ts +1 -8
- package/dist/exceptions/database/contains-null-values.d.ts +1 -1
- package/dist/exceptions/database/dialects/types.d.ts +6 -6
- package/dist/exceptions/database/invalid-foreign-key.d.ts +1 -1
- package/dist/exceptions/database/not-null-violation.d.ts +1 -1
- package/dist/exceptions/database/record-not-unique.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.d.ts +1 -1
- package/dist/exceptions/database/value-too-long.d.ts +1 -1
- package/dist/exceptions/hit-rate-limit.d.ts +1 -1
- package/dist/exceptions/method-not-allowed.d.ts +1 -1
- package/dist/exceptions/service-unavailable.d.ts +1 -1
- package/dist/extensions.d.ts +7 -7
- package/dist/extensions.js +92 -89
- package/dist/logger.d.ts +1 -0
- package/dist/messenger.d.ts +1 -1
- package/dist/middleware/authenticate.d.ts +1 -0
- package/dist/middleware/validate-batch.d.ts +2 -0
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/condition/index.js +1 -1
- package/dist/operations/condition/index.test.d.ts +1 -0
- package/dist/operations/exec/index.d.ts +1 -1
- package/dist/operations/item-create/index.d.ts +1 -1
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/log/index.d.ts +1 -1
- package/dist/operations/mail/index.d.ts +1 -1
- package/dist/operations/notification/index.d.ts +1 -1
- package/dist/operations/request/index.d.ts +1 -1
- package/dist/operations/sleep/index.d.ts +1 -1
- package/dist/operations/transform/index.d.ts +1 -1
- package/dist/operations/trigger/index.d.ts +1 -1
- package/dist/operations/trigger/index.js +5 -2
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/services/authorization.js +7 -3
- package/dist/services/collections.d.ts +1 -1
- package/dist/services/collections.js +112 -13
- package/dist/services/fields.d.ts +2 -2
- package/dist/services/fields.js +89 -41
- package/dist/services/fields.test.d.ts +1 -0
- package/dist/services/graphql/index.js +4 -1
- package/dist/services/graphql/utils/process-error.d.ts +4 -0
- package/dist/services/graphql/utils/process-error.js +26 -0
- package/dist/services/graphql/utils/process-error.test.d.ts +1 -0
- package/dist/services/items.d.ts +1 -1
- package/dist/services/items.js +39 -13
- package/dist/services/mail/index.d.ts +2 -2
- package/dist/services/mail/index.js +2 -1
- package/dist/services/mail/templates/base.liquid +4 -4
- package/dist/services/notifications.js +9 -4
- package/dist/services/notifications.test.d.ts +1 -0
- package/dist/services/payload.d.ts +2 -2
- package/dist/services/payload.js +14 -12
- package/dist/services/relations.d.ts +2 -2
- package/dist/services/relations.js +54 -4
- package/dist/services/users.js +2 -2
- package/dist/services/users.test.d.ts +1 -0
- package/dist/types/assets.d.ts +7 -7
- package/dist/types/ast.d.ts +7 -7
- package/dist/types/auth.d.ts +4 -4
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +1 -1
- package/dist/types/files.d.ts +2 -2
- package/dist/types/items.d.ts +5 -5
- package/dist/types/migration.d.ts +1 -1
- package/dist/types/revision.d.ts +1 -1
- package/dist/types/services.d.ts +1 -1
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/types/webhooks.d.ts +2 -2
- package/dist/utils/get-ast-from-query.d.ts +1 -1
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-module-default.d.ts +1 -1
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/job-queue.d.ts +1 -1
- package/dist/utils/merge-permissions.d.ts +1 -0
- package/dist/utils/reduce-schema.js +3 -1
- package/package.json +70 -71
- package/dist/__mocks__/cache.d.ts +0 -5
- package/dist/__mocks__/cache.js +0 -7
- package/dist/__utils__/items-utils.d.ts +0 -2
- package/dist/__utils__/items-utils.js +0 -36
- package/dist/__utils__/schemas.d.ts +0 -13
- package/dist/__utils__/schemas.js +0 -304
- package/dist/__utils__/snapshots.d.ts +0 -5
- package/dist/__utils__/snapshots.js +0 -897
- package/dist/cli/index.test.js +0 -63
- package/dist/controllers/files.test.js +0 -49
- package/dist/database/migrations/run.test.js +0 -92
- package/dist/env.test.js +0 -40
- package/dist/middleware/authenticate.test.js +0 -214
- package/dist/middleware/extract-token.test.js +0 -60
- package/dist/middleware/validate-batch.test.js +0 -82
- package/dist/operations/exec/index.test.js +0 -95
- package/dist/services/files.test.js +0 -89
- package/dist/services/items.test.js +0 -765
- package/dist/services/payload.test.js +0 -196
- package/dist/services/specifications.test.js +0 -96
- package/dist/utils/apply-snapshot.test.js +0 -305
- package/dist/utils/async-handler.test.js +0 -18
- package/dist/utils/calculate-field-depth.test.js +0 -76
- package/dist/utils/filter-items.test.js +0 -60
- package/dist/utils/get-auth-providers.test.js +0 -72
- package/dist/utils/get-cache-key.test.js +0 -74
- package/dist/utils/get-column-path.test.js +0 -136
- package/dist/utils/get-config-from-env.test.js +0 -19
- package/dist/utils/get-relation-info.test.js +0 -88
- package/dist/utils/get-relation-type.test.js +0 -69
- package/dist/utils/get-string-byte-size.test.js +0 -8
- package/dist/utils/is-directus-jwt.test.js +0 -26
- package/dist/utils/jwt.test.js +0 -36
- package/dist/utils/merge-permissions.test.js +0 -80
- package/dist/utils/validate-keys.test.js +0 -97
|
@@ -26,23 +26,14 @@ router.get('/:type', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
26
26
|
};
|
|
27
27
|
return next();
|
|
28
28
|
}), respond_1.respond);
|
|
29
|
-
router.get('
|
|
30
|
-
const type = (0, utils_1.depluralize)(req.params.type);
|
|
31
|
-
if (!(0, utils_1.isIn)(type, constants_1.APP_OR_HYBRID_EXTENSION_TYPES)) {
|
|
32
|
-
throw new exceptions_1.RouteNotFoundException(req.path);
|
|
33
|
-
}
|
|
29
|
+
router.get('/sources/index.js', (0, async_handler_1.default)(async (req, res) => {
|
|
34
30
|
const extensionManager = (0, extensions_1.getExtensionManager)();
|
|
35
|
-
const extensionSource = extensionManager.getAppExtensions(
|
|
36
|
-
if (extensionSource ===
|
|
31
|
+
const extensionSource = extensionManager.getAppExtensions();
|
|
32
|
+
if (extensionSource === null) {
|
|
37
33
|
throw new exceptions_1.RouteNotFoundException(req.path);
|
|
38
34
|
}
|
|
39
35
|
res.setHeader('Content-Type', 'application/javascript; charset=UTF-8');
|
|
40
|
-
|
|
41
|
-
res.setHeader('Cache-Control', (0, get_cache_headers_1.getCacheControlHeader)(req, (0, ms_1.default)(env_1.default.EXTENSIONS_CACHE_TTL)));
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
res.setHeader('Cache-Control', 'no-store');
|
|
45
|
-
}
|
|
36
|
+
res.setHeader('Cache-Control', env_1.default.EXTENSIONS_CACHE_TTL ? (0, get_cache_headers_1.getCacheControlHeader)(req, (0, ms_1.default)(env_1.default.EXTENSIONS_CACHE_TTL)) : 'no-store');
|
|
46
37
|
res.setHeader('Vary', 'Origin, Cache-Control');
|
|
47
38
|
res.end(extensionSource);
|
|
48
39
|
}));
|
|
@@ -7,6 +7,10 @@ class DateHelperSQLite extends types_1.DateHelper {
|
|
|
7
7
|
if (!date) {
|
|
8
8
|
return date;
|
|
9
9
|
}
|
|
10
|
+
// Date generated from NOW()
|
|
11
|
+
if (date instanceof Date) {
|
|
12
|
+
return String(date.getTime());
|
|
13
|
+
}
|
|
10
14
|
// Return the time as string
|
|
11
15
|
if (date.length <= 8 && date.includes(':')) {
|
|
12
16
|
return date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DatabaseHelper } from '../types';
|
|
2
2
|
export declare abstract class DateHelper extends DatabaseHelper {
|
|
3
|
-
parse(date: string): string;
|
|
3
|
+
parse(date: string | Date): string;
|
|
4
4
|
readTimestampString(date: string): string;
|
|
5
5
|
writeTimestamp(date: string): Date;
|
|
6
6
|
fieldFlagForField(_fieldType: string): string;
|
|
@@ -5,6 +5,10 @@ const types_1 = require("../types");
|
|
|
5
5
|
const date_fns_1 = require("date-fns");
|
|
6
6
|
class DateHelper extends types_1.DatabaseHelper {
|
|
7
7
|
parse(date) {
|
|
8
|
+
// Date generated from NOW()
|
|
9
|
+
if (date instanceof Date) {
|
|
10
|
+
return date.toISOString();
|
|
11
|
+
}
|
|
8
12
|
return date;
|
|
9
13
|
}
|
|
10
14
|
readTimestampString(date) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FnHelper, FnHelperOptions } from '../types';
|
|
2
2
|
import { Knex } from 'knex';
|
|
3
3
|
export declare class FnHelperMSSQL extends FnHelper {
|
|
4
|
-
year(table: string, column: string): Knex.Raw;
|
|
5
|
-
month(table: string, column: string): Knex.Raw;
|
|
6
|
-
week(table: string, column: string): Knex.Raw;
|
|
7
|
-
day(table: string, column: string): Knex.Raw;
|
|
8
|
-
weekday(table: string, column: string): Knex.Raw;
|
|
9
|
-
hour(table: string, column: string): Knex.Raw;
|
|
10
|
-
minute(table: string, column: string): Knex.Raw;
|
|
11
|
-
second(table: string, column: string): Knex.Raw;
|
|
4
|
+
year(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
5
|
+
month(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
6
|
+
week(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
7
|
+
day(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
8
|
+
weekday(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
9
|
+
hour(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
10
|
+
minute(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
11
|
+
second(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
12
12
|
count(table: string, column: string, options?: FnHelperOptions): Knex.Raw<any>;
|
|
13
13
|
}
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FnHelperMSSQL = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const parseLocaltime = (columnType) => {
|
|
6
|
+
if (columnType === 'timestamp') {
|
|
7
|
+
return ` AT TIME ZONE 'UTC'`;
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
};
|
|
5
11
|
class FnHelperMSSQL extends types_1.FnHelper {
|
|
6
|
-
year(table, column) {
|
|
7
|
-
return this.knex.raw(
|
|
12
|
+
year(table, column, options) {
|
|
13
|
+
return this.knex.raw(`DATEPART(year, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
8
14
|
}
|
|
9
|
-
month(table, column) {
|
|
10
|
-
return this.knex.raw(
|
|
15
|
+
month(table, column, options) {
|
|
16
|
+
return this.knex.raw(`DATEPART(month, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
11
17
|
}
|
|
12
|
-
week(table, column) {
|
|
13
|
-
return this.knex.raw(
|
|
18
|
+
week(table, column, options) {
|
|
19
|
+
return this.knex.raw(`DATEPART(week, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
14
20
|
}
|
|
15
|
-
day(table, column) {
|
|
16
|
-
return this.knex.raw(
|
|
21
|
+
day(table, column, options) {
|
|
22
|
+
return this.knex.raw(`DATEPART(day, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
17
23
|
}
|
|
18
|
-
weekday(table, column) {
|
|
19
|
-
return this.knex.raw(
|
|
24
|
+
weekday(table, column, options) {
|
|
25
|
+
return this.knex.raw(`DATEPART(weekday, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
20
26
|
}
|
|
21
|
-
hour(table, column) {
|
|
22
|
-
return this.knex.raw(
|
|
27
|
+
hour(table, column, options) {
|
|
28
|
+
return this.knex.raw(`DATEPART(hour, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
23
29
|
}
|
|
24
|
-
minute(table, column) {
|
|
25
|
-
return this.knex.raw(
|
|
30
|
+
minute(table, column, options) {
|
|
31
|
+
return this.knex.raw(`DATEPART(minute, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
26
32
|
}
|
|
27
|
-
second(table, column) {
|
|
28
|
-
return this.knex.raw(
|
|
33
|
+
second(table, column, options) {
|
|
34
|
+
return this.knex.raw(`DATEPART(second, ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
29
35
|
}
|
|
30
36
|
count(table, column, options) {
|
|
31
37
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FnHelper, FnHelperOptions } from '../types';
|
|
2
2
|
import { Knex } from 'knex';
|
|
3
3
|
export declare class FnHelperMySQL extends FnHelper {
|
|
4
|
-
year(table: string, column: string): Knex.Raw;
|
|
5
|
-
month(table: string, column: string): Knex.Raw;
|
|
6
|
-
week(table: string, column: string): Knex.Raw;
|
|
7
|
-
day(table: string, column: string): Knex.Raw;
|
|
8
|
-
weekday(table: string, column: string): Knex.Raw;
|
|
9
|
-
hour(table: string, column: string): Knex.Raw;
|
|
10
|
-
minute(table: string, column: string): Knex.Raw;
|
|
11
|
-
second(table: string, column: string): Knex.Raw;
|
|
4
|
+
year(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
5
|
+
month(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
6
|
+
week(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
7
|
+
day(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
8
|
+
weekday(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
9
|
+
hour(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
10
|
+
minute(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
11
|
+
second(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
12
12
|
count(table: string, column: string, options?: FnHelperOptions): Knex.Raw;
|
|
13
13
|
}
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FnHelperMySQL = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const parseLocaltime = (columnType) => {
|
|
6
|
+
if (columnType === 'timestamp') {
|
|
7
|
+
return `CONVERT_TZ(??.??, @@GLOBAL.time_zone, 'UTC')`;
|
|
8
|
+
}
|
|
9
|
+
return '??.??';
|
|
10
|
+
};
|
|
5
11
|
class FnHelperMySQL extends types_1.FnHelper {
|
|
6
|
-
year(table, column) {
|
|
7
|
-
return this.knex.raw(
|
|
12
|
+
year(table, column, options) {
|
|
13
|
+
return this.knex.raw(`YEAR(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
8
14
|
}
|
|
9
|
-
month(table, column) {
|
|
10
|
-
return this.knex.raw(
|
|
15
|
+
month(table, column, options) {
|
|
16
|
+
return this.knex.raw(`MONTH(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
11
17
|
}
|
|
12
|
-
week(table, column) {
|
|
13
|
-
return this.knex.raw(
|
|
18
|
+
week(table, column, options) {
|
|
19
|
+
return this.knex.raw(`WEEK(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
14
20
|
}
|
|
15
|
-
day(table, column) {
|
|
16
|
-
return this.knex.raw(
|
|
21
|
+
day(table, column, options) {
|
|
22
|
+
return this.knex.raw(`DAYOFMONTH(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
17
23
|
}
|
|
18
|
-
weekday(table, column) {
|
|
19
|
-
return this.knex.raw(
|
|
24
|
+
weekday(table, column, options) {
|
|
25
|
+
return this.knex.raw(`DAYOFWEEK(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
20
26
|
}
|
|
21
|
-
hour(table, column) {
|
|
22
|
-
return this.knex.raw(
|
|
27
|
+
hour(table, column, options) {
|
|
28
|
+
return this.knex.raw(`HOUR(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
23
29
|
}
|
|
24
|
-
minute(table, column) {
|
|
25
|
-
return this.knex.raw(
|
|
30
|
+
minute(table, column, options) {
|
|
31
|
+
return this.knex.raw(`MINUTE(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
26
32
|
}
|
|
27
|
-
second(table, column) {
|
|
28
|
-
return this.knex.raw(
|
|
33
|
+
second(table, column, options) {
|
|
34
|
+
return this.knex.raw(`SECOND(${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
29
35
|
}
|
|
30
36
|
count(table, column, options) {
|
|
31
37
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FnHelper, FnHelperOptions } from '../types';
|
|
2
2
|
import { Knex } from 'knex';
|
|
3
3
|
export declare class FnHelperPostgres extends FnHelper {
|
|
4
|
-
year(table: string, column: string): Knex.Raw;
|
|
5
|
-
month(table: string, column: string): Knex.Raw;
|
|
6
|
-
week(table: string, column: string): Knex.Raw;
|
|
7
|
-
day(table: string, column: string): Knex.Raw;
|
|
8
|
-
weekday(table: string, column: string): Knex.Raw;
|
|
9
|
-
hour(table: string, column: string): Knex.Raw;
|
|
10
|
-
minute(table: string, column: string): Knex.Raw;
|
|
11
|
-
second(table: string, column: string): Knex.Raw;
|
|
4
|
+
year(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
5
|
+
month(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
6
|
+
week(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
7
|
+
day(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
8
|
+
weekday(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
9
|
+
hour(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
10
|
+
minute(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
11
|
+
second(table: string, column: string, options: FnHelperOptions): Knex.Raw;
|
|
12
12
|
count(table: string, column: string, options?: FnHelperOptions): Knex.Raw;
|
|
13
13
|
}
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FnHelperPostgres = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const parseLocaltime = (columnType) => {
|
|
6
|
+
if (columnType === 'timestamp') {
|
|
7
|
+
return ` AT TIME ZONE 'UTC'`;
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
};
|
|
5
11
|
class FnHelperPostgres extends types_1.FnHelper {
|
|
6
|
-
year(table, column) {
|
|
7
|
-
return this.knex.raw(
|
|
12
|
+
year(table, column, options) {
|
|
13
|
+
return this.knex.raw(`EXTRACT(YEAR FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
8
14
|
}
|
|
9
|
-
month(table, column) {
|
|
10
|
-
return this.knex.raw(
|
|
15
|
+
month(table, column, options) {
|
|
16
|
+
return this.knex.raw(`EXTRACT(MONTH FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
11
17
|
}
|
|
12
|
-
week(table, column) {
|
|
13
|
-
return this.knex.raw(
|
|
18
|
+
week(table, column, options) {
|
|
19
|
+
return this.knex.raw(`EXTRACT(WEEK FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
14
20
|
}
|
|
15
|
-
day(table, column) {
|
|
16
|
-
return this.knex.raw(
|
|
21
|
+
day(table, column, options) {
|
|
22
|
+
return this.knex.raw(`EXTRACT(DAY FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
17
23
|
}
|
|
18
|
-
weekday(table, column) {
|
|
19
|
-
return this.knex.raw(
|
|
24
|
+
weekday(table, column, options) {
|
|
25
|
+
return this.knex.raw(`EXTRACT(DOW FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
20
26
|
}
|
|
21
|
-
hour(table, column) {
|
|
22
|
-
return this.knex.raw(
|
|
27
|
+
hour(table, column, options) {
|
|
28
|
+
return this.knex.raw(`EXTRACT(HOUR FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
23
29
|
}
|
|
24
|
-
minute(table, column) {
|
|
25
|
-
return this.knex.raw(
|
|
30
|
+
minute(table, column, options) {
|
|
31
|
+
return this.knex.raw(`EXTRACT(MINUTE FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
26
32
|
}
|
|
27
|
-
second(table, column) {
|
|
28
|
-
return this.knex.raw(
|
|
33
|
+
second(table, column, options) {
|
|
34
|
+
return this.knex.raw(`EXTRACT(SECOND FROM ??.??${parseLocaltime(options === null || options === void 0 ? void 0 : options.type)})`, [table, column]);
|
|
29
35
|
}
|
|
30
36
|
count(table, column, options) {
|
|
31
37
|
var _a, _b, _c, _d, _e;
|
|
@@ -10,4 +10,4 @@ export declare function getHelpers(database: Knex): {
|
|
|
10
10
|
schema: schemaHelpers.sqlite | schemaHelpers.postgres | schemaHelpers.cockroachdb | schemaHelpers.oracle;
|
|
11
11
|
};
|
|
12
12
|
export declare function getFunctions(database: Knex, schema: SchemaOverview): fnHelpers.sqlite | fnHelpers.postgres | fnHelpers.mysql | fnHelpers.oracle | fnHelpers.mssql;
|
|
13
|
-
export
|
|
13
|
+
export type Helpers = ReturnType<typeof getHelpers>;
|
|
@@ -2,4 +2,5 @@ import { KNEX_TYPES } from '@directus/shared/constants';
|
|
|
2
2
|
import { Options, SchemaHelper } from '../types';
|
|
3
3
|
export declare class SchemaHelperCockroachDb extends SchemaHelper {
|
|
4
4
|
changeToType(table: string, column: string, type: typeof KNEX_TYPES[number], options?: Options): Promise<void>;
|
|
5
|
+
constraintName(existingName: string): string;
|
|
5
6
|
}
|
|
@@ -6,5 +6,16 @@ class SchemaHelperCockroachDb extends types_1.SchemaHelper {
|
|
|
6
6
|
async changeToType(table, column, type, options = {}) {
|
|
7
7
|
await this.changeToTypeByCopy(table, column, type, options);
|
|
8
8
|
}
|
|
9
|
+
constraintName(existingName) {
|
|
10
|
+
const suffix = '_replaced';
|
|
11
|
+
// CockroachDB does not allow for dropping/creating constraints with the same
|
|
12
|
+
// name in a single transaction. reference issue #14873
|
|
13
|
+
if (existingName.endsWith(suffix)) {
|
|
14
|
+
return existingName.substring(0, existingName.length - suffix.length);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return existingName + suffix;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
}
|
|
10
21
|
exports.SchemaHelperCockroachDb = SchemaHelperCockroachDb;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DatabaseHelper } from '../types';
|
|
2
2
|
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
type Clients = 'mysql' | 'postgres' | 'cockroachdb' | 'sqlite' | 'oracle' | 'mssql' | 'redshift';
|
|
4
|
+
export type Options = {
|
|
5
5
|
nullable?: boolean;
|
|
6
6
|
default?: any;
|
|
7
7
|
length?: number;
|
|
@@ -13,5 +13,6 @@ export declare abstract class SchemaHelper extends DatabaseHelper {
|
|
|
13
13
|
protected changeToTypeByCopy(table: string, column: string, type: typeof KNEX_TYPES[number], options: Options): Promise<void>;
|
|
14
14
|
preColumnChange(): Promise<boolean>;
|
|
15
15
|
postColumnChange(): Promise<void>;
|
|
16
|
+
constraintName(existingName: string): string;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
|
@@ -62,5 +62,10 @@ class SchemaHelper extends types_1.DatabaseHelper {
|
|
|
62
62
|
async postColumnChange() {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
+
constraintName(existingName) {
|
|
66
|
+
// most vendors allow for dropping/creating constraints with the same name
|
|
67
|
+
// reference issue #14873
|
|
68
|
+
return existingName;
|
|
69
|
+
}
|
|
65
70
|
}
|
|
66
71
|
exports.SchemaHelper = SchemaHelper;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -42,6 +65,7 @@ async function run(database, direction, log = true) {
|
|
|
42
65
|
if (direction === 'latest')
|
|
43
66
|
await latest();
|
|
44
67
|
async function up() {
|
|
68
|
+
var _a;
|
|
45
69
|
const currentVersion = completedMigrations[completedMigrations.length - 1];
|
|
46
70
|
let nextVersion;
|
|
47
71
|
if (!currentVersion) {
|
|
@@ -55,7 +79,7 @@ async function run(database, direction, log = true) {
|
|
|
55
79
|
if (!nextVersion) {
|
|
56
80
|
throw Error('Nothing to upgrade');
|
|
57
81
|
}
|
|
58
|
-
const { up } =
|
|
82
|
+
const { up } = await (_a = nextVersion.file, Promise.resolve().then(() => __importStar(require(_a))));
|
|
59
83
|
if (log) {
|
|
60
84
|
logger_1.default.info(`Applying ${nextVersion.name}...`);
|
|
61
85
|
}
|
|
@@ -63,6 +87,7 @@ async function run(database, direction, log = true) {
|
|
|
63
87
|
await database.insert({ version: nextVersion.version, name: nextVersion.name }).into('directus_migrations');
|
|
64
88
|
}
|
|
65
89
|
async function down() {
|
|
90
|
+
var _a;
|
|
66
91
|
const lastAppliedMigration = (0, lodash_1.orderBy)(completedMigrations, ['timestamp', 'version'], ['desc', 'desc'])[0];
|
|
67
92
|
if (!lastAppliedMigration) {
|
|
68
93
|
throw Error('Nothing to downgrade');
|
|
@@ -71,7 +96,7 @@ async function run(database, direction, log = true) {
|
|
|
71
96
|
if (!migration) {
|
|
72
97
|
throw new Error("Couldn't find migration");
|
|
73
98
|
}
|
|
74
|
-
const { down } =
|
|
99
|
+
const { down } = await (_a = migration.file, Promise.resolve().then(() => __importStar(require(_a))));
|
|
75
100
|
if (log) {
|
|
76
101
|
logger_1.default.info(`Undoing ${migration.name}...`);
|
|
77
102
|
}
|
|
@@ -79,9 +104,10 @@ async function run(database, direction, log = true) {
|
|
|
79
104
|
await database('directus_migrations').delete().where({ version: migration.version });
|
|
80
105
|
}
|
|
81
106
|
async function latest() {
|
|
107
|
+
var _a;
|
|
82
108
|
for (const migration of migrations) {
|
|
83
109
|
if (migration.completed === false) {
|
|
84
|
-
const { up } =
|
|
110
|
+
const { up } = await (_a = migration.file, Promise.resolve().then(() => __importStar(require(_a))));
|
|
85
111
|
if (log) {
|
|
86
112
|
logger_1.default.info(`Applying ${migration.name}...`);
|
|
87
113
|
}
|
package/dist/database/run-ast.js
CHANGED
|
@@ -209,7 +209,7 @@ function applyParentFilters(schema, nestedCollectionNodes, parentItem) {
|
|
|
209
209
|
const foreignField = nestedNode.relatedKey[relatedCollection];
|
|
210
210
|
const foreignIds = (0, lodash_1.uniq)(keysPerCollection[relatedCollection]);
|
|
211
211
|
(0, lodash_1.merge)(nestedNode, {
|
|
212
|
-
query: { [relatedCollection]: { filter: { [foreignField]: { _in: foreignIds } } } },
|
|
212
|
+
query: { [relatedCollection]: { filter: { [foreignField]: { _in: foreignIds } }, limit: foreignIds.length } },
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
}
|
package/dist/env.d.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare let env: Record<string, any>;
|
|
6
6
|
export default env;
|
|
7
|
+
/**
|
|
8
|
+
* Small wrapper function that makes it easier to write unit tests against changing environments
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEnv: () => Record<string, any>;
|
|
7
11
|
/**
|
|
8
12
|
* When changes have been made during runtime, like in the CLI, we can refresh the env object with
|
|
9
13
|
* the newly created variables
|
package/dist/env.js
CHANGED
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.refreshEnv = void 0;
|
|
10
|
+
exports.refreshEnv = exports.getEnv = void 0;
|
|
11
11
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
@@ -265,11 +265,16 @@ const typeMap = {
|
|
|
265
265
|
let env = {
|
|
266
266
|
...defaults,
|
|
267
267
|
...process.env,
|
|
268
|
-
...
|
|
268
|
+
...processConfiguration(),
|
|
269
269
|
};
|
|
270
270
|
process.env = env;
|
|
271
271
|
env = processValues(env);
|
|
272
272
|
exports.default = env;
|
|
273
|
+
/**
|
|
274
|
+
* Small wrapper function that makes it easier to write unit tests against changing environments
|
|
275
|
+
*/
|
|
276
|
+
const getEnv = () => env;
|
|
277
|
+
exports.getEnv = getEnv;
|
|
273
278
|
/**
|
|
274
279
|
* When changes have been made during runtime, like in the CLI, we can refresh the env object with
|
|
275
280
|
* the newly created variables
|
|
@@ -278,13 +283,13 @@ function refreshEnv() {
|
|
|
278
283
|
env = {
|
|
279
284
|
...defaults,
|
|
280
285
|
...process.env,
|
|
281
|
-
...
|
|
286
|
+
...processConfiguration(),
|
|
282
287
|
};
|
|
283
288
|
process.env = env;
|
|
284
289
|
env = processValues(env);
|
|
285
290
|
}
|
|
286
291
|
exports.refreshEnv = refreshEnv;
|
|
287
|
-
function
|
|
292
|
+
function processConfiguration() {
|
|
288
293
|
const configPath = path_1.default.resolve(process.env.CONFIG_PATH || defaults.CONFIG_PATH);
|
|
289
294
|
if (fs_1.default.existsSync(configPath) === false)
|
|
290
295
|
return {};
|
package/dist/env.test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MSSQLError = {
|
|
2
2
|
message: string;
|
|
3
3
|
code: 'EREQUEST';
|
|
4
4
|
number: number;
|
|
@@ -8,7 +8,7 @@ export declare type MSSQLError = {
|
|
|
8
8
|
procName: string;
|
|
9
9
|
lineNumber: number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type MySQLError = {
|
|
12
12
|
message: string;
|
|
13
13
|
code: string;
|
|
14
14
|
errno: number;
|
|
@@ -17,7 +17,7 @@ export declare type MySQLError = {
|
|
|
17
17
|
index: number;
|
|
18
18
|
sql: string;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type PostgresError = {
|
|
21
21
|
message: string;
|
|
22
22
|
length: number;
|
|
23
23
|
code: string;
|
|
@@ -28,14 +28,14 @@ export declare type PostgresError = {
|
|
|
28
28
|
dataType?: string;
|
|
29
29
|
constraint?: string;
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type OracleError = {
|
|
32
32
|
message: string;
|
|
33
33
|
errorNum: number;
|
|
34
34
|
offset: number;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type SQLiteError = {
|
|
37
37
|
message: string;
|
|
38
38
|
errno: number;
|
|
39
39
|
code: string;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type SQLError = MSSQLError & MySQLError & PostgresError & SQLiteError & OracleError & Error;
|