directus 9.11.1 → 9.12.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/app.js +14 -1
- package/dist/cli/utils/create-env/env-stub.liquid +266 -9
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +5 -1
- 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/helpers/fn/dialects/oracle.d.ts +9 -9
- package/dist/database/helpers/fn/dialects/oracle.js +22 -16
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +9 -9
- package/dist/database/helpers/fn/dialects/sqlite.js +46 -16
- package/dist/database/helpers/fn/types.d.ts +12 -9
- package/dist/database/index.js +10 -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/flows.yaml +21 -0
- package/dist/database/system-data/fields/operations.yaml +19 -0
- 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 +6 -30
- package/dist/extensions.d.ts +5 -1
- package/dist/extensions.js +96 -39
- package/dist/flows.d.ts +22 -0
- package/dist/flows.js +332 -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 +12 -0
- package/dist/operations/request/index.js +18 -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 +12 -0
- package/dist/services/flows.js +47 -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 +1 -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 +12 -0
- package/dist/services/operations.js +47 -0
- package/dist/services/users.js +5 -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-snapshot.js +3 -0
- 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/get-column.js +1 -1
- package/dist/utils/job-queue.d.ts +9 -0
- package/dist/utils/job-queue.js +24 -0
- package/dist/utils/operation-options.d.ts +3 -0
- package/dist/utils/operation-options.js +45 -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/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,12 @@
|
|
|
1
|
+
import { Method } from 'axios';
|
|
2
|
+
declare type Options = {
|
|
3
|
+
url: string;
|
|
4
|
+
method: Method;
|
|
5
|
+
body: Record<string, any> | string | null;
|
|
6
|
+
headers?: {
|
|
7
|
+
header: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[] | null;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("@directus/shared/types").OperationApiConfig<Options>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 customHeaders = headers === null || headers === void 0 ? void 0 : headers.reduce((acc, { header, value }) => {
|
|
12
|
+
acc[header] = value;
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
const result = await (0, axios_1.default)({ url, method, data: body, headers: customHeaders });
|
|
16
|
+
return { status: result.status, statusText: result.statusText, headers: result.headers, data: result.data };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { FlowRaw } from '@directus/shared/types';
|
|
2
|
+
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
3
|
+
import { ItemsService } from './items';
|
|
4
|
+
export declare class FlowsService extends ItemsService<FlowRaw> {
|
|
5
|
+
constructor(options: AbstractServiceOptions);
|
|
6
|
+
createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
7
|
+
createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
8
|
+
updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
|
+
updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
10
|
+
deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
11
|
+
deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowsService = void 0;
|
|
4
|
+
const flows_1 = require("../flows");
|
|
5
|
+
const items_1 = require("./items");
|
|
6
|
+
class FlowsService extends items_1.ItemsService {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super('directus_flows', options);
|
|
9
|
+
}
|
|
10
|
+
async createOne(data, opts) {
|
|
11
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
12
|
+
const result = await super.createOne(data, opts);
|
|
13
|
+
await flowManager.reload();
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
async createMany(data, opts) {
|
|
17
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
18
|
+
const result = await super.createMany(data, opts);
|
|
19
|
+
await flowManager.reload();
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
async updateOne(key, data, opts) {
|
|
23
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
24
|
+
const result = await super.updateOne(key, data, opts);
|
|
25
|
+
await flowManager.reload();
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
async updateMany(keys, data, opts) {
|
|
29
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
30
|
+
const result = await super.updateMany(keys, data, opts);
|
|
31
|
+
await flowManager.reload();
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
async deleteOne(key, opts) {
|
|
35
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
36
|
+
const result = await super.deleteOne(key, opts);
|
|
37
|
+
await flowManager.reload();
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async deleteMany(keys, opts) {
|
|
41
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
42
|
+
const result = await super.deleteMany(keys, opts);
|
|
43
|
+
await flowManager.reload();
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
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,7 +13,6 @@ 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");
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { OperationRaw } from '@directus/shared/types';
|
|
2
|
+
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
3
|
+
import { ItemsService } from './items';
|
|
4
|
+
export declare class OperationsService extends ItemsService<OperationRaw> {
|
|
5
|
+
constructor(options: AbstractServiceOptions);
|
|
6
|
+
createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
7
|
+
createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
8
|
+
updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
|
+
updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
10
|
+
deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
11
|
+
deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationsService = void 0;
|
|
4
|
+
const flows_1 = require("../flows");
|
|
5
|
+
const items_1 = require("./items");
|
|
6
|
+
class OperationsService extends items_1.ItemsService {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super('directus_operations', options);
|
|
9
|
+
}
|
|
10
|
+
async createOne(data, opts) {
|
|
11
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
12
|
+
const result = await super.createOne(data, opts);
|
|
13
|
+
await flowManager.reload();
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
async createMany(data, opts) {
|
|
17
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
18
|
+
const result = await super.createMany(data, opts);
|
|
19
|
+
await flowManager.reload();
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
async updateOne(key, data, opts) {
|
|
23
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
24
|
+
const result = await super.updateOne(key, data, opts);
|
|
25
|
+
await flowManager.reload();
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
async updateMany(keys, data, opts) {
|
|
29
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
30
|
+
const result = await super.updateMany(keys, data, opts);
|
|
31
|
+
await flowManager.reload();
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
async deleteOne(key, opts) {
|
|
35
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
36
|
+
const result = await super.deleteOne(key, opts);
|
|
37
|
+
await flowManager.reload();
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async deleteMany(keys, opts) {
|
|
41
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
42
|
+
const result = await super.deleteMany(keys, opts);
|
|
43
|
+
await flowManager.reload();
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.OperationsService = OperationsService;
|
package/dist/services/users.js
CHANGED
|
@@ -305,6 +305,7 @@ class UsersService extends items_1.ItemsService {
|
|
|
305
305
|
await (0, stall_1.stall)(STALL_TIME, timeStart);
|
|
306
306
|
}
|
|
307
307
|
async resetPassword(token, password) {
|
|
308
|
+
var _a;
|
|
308
309
|
const { email, scope, hash } = jsonwebtoken_1.default.verify(token, env_1.default.SECRET, { issuer: 'directus' });
|
|
309
310
|
if (scope !== 'password-reset' || !hash)
|
|
310
311
|
throw new exceptions_2.ForbiddenException();
|
|
@@ -317,6 +318,10 @@ class UsersService extends items_1.ItemsService {
|
|
|
317
318
|
const service = new UsersService({
|
|
318
319
|
knex: this.knex,
|
|
319
320
|
schema: this.schema,
|
|
321
|
+
accountability: {
|
|
322
|
+
...((_a = this.accountability) !== null && _a !== void 0 ? _a : { role: null }),
|
|
323
|
+
admin: true, // We need to skip permissions checks for the update call below
|
|
324
|
+
},
|
|
320
325
|
});
|
|
321
326
|
await service.updateOne(user.id, { password, status: 'active' });
|
|
322
327
|
}
|