directus 9.20.4 → 9.21.2
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/auth/drivers/openid.js +3 -1
- package/dist/cli/commands/schema/apply.js +0 -2
- package/dist/cli/commands/schema/snapshot.js +0 -2
- 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/schema.js +1 -1
- 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 +5 -4
- package/dist/services/fields.js +118 -50
- 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 +4 -4
- package/dist/services/relations.js +66 -8
- package/dist/services/users.js +8 -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/apply-snapshot.js +32 -13
- 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/get-schema.d.ts +6 -2
- package/dist/utils/get-schema.js +1 -1
- package/dist/utils/get-snapshot.js +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 +69 -80
- 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
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const merge_permissions_1 = require("../../src/utils/merge-permissions");
|
|
4
|
-
const fullFilter = {};
|
|
5
|
-
const conditionalFilter = { user: { id: { _eq: '$CURRENT_USER' } } };
|
|
6
|
-
const conditionalFilter2 = { count: { _gt: 42 } };
|
|
7
|
-
const permissionTemplate = {
|
|
8
|
-
role: null,
|
|
9
|
-
collection: 'directus_users',
|
|
10
|
-
permissions: null,
|
|
11
|
-
validation: null,
|
|
12
|
-
presets: null,
|
|
13
|
-
fields: null,
|
|
14
|
-
};
|
|
15
|
-
describe('merging permissions', () => {
|
|
16
|
-
test('processes _or permissions', () => {
|
|
17
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('or', { ...permissionTemplate, permissions: conditionalFilter }, { ...permissionTemplate, permissions: conditionalFilter2 });
|
|
18
|
-
expect(mergedPermission).toStrictEqual({
|
|
19
|
-
...permissionTemplate,
|
|
20
|
-
permissions: {
|
|
21
|
-
_or: [conditionalFilter, conditionalFilter2],
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
test('processes _or validations', () => {
|
|
26
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('or', { ...permissionTemplate, validation: conditionalFilter }, { ...permissionTemplate, validation: conditionalFilter2 });
|
|
27
|
-
expect(mergedPermission).toStrictEqual({
|
|
28
|
-
...permissionTemplate,
|
|
29
|
-
validation: {
|
|
30
|
-
_or: [conditionalFilter, conditionalFilter2],
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
test('processes _and permissions', () => {
|
|
35
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('and', { ...permissionTemplate, permissions: conditionalFilter }, { ...permissionTemplate, permissions: conditionalFilter2 });
|
|
36
|
-
expect(mergedPermission).toStrictEqual({
|
|
37
|
-
...permissionTemplate,
|
|
38
|
-
permissions: {
|
|
39
|
-
_and: [conditionalFilter, conditionalFilter2],
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
test('processes _and validations', () => {
|
|
44
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('and', { ...permissionTemplate, validation: conditionalFilter }, { ...permissionTemplate, validation: conditionalFilter2 });
|
|
45
|
-
expect(mergedPermission).toStrictEqual({
|
|
46
|
-
...permissionTemplate,
|
|
47
|
-
validation: {
|
|
48
|
-
_and: [conditionalFilter, conditionalFilter2],
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
test('{} supersedes conditional permissions in _or', () => {
|
|
53
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('or', { ...permissionTemplate, permissions: fullFilter }, { ...permissionTemplate, permissions: conditionalFilter });
|
|
54
|
-
expect(mergedPermission).toStrictEqual({ ...permissionTemplate, permissions: fullFilter });
|
|
55
|
-
});
|
|
56
|
-
test('{} supersedes conditional validations in _or', () => {
|
|
57
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('or', { ...permissionTemplate, validation: fullFilter }, { ...permissionTemplate, validation: conditionalFilter });
|
|
58
|
-
expect(mergedPermission).toStrictEqual({ ...permissionTemplate, validation: fullFilter });
|
|
59
|
-
});
|
|
60
|
-
test('{} does not supersede conditional permissions in _and', () => {
|
|
61
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('and', { ...permissionTemplate, permissions: fullFilter }, { ...permissionTemplate, permissions: conditionalFilter });
|
|
62
|
-
const expectedPermission = {
|
|
63
|
-
...permissionTemplate,
|
|
64
|
-
permissions: {
|
|
65
|
-
_and: [fullFilter, conditionalFilter],
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
expect(mergedPermission).toStrictEqual(expectedPermission);
|
|
69
|
-
});
|
|
70
|
-
test('{} does not supersede conditional validations in _and', () => {
|
|
71
|
-
const mergedPermission = (0, merge_permissions_1.mergePermission)('and', { ...permissionTemplate, validation: fullFilter }, { ...permissionTemplate, validation: conditionalFilter });
|
|
72
|
-
const expectedPermission = {
|
|
73
|
-
...permissionTemplate,
|
|
74
|
-
validation: {
|
|
75
|
-
_and: [fullFilter, conditionalFilter],
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
expect(mergedPermission).toStrictEqual(expectedPermission);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const validate_keys_1 = require("../../src/utils/validate-keys");
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const schema = {
|
|
6
|
-
collections: {
|
|
7
|
-
pk_integer: {
|
|
8
|
-
collection: 'pk_integer',
|
|
9
|
-
primary: 'id',
|
|
10
|
-
singleton: false,
|
|
11
|
-
note: 'Sample schema with integer primary key',
|
|
12
|
-
sortField: null,
|
|
13
|
-
accountability: null,
|
|
14
|
-
fields: {
|
|
15
|
-
id: {
|
|
16
|
-
field: 'id',
|
|
17
|
-
defaultValue: null,
|
|
18
|
-
nullable: false,
|
|
19
|
-
generated: false,
|
|
20
|
-
type: 'integer',
|
|
21
|
-
dbType: 'integer',
|
|
22
|
-
precision: null,
|
|
23
|
-
scale: null,
|
|
24
|
-
special: [],
|
|
25
|
-
note: null,
|
|
26
|
-
alias: false,
|
|
27
|
-
validation: null,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
pk_uuid: {
|
|
32
|
-
collection: 'pk_uuid',
|
|
33
|
-
primary: 'id',
|
|
34
|
-
singleton: false,
|
|
35
|
-
note: 'Sample schema with uuid primary key',
|
|
36
|
-
sortField: null,
|
|
37
|
-
accountability: null,
|
|
38
|
-
fields: {
|
|
39
|
-
id: {
|
|
40
|
-
field: 'id',
|
|
41
|
-
defaultValue: null,
|
|
42
|
-
nullable: false,
|
|
43
|
-
generated: false,
|
|
44
|
-
type: 'uuid',
|
|
45
|
-
dbType: 'uuid',
|
|
46
|
-
precision: null,
|
|
47
|
-
scale: null,
|
|
48
|
-
special: [],
|
|
49
|
-
note: null,
|
|
50
|
-
alias: false,
|
|
51
|
-
validation: null,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
relations: [],
|
|
57
|
-
};
|
|
58
|
-
describe('validate keys', () => {
|
|
59
|
-
describe('of integer type', () => {
|
|
60
|
-
it('Throws an error when provided with an invalid integer key', () => {
|
|
61
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', 'invalid')).toThrowError();
|
|
62
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', NaN)).toThrowError();
|
|
63
|
-
});
|
|
64
|
-
it('Throws an error when provided with an array containing an invalid integer key', () => {
|
|
65
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [111, 'invalid', 222])).toThrowError();
|
|
66
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [555, NaN, 666])).toThrowError();
|
|
67
|
-
});
|
|
68
|
-
it('Does not throw an error when provided with a valid integer key', () => {
|
|
69
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', 111)).not.toThrowError();
|
|
70
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', '222')).not.toThrowError();
|
|
71
|
-
});
|
|
72
|
-
it('Does not throw an error when provided with an array of valid integer keys', () => {
|
|
73
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [111, 222, 333])).not.toThrowError();
|
|
74
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', ['444', '555', '666'])).not.toThrowError();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe('of uuid type', () => {
|
|
78
|
-
it('Throws an error when provided with an invalid uuid key', () => {
|
|
79
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 'fakeuuid-62d9-434d-a7c7-878c8376782e')).toThrowError();
|
|
80
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 'invalid')).toThrowError();
|
|
81
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', NaN)).toThrowError();
|
|
82
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 111)).toThrowError();
|
|
83
|
-
});
|
|
84
|
-
it('Throws an error when provided with an array containing an invalid uuid key', () => {
|
|
85
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 'fakeuuid-62d9-434d-a7c7-878c8376782e', (0, uuid_1.v4)()])).toThrowError();
|
|
86
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 'invalid', (0, uuid_1.v4)()])).toThrowError();
|
|
87
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), NaN, (0, uuid_1.v4)()])).toThrowError();
|
|
88
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 111, (0, uuid_1.v4)()])).toThrowError();
|
|
89
|
-
});
|
|
90
|
-
it('Does not throw an error when provided with a valid uuid key', () => {
|
|
91
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', (0, uuid_1.v4)())).not.toThrowError();
|
|
92
|
-
});
|
|
93
|
-
it('Does not throw an error when provided with an array of valid uuid keys', () => {
|
|
94
|
-
expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), (0, uuid_1.v4)(), (0, uuid_1.v4)()])).not.toThrowError();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|