directus 9.11.0 → 9.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +8 -1
- package/dist/cli/utils/create-env/env-stub.liquid +266 -9
- package/dist/controllers/activity.js +1 -1
- package/dist/controllers/flows.d.ts +2 -0
- package/dist/controllers/flows.js +157 -0
- package/dist/controllers/folders.js +1 -1
- package/dist/controllers/notifications.js +1 -1
- package/dist/controllers/operations.d.ts +2 -0
- package/dist/controllers/operations.js +138 -0
- package/dist/database/index.js +15 -19
- package/dist/database/migrations/20220429A-add-flows.d.ts +3 -0
- package/dist/database/migrations/20220429A-add-flows.js +83 -0
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +3 -0
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.js +15 -0
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +3 -0
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.js +15 -0
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +3 -0
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.js +15 -0
- package/dist/database/seeds/05-activity.yaml +0 -1
- package/dist/database/system-data/collections/collections.yaml +4 -0
- package/dist/database/system-data/fields/activity.yaml +3 -0
- package/dist/database/system-data/fields/dashboards.yaml +3 -1
- package/dist/database/system-data/fields/flows.yaml +21 -0
- package/dist/database/system-data/fields/notifications.yaml +3 -1
- package/dist/database/system-data/fields/operations.yaml +19 -0
- package/dist/database/system-data/fields/panels.yaml +3 -1
- package/dist/database/system-data/fields/shares.yaml +3 -1
- package/dist/database/system-data/fields/users.yaml +2 -4
- package/dist/database/system-data/relations/relations.yaml +20 -0
- package/dist/env.d.ts +1 -1
- package/dist/env.js +165 -11
- package/dist/extensions.d.ts +3 -0
- package/dist/extensions.js +73 -20
- package/dist/flows.d.ts +17 -0
- package/dist/flows.js +310 -0
- package/dist/messenger.d.ts +24 -0
- package/dist/messenger.js +64 -0
- package/dist/operations/condition/index.d.ts +6 -0
- package/dist/operations/condition/index.js +15 -0
- package/dist/operations/item-create/index.d.ts +8 -0
- package/dist/operations/item-create/index.js +40 -0
- package/dist/operations/item-delete/index.d.ts +9 -0
- package/dist/operations/item-delete/index.js +45 -0
- package/dist/operations/item-read/index.d.ts +9 -0
- package/dist/operations/item-read/index.js +45 -0
- package/dist/operations/item-update/index.d.ts +10 -0
- package/dist/operations/item-update/index.js +50 -0
- package/dist/operations/log/index.d.ts +5 -0
- package/dist/operations/log/index.js +14 -0
- package/dist/operations/mail/index.d.ts +7 -0
- package/dist/operations/mail/index.js +16 -0
- package/dist/operations/notification/index.d.ts +8 -0
- package/dist/operations/notification/index.js +39 -0
- package/dist/operations/request/index.d.ts +9 -0
- package/dist/operations/request/index.js +14 -0
- package/dist/operations/sleep/index.d.ts +5 -0
- package/dist/operations/sleep/index.js +9 -0
- package/dist/operations/transform/index.d.ts +5 -0
- package/dist/operations/transform/index.js +10 -0
- package/dist/operations/trigger/index.d.ts +6 -0
- package/dist/operations/trigger/index.js +21 -0
- package/dist/services/activity.d.ts +1 -2
- package/dist/services/activity.js +10 -10
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +7 -7
- package/dist/services/authorization.js +12 -0
- package/dist/services/flows.d.ts +14 -0
- package/dist/services/flows.js +42 -0
- package/dist/services/graphql.js +13 -2
- package/dist/services/import-export.js +7 -3
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/services/items.js +17 -1
- package/dist/services/mail/index.js +2 -1
- package/dist/services/notifications.d.ts +2 -1
- package/dist/services/notifications.js +4 -3
- package/dist/services/operations.d.ts +14 -0
- package/dist/services/operations.js +42 -0
- package/dist/services/webhooks.d.ts +2 -0
- package/dist/services/webhooks.js +8 -7
- package/dist/types/events.d.ts +18 -0
- package/dist/types/events.js +2 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/{apply-query/index.d.ts → apply-query.d.ts} +0 -0
- package/dist/utils/{apply-query/index.js → apply-query.js} +147 -48
- package/dist/utils/construct-flow-tree.d.ts +2 -0
- package/dist/utils/construct-flow-tree.js +31 -0
- package/dist/utils/get-accountability-for-role.d.ts +7 -0
- package/dist/utils/get-accountability-for-role.js +36 -0
- package/dist/utils/operation-options.d.ts +3 -0
- package/dist/utils/operation-options.js +45 -0
- package/dist/utils/validate-keys.d.ts +6 -0
- package/dist/utils/validate-keys.js +28 -0
- package/dist/utils/validate-query.js +1 -1
- package/dist/webhooks.d.ts +2 -0
- package/dist/webhooks.js +17 -2
- package/package.json +19 -15
- package/dist/types/activity.d.ts +0 -9
- package/dist/types/activity.js +0 -13
- package/dist/utils/apply-query/operators/between.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/between.operator.js +0 -16
- package/dist/utils/apply-query/operators/contains.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/contains.operator.js +0 -9
- package/dist/utils/apply-query/operators/ends-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/ends-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/greather-than-equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/greather-than-equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/greather-than.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/greather-than.operator.js +0 -9
- package/dist/utils/apply-query/operators/in.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/in.operator.js +0 -14
- package/dist/utils/apply-query/operators/index.d.ts +0 -3
- package/dist/utils/apply-query/operators/index.js +0 -72
- package/dist/utils/apply-query/operators/insensitive-contains.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-contains.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-ends-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-ends-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-not-contains.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-not-contains.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-not-ends-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-not-ends-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-not-equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-not-equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-not-starts-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-not-starts-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/insensitive-starts-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/insensitive-starts-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/intersects-bbox.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/intersects-bbox.operator.js +0 -9
- package/dist/utils/apply-query/operators/intersects.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/intersects.operator.js +0 -9
- package/dist/utils/apply-query/operators/is-empty.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/is-empty.operator.js +0 -14
- package/dist/utils/apply-query/operators/is-not-empty.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/is-not-empty.operator.js +0 -14
- package/dist/utils/apply-query/operators/is-not-null.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/is-not-null.operator.js +0 -14
- package/dist/utils/apply-query/operators/is-null.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/is-null.operator.js +0 -14
- package/dist/utils/apply-query/operators/less-than-equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/less-than-equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/less-than.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/less-than.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-between.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-between.operator.js +0 -16
- package/dist/utils/apply-query/operators/not-contains.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-contains.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-ends-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-ends-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-equals.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-equals.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-in.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-in.operator.js +0 -14
- package/dist/utils/apply-query/operators/not-intersects-bbox.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-intersects-bbox.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-intersects.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-intersects.operator.js +0 -9
- package/dist/utils/apply-query/operators/not-starts-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/not-starts-with.operator.js +0 -9
- package/dist/utils/apply-query/operators/operator-register.d.ts +0 -13
- package/dist/utils/apply-query/operators/operator-register.js +0 -7
- package/dist/utils/apply-query/operators/starts-with.operator.d.ts +0 -2
- package/dist/utils/apply-query/operators/starts-with.operator.js +0 -9
- package/example.env +0 -202
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("@directus/shared/utils");
|
|
7
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
8
|
+
const operation_options_1 = require("../../utils/operation-options");
|
|
9
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
10
|
+
id: 'log',
|
|
11
|
+
handler: ({ message }) => {
|
|
12
|
+
logger_1.default.info((0, operation_options_1.optionToString)(message));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@directus/shared/utils");
|
|
4
|
+
const services_1 = require("../../services");
|
|
5
|
+
const md_1 = require("../../utils/md");
|
|
6
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
7
|
+
id: 'mail',
|
|
8
|
+
handler: async ({ body, to, subject }, { accountability, database, getSchema }) => {
|
|
9
|
+
const mailService = new services_1.MailService({ schema: await getSchema({ database }), accountability, knex: database });
|
|
10
|
+
await mailService.send({
|
|
11
|
+
html: (0, md_1.md)(body),
|
|
12
|
+
to,
|
|
13
|
+
subject,
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@directus/shared/utils");
|
|
4
|
+
const services_1 = require("../../services");
|
|
5
|
+
const operation_options_1 = require("../../utils/operation-options");
|
|
6
|
+
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
7
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
|
+
id: 'notification',
|
|
9
|
+
handler: async ({ recipient, subject, message, permissions }, { accountability, database, getSchema }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const schema = await getSchema({ database });
|
|
12
|
+
let customAccountability;
|
|
13
|
+
if (!permissions || permissions === '$trigger') {
|
|
14
|
+
customAccountability = accountability;
|
|
15
|
+
}
|
|
16
|
+
else if (permissions === '$full') {
|
|
17
|
+
customAccountability = null;
|
|
18
|
+
}
|
|
19
|
+
else if (permissions === '$public') {
|
|
20
|
+
customAccountability = await (0, get_accountability_for_role_1.getAccountabilityForRole)(null, { database, schema, accountability });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
customAccountability = await (0, get_accountability_for_role_1.getAccountabilityForRole)(permissions, { database, schema, accountability });
|
|
24
|
+
}
|
|
25
|
+
const notificationsService = new services_1.NotificationsService({
|
|
26
|
+
schema: await getSchema({ database }),
|
|
27
|
+
accountability: customAccountability,
|
|
28
|
+
knex: database,
|
|
29
|
+
});
|
|
30
|
+
const messageString = message ? (0, operation_options_1.optionToString)(message) : null;
|
|
31
|
+
const result = await notificationsService.createOne({
|
|
32
|
+
recipient,
|
|
33
|
+
sender: (_a = customAccountability === null || customAccountability === void 0 ? void 0 : customAccountability.user) !== null && _a !== void 0 ? _a : null,
|
|
34
|
+
subject,
|
|
35
|
+
message: messageString,
|
|
36
|
+
});
|
|
37
|
+
return result;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Method } from 'axios';
|
|
2
|
+
declare type Options = {
|
|
3
|
+
url: string;
|
|
4
|
+
method: Method;
|
|
5
|
+
body: Record<string, any> | string | null;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: import("@directus/shared/types").OperationApiConfig<Options>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("@directus/shared/utils");
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
9
|
+
id: 'request',
|
|
10
|
+
handler: async ({ url, method, body, headers }) => {
|
|
11
|
+
const result = await (0, axios_1.default)({ url, method, data: body, headers });
|
|
12
|
+
return { status: result.status, statusText: result.statusText, headers: result.headers, data: result.data };
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@directus/shared/utils");
|
|
4
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
5
|
+
id: 'sleep',
|
|
6
|
+
handler: async ({ milliseconds }) => {
|
|
7
|
+
await new Promise((resolve) => setTimeout(resolve, Number(milliseconds)));
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@directus/shared/utils");
|
|
4
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
5
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
6
|
+
id: 'transform',
|
|
7
|
+
handler: ({ json }) => {
|
|
8
|
+
return (0, parse_json_1.parseJSON)(json);
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@directus/shared/utils");
|
|
4
|
+
const flows_1 = require("../../flows");
|
|
5
|
+
const operation_options_1 = require("../../utils/operation-options");
|
|
6
|
+
exports.default = (0, utils_1.defineOperationApi)({
|
|
7
|
+
id: 'trigger',
|
|
8
|
+
handler: async ({ flow, payload }, context) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
11
|
+
const payloadObject = (_a = (0, operation_options_1.optionToObject)(payload)) !== null && _a !== void 0 ? _a : null;
|
|
12
|
+
let result;
|
|
13
|
+
if (Array.isArray(payloadObject)) {
|
|
14
|
+
result = await Promise.all(payloadObject.map((payload) => flowManager.runOperationFlow(flow, payload, context)));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result = await flowManager.runOperationFlow(flow, payloadObject, context);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AbstractServiceOptions,
|
|
1
|
+
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
2
2
|
import { ItemsService } from './items';
|
|
3
|
-
import { MutationOptions } from '../types';
|
|
4
3
|
import { NotificationsService } from './notifications';
|
|
5
4
|
import { UsersService } from './users';
|
|
6
5
|
export declare class ActivityService extends ItemsService {
|
|
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ActivityService = void 0;
|
|
7
|
-
const types_1 = require("
|
|
8
|
-
const items_1 = require("./items");
|
|
9
|
-
const notifications_1 = require("./notifications");
|
|
10
|
-
const users_1 = require("./users");
|
|
11
|
-
const authorization_1 = require("./authorization");
|
|
12
|
-
const get_permissions_1 = require("../utils/get-permissions");
|
|
13
|
-
const forbidden_1 = require("../exceptions/forbidden");
|
|
14
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
15
|
-
const user_name_1 = require("../utils/user-name");
|
|
7
|
+
const types_1 = require("@directus/shared/types");
|
|
16
8
|
const lodash_1 = require("lodash");
|
|
17
|
-
const env_1 = __importDefault(require("../env"));
|
|
18
9
|
const uuid_validate_1 = __importDefault(require("uuid-validate"));
|
|
10
|
+
const env_1 = __importDefault(require("../env"));
|
|
11
|
+
const forbidden_1 = require("../exceptions/forbidden");
|
|
12
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
13
|
+
const get_permissions_1 = require("../utils/get-permissions");
|
|
19
14
|
const url_1 = require("../utils/url");
|
|
15
|
+
const user_name_1 = require("../utils/user-name");
|
|
16
|
+
const authorization_1 = require("./authorization");
|
|
17
|
+
const items_1 = require("./items");
|
|
18
|
+
const notifications_1 = require("./notifications");
|
|
19
|
+
const users_1 = require("./users");
|
|
20
20
|
class ActivityService extends items_1.ItemsService {
|
|
21
21
|
constructor(options) {
|
|
22
22
|
super('directus_activity', options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
1
2
|
import { Knex } from 'knex';
|
|
2
|
-
import { ActivityService } from './activity';
|
|
3
3
|
import { AbstractServiceOptions, LoginResult } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { ActivityService } from './activity';
|
|
5
5
|
export declare class AuthenticationService {
|
|
6
6
|
knex: Knex;
|
|
7
7
|
accountability: Accountability | null;
|
|
@@ -4,23 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AuthenticationService = void 0;
|
|
7
|
+
const types_1 = require("@directus/shared/types");
|
|
7
8
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
8
10
|
const ms_1 = __importDefault(require("ms"));
|
|
9
11
|
const nanoid_1 = require("nanoid");
|
|
12
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
13
|
+
const auth_1 = require("../auth");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
10
15
|
const database_1 = __importDefault(require("../database"));
|
|
11
16
|
const emitter_1 = __importDefault(require("../emitter"));
|
|
12
17
|
const env_1 = __importDefault(require("../env"));
|
|
13
|
-
const auth_1 = require("../auth");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
18
|
const exceptions_1 = require("../exceptions");
|
|
16
19
|
const rate_limiter_1 = require("../rate-limiter");
|
|
20
|
+
const stall_1 = require("../utils/stall");
|
|
17
21
|
const activity_1 = require("./activity");
|
|
18
|
-
const tfa_1 = require("./tfa");
|
|
19
|
-
const types_1 = require("../types");
|
|
20
22
|
const settings_1 = require("./settings");
|
|
21
|
-
const
|
|
22
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
23
|
-
const stall_1 = require("../utils/stall");
|
|
23
|
+
const tfa_1 = require("./tfa");
|
|
24
24
|
const loginAttemptsLimiter = (0, rate_limiter_1.createRateLimiter)({ duration: 0 });
|
|
25
25
|
class AuthenticationService {
|
|
26
26
|
constructor(options) {
|
|
@@ -12,6 +12,7 @@ const exceptions_2 = require("../exceptions");
|
|
|
12
12
|
const strip_function_1 = require("../utils/strip-function");
|
|
13
13
|
const items_1 = require("./items");
|
|
14
14
|
const payload_1 = require("./payload");
|
|
15
|
+
const get_relation_info_1 = require("../utils/get-relation-info");
|
|
15
16
|
class AuthorizationService {
|
|
16
17
|
constructor(options) {
|
|
17
18
|
this.knex = options.knex || (0, database_1.default)();
|
|
@@ -161,6 +162,15 @@ class AuthorizationService {
|
|
|
161
162
|
// Filter value is not a filter, so we should skip it
|
|
162
163
|
return result;
|
|
163
164
|
}
|
|
165
|
+
// virtual o2m/o2a filter in the form of `$FOLLOW(...)`
|
|
166
|
+
else if (collection && filterKey.startsWith('$FOLLOW')) {
|
|
167
|
+
(result[collection] || (result[collection] = new Set())).add(filterKey);
|
|
168
|
+
// add virtual relation to the required permissions
|
|
169
|
+
const { relation } = (0, get_relation_info_1.getRelationInfo)([], collection, filterKey);
|
|
170
|
+
if ((relation === null || relation === void 0 ? void 0 : relation.collection) && (relation === null || relation === void 0 ? void 0 : relation.field)) {
|
|
171
|
+
(result[relation.collection] || (result[relation.collection] = new Set())).add(relation.field);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
164
174
|
// m2a filter in the form of `item:collection`
|
|
165
175
|
else if (filterKey.includes(':')) {
|
|
166
176
|
const [field, collectionScope] = filterKey.split(':');
|
|
@@ -271,6 +281,8 @@ class AuthorizationService {
|
|
|
271
281
|
if (allowedFields.length === 0)
|
|
272
282
|
allowedFields.push(schema.collections[collection].primary);
|
|
273
283
|
for (const field of requiredPermissions[collection]) {
|
|
284
|
+
if (field.startsWith('$FOLLOW'))
|
|
285
|
+
continue;
|
|
274
286
|
if (!allowedFields.includes(field))
|
|
275
287
|
throw new exceptions_2.ForbiddenException();
|
|
276
288
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlowRaw } from '@directus/shared/types';
|
|
2
|
+
import { Messenger } from '../messenger';
|
|
3
|
+
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
4
|
+
import { ItemsService } from './items';
|
|
5
|
+
export declare class FlowsService extends ItemsService<FlowRaw> {
|
|
6
|
+
messenger: Messenger;
|
|
7
|
+
constructor(options: AbstractServiceOptions);
|
|
8
|
+
createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
|
+
createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
10
|
+
updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
11
|
+
updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
12
|
+
deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
13
|
+
deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowsService = void 0;
|
|
4
|
+
const messenger_1 = require("../messenger");
|
|
5
|
+
const items_1 = require("./items");
|
|
6
|
+
class FlowsService extends items_1.ItemsService {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super('directus_flows', options);
|
|
9
|
+
this.messenger = (0, messenger_1.getMessenger)();
|
|
10
|
+
}
|
|
11
|
+
async createOne(data, opts) {
|
|
12
|
+
const result = await super.createOne(data, opts);
|
|
13
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
async createMany(data, opts) {
|
|
17
|
+
const result = await super.createMany(data, opts);
|
|
18
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
async updateOne(key, data, opts) {
|
|
22
|
+
const result = await super.updateOne(key, data, opts);
|
|
23
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
async updateMany(keys, data, opts) {
|
|
27
|
+
const result = await super.updateMany(keys, data, opts);
|
|
28
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
async deleteOne(key, opts) {
|
|
32
|
+
const result = await super.deleteOne(key, opts);
|
|
33
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async deleteMany(keys, opts) {
|
|
37
|
+
const result = await super.deleteMany(keys, opts);
|
|
38
|
+
this.messenger.publish('flows', { type: 'reload' });
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.FlowsService = FlowsService;
|
package/dist/services/graphql.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GraphQLService = exports.GraphQLDate = exports.GraphQLGeoJSON = void 0;
|
|
7
|
+
const types_1 = require("@directus/shared/types");
|
|
7
8
|
const argon2_1 = __importDefault(require("argon2"));
|
|
8
9
|
const graphql_1 = require("graphql");
|
|
9
10
|
const graphql_compose_1 = require("graphql-compose");
|
|
@@ -15,7 +16,6 @@ const database_1 = __importDefault(require("../database"));
|
|
|
15
16
|
const env_1 = __importDefault(require("../env"));
|
|
16
17
|
const exceptions_1 = require("../exceptions");
|
|
17
18
|
const extensions_1 = require("../extensions");
|
|
18
|
-
const types_1 = require("../types");
|
|
19
19
|
const generate_hash_1 = require("../utils/generate-hash");
|
|
20
20
|
const get_graphql_type_1 = require("../utils/get-graphql-type");
|
|
21
21
|
const reduce_schema_1 = require("../utils/reduce-schema");
|
|
@@ -26,9 +26,11 @@ const authentication_1 = require("./authentication");
|
|
|
26
26
|
const collections_1 = require("./collections");
|
|
27
27
|
const fields_1 = require("./fields");
|
|
28
28
|
const files_1 = require("./files");
|
|
29
|
+
const flows_1 = require("./flows");
|
|
29
30
|
const folders_1 = require("./folders");
|
|
30
31
|
const items_1 = require("./items");
|
|
31
32
|
const notifications_1 = require("./notifications");
|
|
33
|
+
const operations_1 = require("./operations");
|
|
32
34
|
const permissions_1 = require("./permissions");
|
|
33
35
|
const presets_1 = require("./presets");
|
|
34
36
|
const relations_1 = require("./relations");
|
|
@@ -1165,7 +1167,12 @@ class GraphQLService {
|
|
|
1165
1167
|
values.push(this.parseArgs(valueNode.fields, variableValues));
|
|
1166
1168
|
}
|
|
1167
1169
|
else {
|
|
1168
|
-
|
|
1170
|
+
if (valueNode.kind === 'Variable') {
|
|
1171
|
+
values.push(variableValues[valueNode.name.value]);
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
values.push(valueNode.value);
|
|
1175
|
+
}
|
|
1169
1176
|
}
|
|
1170
1177
|
}
|
|
1171
1178
|
argsObject[argument.name.value] = values;
|
|
@@ -1354,6 +1361,10 @@ class GraphQLService {
|
|
|
1354
1361
|
return new webhooks_1.WebhooksService(opts);
|
|
1355
1362
|
case 'directus_shares':
|
|
1356
1363
|
return new shares_1.SharesService(opts);
|
|
1364
|
+
case 'directus_flows':
|
|
1365
|
+
return new flows_1.FlowsService(opts);
|
|
1366
|
+
case 'directus_operations':
|
|
1367
|
+
return new operations_1.OperationsService(opts);
|
|
1357
1368
|
default:
|
|
1358
1369
|
return new items_1.ItemsService(collection, opts);
|
|
1359
1370
|
}
|
|
@@ -169,7 +169,7 @@ class ExportService {
|
|
|
169
169
|
const requestedLimit = (_a = query.limit) !== null && _a !== void 0 ? _a : -1;
|
|
170
170
|
const batchesRequired = Math.ceil(count / env_1.default.EXPORT_BATCH_SIZE);
|
|
171
171
|
let readCount = 0;
|
|
172
|
-
for (let batch = 0; batch
|
|
172
|
+
for (let batch = 0; batch < batchesRequired; batch++) {
|
|
173
173
|
let limit = env_1.default.EXPORT_BATCH_SIZE;
|
|
174
174
|
if (requestedLimit > 0 && env_1.default.EXPORT_BATCH_SIZE > requestedLimit - readCount) {
|
|
175
175
|
limit = requestedLimit - readCount;
|
|
@@ -177,7 +177,7 @@ class ExportService {
|
|
|
177
177
|
const result = await service.readByQuery({
|
|
178
178
|
...query,
|
|
179
179
|
limit,
|
|
180
|
-
|
|
180
|
+
offset: batch * env_1.default.EXPORT_BATCH_SIZE,
|
|
181
181
|
});
|
|
182
182
|
readCount += result.length;
|
|
183
183
|
if (result.length) {
|
|
@@ -265,7 +265,11 @@ class ExportService {
|
|
|
265
265
|
transforms: [json2csv_1.transforms.flatten({ separator: '.' })],
|
|
266
266
|
header: (options === null || options === void 0 ? void 0 : options.includeHeader) !== false,
|
|
267
267
|
});
|
|
268
|
-
|
|
268
|
+
let string = parser.parse(input);
|
|
269
|
+
if ((options === null || options === void 0 ? void 0 : options.includeHeader) === false) {
|
|
270
|
+
string = '\n' + string;
|
|
271
|
+
}
|
|
272
|
+
return string;
|
|
269
273
|
}
|
|
270
274
|
throw new exceptions_1.ServiceUnavailableException(`Illegal export type used: "${format}"`, { service: 'export' });
|
|
271
275
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export * from './collections';
|
|
|
7
7
|
export * from './dashboards';
|
|
8
8
|
export * from './fields';
|
|
9
9
|
export * from './files';
|
|
10
|
+
export * from './flows';
|
|
10
11
|
export * from './folders';
|
|
11
12
|
export * from './graphql';
|
|
12
13
|
export * from './import-export';
|
|
13
14
|
export * from './mail';
|
|
14
15
|
export * from './meta';
|
|
15
16
|
export * from './notifications';
|
|
17
|
+
export * from './operations';
|
|
16
18
|
export * from './panels';
|
|
17
19
|
export * from './payload';
|
|
18
20
|
export * from './permissions';
|
package/dist/services/index.js
CHANGED
|
@@ -20,12 +20,14 @@ __exportStar(require("./collections"), exports);
|
|
|
20
20
|
__exportStar(require("./dashboards"), exports);
|
|
21
21
|
__exportStar(require("./fields"), exports);
|
|
22
22
|
__exportStar(require("./files"), exports);
|
|
23
|
+
__exportStar(require("./flows"), exports);
|
|
23
24
|
__exportStar(require("./folders"), exports);
|
|
24
25
|
__exportStar(require("./graphql"), exports);
|
|
25
26
|
__exportStar(require("./import-export"), exports);
|
|
26
27
|
__exportStar(require("./mail"), exports);
|
|
27
28
|
__exportStar(require("./meta"), exports);
|
|
28
29
|
__exportStar(require("./notifications"), exports);
|
|
30
|
+
__exportStar(require("./operations"), exports);
|
|
29
31
|
__exportStar(require("./panels"), exports);
|
|
30
32
|
__exportStar(require("./payload"), exports);
|
|
31
33
|
__exportStar(require("./permissions"), exports);
|
package/dist/services/items.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ItemsService = void 0;
|
|
7
|
+
const types_1 = require("@directus/shared/types");
|
|
7
8
|
const lodash_1 = require("lodash");
|
|
8
9
|
const cache_1 = require("../cache");
|
|
9
10
|
const database_1 = __importDefault(require("../database"));
|
|
@@ -12,11 +13,11 @@ const emitter_1 = __importDefault(require("../emitter"));
|
|
|
12
13
|
const env_1 = __importDefault(require("../env"));
|
|
13
14
|
const exceptions_1 = require("../exceptions");
|
|
14
15
|
const translate_1 = require("../exceptions/database/translate");
|
|
15
|
-
const types_1 = require("../types");
|
|
16
16
|
const get_ast_from_query_1 = __importDefault(require("../utils/get-ast-from-query"));
|
|
17
17
|
const authorization_1 = require("./authorization");
|
|
18
18
|
const index_1 = require("./index");
|
|
19
19
|
const payload_1 = require("./payload");
|
|
20
|
+
const validate_keys_1 = require("../utils/validate-keys");
|
|
20
21
|
class ItemsService {
|
|
21
22
|
constructor(collection, options) {
|
|
22
23
|
this.collection = collection;
|
|
@@ -244,6 +245,7 @@ class ItemsService {
|
|
|
244
245
|
*/
|
|
245
246
|
async readOne(key, query = {}, opts) {
|
|
246
247
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
248
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, key);
|
|
247
249
|
const filterWithKey = (0, lodash_1.assign)({}, query.filter, { [primaryKeyField]: { _eq: key } });
|
|
248
250
|
const queryWithKey = (0, lodash_1.assign)({}, query, { filter: filterWithKey });
|
|
249
251
|
const results = await this.readByQuery(queryWithKey, opts);
|
|
@@ -258,6 +260,7 @@ class ItemsService {
|
|
|
258
260
|
async readMany(keys, query = {}, opts) {
|
|
259
261
|
var _a;
|
|
260
262
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
263
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
261
264
|
const filterWithKey = { _and: [{ [primaryKeyField]: { _in: keys } }, (_a = query.filter) !== null && _a !== void 0 ? _a : {}] };
|
|
262
265
|
const queryWithKey = (0, lodash_1.assign)({}, query, { filter: filterWithKey });
|
|
263
266
|
// Set query limit as the number of keys
|
|
@@ -272,12 +275,16 @@ class ItemsService {
|
|
|
272
275
|
*/
|
|
273
276
|
async updateByQuery(query, data, opts) {
|
|
274
277
|
const keys = await this.getKeysByQuery(query);
|
|
278
|
+
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
279
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
275
280
|
return keys.length ? await this.updateMany(keys, data, opts) : [];
|
|
276
281
|
}
|
|
277
282
|
/**
|
|
278
283
|
* Update a single item by primary key
|
|
279
284
|
*/
|
|
280
285
|
async updateOne(key, data, opts) {
|
|
286
|
+
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
287
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, key);
|
|
281
288
|
await this.updateMany([key], data, opts);
|
|
282
289
|
return key;
|
|
283
290
|
}
|
|
@@ -286,6 +293,7 @@ class ItemsService {
|
|
|
286
293
|
*/
|
|
287
294
|
async updateMany(keys, data, opts) {
|
|
288
295
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
296
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
289
297
|
const fields = Object.keys(this.schema.collections[this.collection].fields);
|
|
290
298
|
const aliases = Object.values(this.schema.collections[this.collection].fields)
|
|
291
299
|
.filter((field) => field.alias === true)
|
|
@@ -415,6 +423,9 @@ class ItemsService {
|
|
|
415
423
|
async upsertOne(payload, opts) {
|
|
416
424
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
417
425
|
const primaryKey = payload[primaryKeyField];
|
|
426
|
+
if (primaryKey) {
|
|
427
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, primaryKey);
|
|
428
|
+
}
|
|
418
429
|
const exists = primaryKey &&
|
|
419
430
|
!!(await this.knex
|
|
420
431
|
.select(primaryKeyField)
|
|
@@ -455,12 +466,16 @@ class ItemsService {
|
|
|
455
466
|
*/
|
|
456
467
|
async deleteByQuery(query, opts) {
|
|
457
468
|
const keys = await this.getKeysByQuery(query);
|
|
469
|
+
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
470
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
458
471
|
return keys.length ? await this.deleteMany(keys, opts) : [];
|
|
459
472
|
}
|
|
460
473
|
/**
|
|
461
474
|
* Delete a single item by primary key
|
|
462
475
|
*/
|
|
463
476
|
async deleteOne(key, opts) {
|
|
477
|
+
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
478
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, key);
|
|
464
479
|
await this.deleteMany([key], opts);
|
|
465
480
|
return key;
|
|
466
481
|
}
|
|
@@ -469,6 +484,7 @@ class ItemsService {
|
|
|
469
484
|
*/
|
|
470
485
|
async deleteMany(keys, opts) {
|
|
471
486
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
487
|
+
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
472
488
|
if (this.accountability && this.accountability.admin !== true) {
|
|
473
489
|
const authorizationService = new authorization_1.AuthorizationService({
|
|
474
490
|
accountability: this.accountability,
|
|
@@ -65,13 +65,14 @@ class MailService {
|
|
|
65
65
|
}
|
|
66
66
|
async getDefaultTemplateData() {
|
|
67
67
|
const projectInfo = await this.knex
|
|
68
|
-
.select(['project_name', 'project_logo', 'project_color'])
|
|
68
|
+
.select(['project_name', 'project_logo', 'project_color', 'project_url'])
|
|
69
69
|
.from('directus_settings')
|
|
70
70
|
.first();
|
|
71
71
|
return {
|
|
72
72
|
projectName: (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.project_name) || 'Directus',
|
|
73
73
|
projectColor: (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.project_color) || '#546e7a',
|
|
74
74
|
projectLogo: getProjectLogoURL(projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.project_logo),
|
|
75
|
+
projectUrl: (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.project_url) || '',
|
|
75
76
|
};
|
|
76
77
|
function getProjectLogoURL(logoID) {
|
|
77
78
|
const projectLogoUrl = new url_1.Url(env_1.default.PUBLIC_URL);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { UsersService, MailService } from '.';
|
|
2
1
|
import { AbstractServiceOptions, PrimaryKey, MutationOptions } from '../types';
|
|
3
2
|
import { ItemsService } from './items';
|
|
4
3
|
import { Notification } from '@directus/shared/types';
|
|
4
|
+
import { UsersService } from './users';
|
|
5
|
+
import { MailService } from './mail';
|
|
5
6
|
export declare class NotificationsService extends ItemsService {
|
|
6
7
|
usersService: UsersService;
|
|
7
8
|
mailService: MailService;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationsService = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
4
|
const items_1 = require("./items");
|
|
6
5
|
const md_1 = require("../utils/md");
|
|
6
|
+
const users_1 = require("./users");
|
|
7
|
+
const mail_1 = require("./mail");
|
|
7
8
|
class NotificationsService extends items_1.ItemsService {
|
|
8
9
|
constructor(options) {
|
|
9
10
|
super('directus_notifications', options);
|
|
10
|
-
this.usersService = new
|
|
11
|
-
this.mailService = new
|
|
11
|
+
this.usersService = new users_1.UsersService({ schema: this.schema });
|
|
12
|
+
this.mailService = new mail_1.MailService({ schema: this.schema, accountability: this.accountability });
|
|
12
13
|
}
|
|
13
14
|
async createOne(data, opts) {
|
|
14
15
|
await this.sendEmail(data);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OperationRaw } from '@directus/shared/types';
|
|
2
|
+
import { Messenger } from '../messenger';
|
|
3
|
+
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
4
|
+
import { ItemsService } from './items';
|
|
5
|
+
export declare class OperationsService extends ItemsService<OperationRaw> {
|
|
6
|
+
messenger: Messenger;
|
|
7
|
+
constructor(options: AbstractServiceOptions);
|
|
8
|
+
createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
|
+
createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
10
|
+
updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
11
|
+
updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
12
|
+
deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
13
|
+
deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
14
|
+
}
|