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,138 @@
|
|
|
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 express_1 = __importDefault(require("express"));
|
|
7
|
+
const exceptions_1 = require("../exceptions");
|
|
8
|
+
const respond_1 = require("../middleware/respond");
|
|
9
|
+
const use_collection_1 = __importDefault(require("../middleware/use-collection"));
|
|
10
|
+
const validate_batch_1 = require("../middleware/validate-batch");
|
|
11
|
+
const services_1 = require("../services");
|
|
12
|
+
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
13
|
+
const router = express_1.default.Router();
|
|
14
|
+
router.use((0, use_collection_1.default)('directus_operations'));
|
|
15
|
+
router.post('/', (0, async_handler_1.default)(async (req, res, next) => {
|
|
16
|
+
const service = new services_1.OperationsService({
|
|
17
|
+
accountability: req.accountability,
|
|
18
|
+
schema: req.schema,
|
|
19
|
+
});
|
|
20
|
+
const savedKeys = [];
|
|
21
|
+
if (Array.isArray(req.body)) {
|
|
22
|
+
const keys = await service.createMany(req.body);
|
|
23
|
+
savedKeys.push(...keys);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const key = await service.createOne(req.body);
|
|
27
|
+
savedKeys.push(key);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
if (Array.isArray(req.body)) {
|
|
31
|
+
const items = await service.readMany(savedKeys, req.sanitizedQuery);
|
|
32
|
+
res.locals.payload = { data: items };
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const item = await service.readOne(savedKeys[0], req.sanitizedQuery);
|
|
36
|
+
res.locals.payload = { data: item };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof exceptions_1.ForbiddenException) {
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
return next();
|
|
46
|
+
}), respond_1.respond);
|
|
47
|
+
const readHandler = (0, async_handler_1.default)(async (req, res, next) => {
|
|
48
|
+
const service = new services_1.OperationsService({
|
|
49
|
+
accountability: req.accountability,
|
|
50
|
+
schema: req.schema,
|
|
51
|
+
});
|
|
52
|
+
const metaService = new services_1.MetaService({
|
|
53
|
+
accountability: req.accountability,
|
|
54
|
+
schema: req.schema,
|
|
55
|
+
});
|
|
56
|
+
const records = await service.readByQuery(req.sanitizedQuery);
|
|
57
|
+
const meta = await metaService.getMetaForQuery(req.collection, req.sanitizedQuery);
|
|
58
|
+
res.locals.payload = { data: records || null, meta };
|
|
59
|
+
return next();
|
|
60
|
+
});
|
|
61
|
+
router.get('/', (0, validate_batch_1.validateBatch)('read'), readHandler, respond_1.respond);
|
|
62
|
+
router.search('/', (0, validate_batch_1.validateBatch)('read'), readHandler, respond_1.respond);
|
|
63
|
+
router.get('/:pk', (0, async_handler_1.default)(async (req, res, next) => {
|
|
64
|
+
const service = new services_1.OperationsService({
|
|
65
|
+
accountability: req.accountability,
|
|
66
|
+
schema: req.schema,
|
|
67
|
+
});
|
|
68
|
+
const record = await service.readOne(req.params.pk, req.sanitizedQuery);
|
|
69
|
+
res.locals.payload = { data: record || null };
|
|
70
|
+
return next();
|
|
71
|
+
}), respond_1.respond);
|
|
72
|
+
router.patch('/', (0, validate_batch_1.validateBatch)('update'), (0, async_handler_1.default)(async (req, res, next) => {
|
|
73
|
+
const service = new services_1.OperationsService({
|
|
74
|
+
accountability: req.accountability,
|
|
75
|
+
schema: req.schema,
|
|
76
|
+
});
|
|
77
|
+
let keys = [];
|
|
78
|
+
if (req.body.keys) {
|
|
79
|
+
keys = await service.updateMany(req.body.keys, req.body.data);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
keys = await service.updateByQuery(req.body.query, req.body.data);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = await service.readMany(keys, req.sanitizedQuery);
|
|
86
|
+
res.locals.payload = { data: result };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof exceptions_1.ForbiddenException) {
|
|
90
|
+
return next();
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return next();
|
|
95
|
+
}), respond_1.respond);
|
|
96
|
+
router.patch('/:pk', (0, async_handler_1.default)(async (req, res, next) => {
|
|
97
|
+
const service = new services_1.OperationsService({
|
|
98
|
+
accountability: req.accountability,
|
|
99
|
+
schema: req.schema,
|
|
100
|
+
});
|
|
101
|
+
const primaryKey = await service.updateOne(req.params.pk, req.body);
|
|
102
|
+
try {
|
|
103
|
+
const item = await service.readOne(primaryKey, req.sanitizedQuery);
|
|
104
|
+
res.locals.payload = { data: item || null };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (error instanceof exceptions_1.ForbiddenException) {
|
|
108
|
+
return next();
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
return next();
|
|
113
|
+
}), respond_1.respond);
|
|
114
|
+
router.delete('/', (0, async_handler_1.default)(async (req, res, next) => {
|
|
115
|
+
const service = new services_1.OperationsService({
|
|
116
|
+
accountability: req.accountability,
|
|
117
|
+
schema: req.schema,
|
|
118
|
+
});
|
|
119
|
+
if (Array.isArray(req.body)) {
|
|
120
|
+
await service.deleteMany(req.body);
|
|
121
|
+
}
|
|
122
|
+
else if (req.body.keys) {
|
|
123
|
+
await service.deleteMany(req.body.keys);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await service.deleteByQuery(req.body.query);
|
|
127
|
+
}
|
|
128
|
+
return next();
|
|
129
|
+
}), respond_1.respond);
|
|
130
|
+
router.delete('/:pk', (0, async_handler_1.default)(async (req, res, next) => {
|
|
131
|
+
const service = new services_1.OperationsService({
|
|
132
|
+
accountability: req.accountability,
|
|
133
|
+
schema: req.schema,
|
|
134
|
+
});
|
|
135
|
+
await service.deleteOne(req.params.pk);
|
|
136
|
+
return next();
|
|
137
|
+
}), respond_1.respond);
|
|
138
|
+
exports.default = router;
|
package/dist/database/index.js
CHANGED
|
@@ -22,18 +22,9 @@ function getDatabase() {
|
|
|
22
22
|
if (database) {
|
|
23
23
|
return database;
|
|
24
24
|
}
|
|
25
|
-
const connectionConfig = (0, get_config_from_env_1.getConfigFromEnv)('DB_', [
|
|
26
|
-
'DB_CLIENT',
|
|
27
|
-
'DB_VERSION',
|
|
28
|
-
'DB_SEARCH_PATH',
|
|
29
|
-
'DB_CONNECTION_STRING',
|
|
30
|
-
'DB_POOL',
|
|
31
|
-
'DB_EXCLUDE_TABLES',
|
|
32
|
-
'DB_VERSION',
|
|
33
|
-
]);
|
|
34
|
-
const poolConfig = (0, get_config_from_env_1.getConfigFromEnv)('DB_POOL');
|
|
25
|
+
const { client, version, searchPath, connectionString, pool: poolConfig = {}, ...connectionConfig } = (0, get_config_from_env_1.getConfigFromEnv)('DB_', ['DB_EXCLUDE_TABLES']);
|
|
35
26
|
const requiredEnvVars = ['DB_CLIENT'];
|
|
36
|
-
switch (
|
|
27
|
+
switch (client) {
|
|
37
28
|
case 'sqlite3':
|
|
38
29
|
requiredEnvVars.push('DB_FILENAME');
|
|
39
30
|
break;
|
|
@@ -47,22 +38,27 @@ function getDatabase() {
|
|
|
47
38
|
break;
|
|
48
39
|
case 'cockroachdb':
|
|
49
40
|
case 'pg':
|
|
50
|
-
if (!
|
|
41
|
+
if (!connectionString) {
|
|
51
42
|
requiredEnvVars.push('DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USER');
|
|
52
43
|
}
|
|
53
44
|
else {
|
|
54
45
|
requiredEnvVars.push('DB_CONNECTION_STRING');
|
|
55
46
|
}
|
|
56
47
|
break;
|
|
48
|
+
case 'mssql':
|
|
49
|
+
if (!env_1.default.DB_TYPE || env_1.default.DB_TYPE === 'default') {
|
|
50
|
+
requiredEnvVars.push('DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USER', 'DB_PASSWORD');
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
57
53
|
default:
|
|
58
54
|
requiredEnvVars.push('DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USER', 'DB_PASSWORD');
|
|
59
55
|
}
|
|
60
56
|
(0, validate_env_1.validateEnv)(requiredEnvVars);
|
|
61
57
|
const knexConfig = {
|
|
62
|
-
client
|
|
63
|
-
version
|
|
64
|
-
searchPath
|
|
65
|
-
connection:
|
|
58
|
+
client,
|
|
59
|
+
version,
|
|
60
|
+
searchPath,
|
|
61
|
+
connection: connectionString || connectionConfig,
|
|
66
62
|
log: {
|
|
67
63
|
warn: (msg) => {
|
|
68
64
|
// Ignore warnings about returning not being supported in some DBs
|
|
@@ -79,7 +75,7 @@ function getDatabase() {
|
|
|
79
75
|
},
|
|
80
76
|
pool: poolConfig,
|
|
81
77
|
};
|
|
82
|
-
if (
|
|
78
|
+
if (client === 'sqlite3') {
|
|
83
79
|
knexConfig.useNullAsDefault = true;
|
|
84
80
|
poolConfig.afterCreate = async (conn, callback) => {
|
|
85
81
|
logger_1.default.trace('Enabling SQLite Foreign Keys support...');
|
|
@@ -88,7 +84,7 @@ function getDatabase() {
|
|
|
88
84
|
callback(null, conn);
|
|
89
85
|
};
|
|
90
86
|
}
|
|
91
|
-
if (
|
|
87
|
+
if (client === 'cockroachdb') {
|
|
92
88
|
poolConfig.afterCreate = async (conn, callback) => {
|
|
93
89
|
logger_1.default.trace('Setting CRDB serial_normalization and default_int_size');
|
|
94
90
|
const run = (0, util_1.promisify)(conn.query.bind(conn));
|
|
@@ -97,7 +93,7 @@ function getDatabase() {
|
|
|
97
93
|
callback(null, conn);
|
|
98
94
|
};
|
|
99
95
|
}
|
|
100
|
-
if (
|
|
96
|
+
if (client === 'mssql') {
|
|
101
97
|
// This brings MS SQL in line with the other DB vendors. We shouldn't do any automatic
|
|
102
98
|
// timezone conversion on the database level, especially not when other database vendors don't
|
|
103
99
|
// act the same
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const utils_1 = require("@directus/shared/utils");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const parse_json_1 = require("../../utils/parse-json");
|
|
7
|
+
async function up(knex) {
|
|
8
|
+
await knex.schema.createTable('directus_flows', (table) => {
|
|
9
|
+
table.uuid('id').primary().notNullable();
|
|
10
|
+
table.string('name').notNullable();
|
|
11
|
+
table.string('icon', 30);
|
|
12
|
+
table.string('color').nullable();
|
|
13
|
+
table.text('description');
|
|
14
|
+
table.string('status').notNullable().defaultTo('active');
|
|
15
|
+
table.string('trigger');
|
|
16
|
+
table.string('accountability').defaultTo('all');
|
|
17
|
+
table.json('options');
|
|
18
|
+
table.uuid('operation').unique();
|
|
19
|
+
table.timestamp('date_created').defaultTo(knex.fn.now());
|
|
20
|
+
table.uuid('user_created').references('id').inTable('directus_users').onDelete('SET NULL');
|
|
21
|
+
});
|
|
22
|
+
await knex.schema.createTable('directus_operations', (table) => {
|
|
23
|
+
table.uuid('id').primary().notNullable();
|
|
24
|
+
table.string('name');
|
|
25
|
+
table.string('key').notNullable();
|
|
26
|
+
table.string('type').notNullable();
|
|
27
|
+
table.integer('position_x').notNullable();
|
|
28
|
+
table.integer('position_y').notNullable();
|
|
29
|
+
table.json('options');
|
|
30
|
+
table.uuid('resolve').unique().references('id').inTable('directus_operations');
|
|
31
|
+
table.uuid('reject').unique().references('id').inTable('directus_operations');
|
|
32
|
+
table.uuid('flow').notNullable().references('id').inTable('directus_flows').onDelete('CASCADE');
|
|
33
|
+
table.timestamp('date_created').defaultTo(knex.fn.now());
|
|
34
|
+
table.uuid('user_created').references('id').inTable('directus_users').onDelete('SET NULL');
|
|
35
|
+
});
|
|
36
|
+
const webhooks = await knex.select('*').from('directus_webhooks');
|
|
37
|
+
const flows = [];
|
|
38
|
+
const operations = [];
|
|
39
|
+
for (const webhook of webhooks) {
|
|
40
|
+
const flowID = (0, uuid_1.v4)();
|
|
41
|
+
flows.push({
|
|
42
|
+
id: flowID,
|
|
43
|
+
name: webhook.name,
|
|
44
|
+
status: 'inactive',
|
|
45
|
+
trigger: 'hook',
|
|
46
|
+
options: JSON.stringify({
|
|
47
|
+
name: webhook.name,
|
|
48
|
+
type: 'action',
|
|
49
|
+
scope: (0, utils_1.toArray)(webhook.actions).map((scope) => `items.${scope}`),
|
|
50
|
+
collections: (0, utils_1.toArray)(webhook.collections),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
operations.push({
|
|
54
|
+
id: (0, uuid_1.v4)(),
|
|
55
|
+
name: 'Request',
|
|
56
|
+
key: 'request',
|
|
57
|
+
type: 'request',
|
|
58
|
+
position_x: 21,
|
|
59
|
+
position_y: 1,
|
|
60
|
+
options: JSON.stringify({
|
|
61
|
+
url: webhook.url,
|
|
62
|
+
headers: typeof webhook.headers === 'string' ? (0, parse_json_1.parseJSON)(webhook.headers) : webhook.headers,
|
|
63
|
+
data: webhook.data ? '{{$trigger}}' : null,
|
|
64
|
+
method: webhook.method,
|
|
65
|
+
}),
|
|
66
|
+
date_created: new Date(),
|
|
67
|
+
flow: flowID,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (flows.length && operations.length) {
|
|
71
|
+
await knex.insert(flows).into('directus_flows');
|
|
72
|
+
await knex.insert(operations).into('directus_operations');
|
|
73
|
+
for (const operation of operations) {
|
|
74
|
+
await knex('directus_flows').update({ operation: operation.id }).where({ id: operation.flow });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.up = up;
|
|
79
|
+
async function down(knex) {
|
|
80
|
+
await knex.schema.dropTable('directus_operations');
|
|
81
|
+
await knex.schema.dropTable('directus_flows');
|
|
82
|
+
}
|
|
83
|
+
exports.down = down;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
async function up(knex) {
|
|
5
|
+
await knex.schema.alterTable('directus_dashboards', (table) => {
|
|
6
|
+
table.string('color').nullable();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.up = up;
|
|
10
|
+
async function down(knex) {
|
|
11
|
+
await knex.schema.alterTable('directus_dashboards', (table) => {
|
|
12
|
+
table.dropColumn('color');
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.down = down;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
async function up(knex) {
|
|
5
|
+
await knex.schema.alterTable('directus_activity', (table) => {
|
|
6
|
+
table.setNullable('ip');
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.up = up;
|
|
10
|
+
async function down(knex) {
|
|
11
|
+
await knex.schema.alterTable('directus_activity', (table) => {
|
|
12
|
+
table.dropNullable('ip');
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.down = down;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
async function up(knex) {
|
|
5
|
+
await knex.schema.alterTable('directus_notifications', (table) => {
|
|
6
|
+
table.setNullable('sender');
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.up = up;
|
|
10
|
+
async function down(knex) {
|
|
11
|
+
await knex.schema.alterTable('directus_notifications', (table) => {
|
|
12
|
+
table.dropNullable('sender');
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.down = down;
|
|
@@ -68,3 +68,7 @@ data:
|
|
|
68
68
|
- collection: directus_shares
|
|
69
69
|
icon: share
|
|
70
70
|
note: $t:directus_collection.directus_shares
|
|
71
|
+
- collection: directus_flows
|
|
72
|
+
note: $t:directus_collection.directus_flows
|
|
73
|
+
- collection: directus_operations
|
|
74
|
+
note: $t:directus_collection.directus_operations
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
table: directus_flows
|
|
2
|
+
|
|
3
|
+
fields:
|
|
4
|
+
- field: id
|
|
5
|
+
special: uuid
|
|
6
|
+
- field: name
|
|
7
|
+
- field: icon
|
|
8
|
+
- field: color
|
|
9
|
+
- field: note
|
|
10
|
+
- field: status
|
|
11
|
+
- field: trigger
|
|
12
|
+
- field: accountability
|
|
13
|
+
- field: options
|
|
14
|
+
special: cast-json
|
|
15
|
+
- field: operation
|
|
16
|
+
- field: operations
|
|
17
|
+
special: o2m
|
|
18
|
+
- field: date_created
|
|
19
|
+
special: date-created
|
|
20
|
+
- field: user_created
|
|
21
|
+
special: user-created
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
table: directus_operations
|
|
2
|
+
|
|
3
|
+
fields:
|
|
4
|
+
- field: id
|
|
5
|
+
special: uuid
|
|
6
|
+
- field: name
|
|
7
|
+
- field: key
|
|
8
|
+
- field: type
|
|
9
|
+
- field: position_x
|
|
10
|
+
- field: position_y
|
|
11
|
+
- field: options
|
|
12
|
+
special: cast-json
|
|
13
|
+
- field: resolve
|
|
14
|
+
- field: reject
|
|
15
|
+
- field: flow
|
|
16
|
+
- field: date_created
|
|
17
|
+
special: date-created
|
|
18
|
+
- field: user_created
|
|
19
|
+
special: user-created
|
|
@@ -135,10 +135,8 @@ fields:
|
|
|
135
135
|
template: '{{ name }}'
|
|
136
136
|
|
|
137
137
|
- field: token
|
|
138
|
-
interface: token
|
|
139
|
-
|
|
140
|
-
iconRight: vpn_key
|
|
141
|
-
placeholder: $t:fields.directus_users.token_placeholder
|
|
138
|
+
interface: system-token
|
|
139
|
+
special: conceal
|
|
142
140
|
width: full
|
|
143
141
|
|
|
144
142
|
- field: id
|
|
@@ -61,6 +61,20 @@ data:
|
|
|
61
61
|
many_field: dashboard
|
|
62
62
|
one_collection: directus_dashboards
|
|
63
63
|
one_field: panels
|
|
64
|
+
- many_collection: directus_flows
|
|
65
|
+
many_field: operation
|
|
66
|
+
one_collection: directus_operations
|
|
67
|
+
- many_collection: directus_operations
|
|
68
|
+
many_field: flow
|
|
69
|
+
one_collection: directus_flows
|
|
70
|
+
one_field: operations
|
|
71
|
+
one_deselect_action: delete
|
|
72
|
+
- many_collection: directus_operations
|
|
73
|
+
many_field: resolve
|
|
74
|
+
one_collection: directus_operations
|
|
75
|
+
- many_collection: directus_operations
|
|
76
|
+
many_field: reject
|
|
77
|
+
one_collection: directus_operations
|
|
64
78
|
- many_collection: directus_files
|
|
65
79
|
many_field: modified_by
|
|
66
80
|
one_collection: directus_users
|
|
@@ -88,6 +102,12 @@ data:
|
|
|
88
102
|
- many_collection: directus_panels
|
|
89
103
|
many_field: user_created
|
|
90
104
|
one_collection: directus_users
|
|
105
|
+
- many_collection: directus_flows
|
|
106
|
+
many_field: user_created
|
|
107
|
+
one_collection: directus_users
|
|
108
|
+
- many_collection: directus_operations
|
|
109
|
+
many_field: user_created
|
|
110
|
+
one_collection: directus_users
|
|
91
111
|
- many_collection: directus_notifications
|
|
92
112
|
many_field: recipient
|
|
93
113
|
one_collection: directus_users
|