directus 9.12.0 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +11 -1
- package/dist/auth/drivers/index.js +5 -1
- package/dist/auth/drivers/ldap.js +5 -1
- package/dist/auth/drivers/oauth2.js +15 -23
- package/dist/auth/drivers/openid.js +16 -24
- package/dist/cli/commands/bootstrap/index.js +5 -1
- package/dist/cli/commands/schema/apply.js +7 -3
- package/dist/cli/commands/schema/snapshot.d.ts +1 -1
- package/dist/cli/commands/schema/snapshot.js +33 -25
- package/dist/cli/index.js +1 -1
- package/dist/cli/utils/create-env/env-stub.liquid +11 -11
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +5 -1
- package/dist/controllers/assets.js +5 -5
- package/dist/controllers/dashboards.js +4 -1
- package/dist/controllers/files.js +8 -5
- package/dist/controllers/flows.js +4 -1
- package/dist/controllers/folders.js +4 -1
- package/dist/controllers/items.js +4 -1
- package/dist/controllers/notifications.js +4 -1
- package/dist/controllers/operations.js +4 -1
- package/dist/controllers/panels.js +4 -1
- package/dist/controllers/permissions.js +4 -1
- package/dist/controllers/presets.js +4 -1
- package/dist/controllers/roles.js +4 -1
- package/dist/controllers/shares.js +4 -1
- package/dist/controllers/users.js +75 -3
- package/dist/controllers/utils.js +3 -3
- package/dist/database/helpers/date/dialects/sqlite.js +3 -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/helpers/index.js +5 -1
- package/dist/database/index.js +2 -0
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +2 -2
- package/dist/database/migrations/20210506A-rename-interfaces.js +2 -2
- package/dist/database/migrations/20210802A-replace-groups.js +2 -2
- package/dist/database/migrations/20210805A-update-groups.js +2 -2
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +3 -3
- package/dist/database/migrations/20211007A-update-presets.js +5 -5
- package/dist/database/migrations/20220429A-add-flows.js +1 -2
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +3 -0
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.js +11 -0
- package/dist/database/system-data/fields/dashboards.yaml +1 -0
- package/dist/database/system-data/fields/flows.yaml +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.js +8 -3
- package/dist/exceptions/database/translate.js +5 -1
- package/dist/exceptions/index.js +5 -1
- package/dist/extensions.d.ts +2 -1
- package/dist/extensions.js +31 -23
- package/dist/flows.d.ts +5 -0
- package/dist/flows.js +66 -40
- package/dist/index.js +5 -1
- package/dist/logger.js +5 -1
- package/dist/messenger.js +2 -2
- package/dist/middleware/graphql.js +2 -2
- package/dist/middleware/respond.js +10 -1
- package/dist/middleware/validate-batch.js +3 -1
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -0
- package/dist/operations/item-delete/index.js +8 -7
- package/dist/operations/item-read/index.js +7 -6
- package/dist/operations/item-update/index.d.ts +1 -0
- package/dist/operations/item-update/index.js +9 -8
- package/dist/operations/log/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.d.ts +4 -1
- package/dist/operations/request/index.js +5 -1
- package/dist/operations/transform/index.js +1 -2
- package/dist/operations/trigger/index.js +1 -2
- package/dist/server.js +5 -1
- package/dist/services/assets.js +5 -1
- package/dist/services/collections.js +5 -1
- package/dist/services/fields.d.ts +3 -3
- package/dist/services/fields.js +25 -17
- package/dist/services/files.js +5 -1
- package/dist/services/flows.d.ts +1 -2
- package/dist/services/flows.js +19 -8
- package/dist/services/{graphql.d.ts → graphql/index.d.ts} +3 -5
- package/dist/services/{graphql.js → graphql/index.js} +115 -102
- package/dist/services/graphql/types/date.d.ts +2 -0
- package/dist/services/graphql/types/date.js +9 -0
- package/dist/services/graphql/types/geojson.d.ts +2 -0
- package/dist/services/graphql/types/geojson.js +10 -0
- package/dist/services/graphql/types/string-or-float.d.ts +5 -0
- package/dist/services/graphql/types/string-or-float.js +34 -0
- package/dist/services/graphql/types/void.d.ts +2 -0
- package/dist/services/graphql/types/void.js +17 -0
- package/dist/services/graphql/utils/add-path-to-validation-error.d.ts +2 -0
- package/dist/services/graphql/utils/add-path-to-validation-error.js +20 -0
- package/dist/services/import-export.js +13 -10
- package/dist/services/index.js +5 -1
- package/dist/services/items.d.ts +5 -1
- package/dist/services/items.js +22 -2
- package/dist/services/mail/index.js +8 -6
- package/dist/services/operations.d.ts +1 -2
- package/dist/services/operations.js +19 -8
- package/dist/services/payload.js +2 -3
- package/dist/services/permissions.d.ts +1 -0
- package/dist/services/permissions.js +5 -0
- package/dist/services/relations.js +5 -1
- package/dist/services/roles.d.ts +1 -0
- package/dist/services/roles.js +9 -0
- package/dist/services/server.js +5 -1
- package/dist/services/users.d.ts +1 -0
- package/dist/services/users.js +22 -0
- package/dist/types/index.js +5 -1
- package/dist/utils/apply-query.js +24 -15
- package/dist/utils/apply-snapshot.js +3 -0
- package/dist/utils/calculate-field-depth.d.ts +33 -0
- package/dist/utils/calculate-field-depth.js +75 -0
- package/dist/utils/get-column.js +1 -1
- package/dist/utils/get-default-value.js +3 -13
- package/dist/utils/get-graphql-type.js +4 -3
- package/dist/utils/get-local-type.d.ts +6 -3
- package/dist/utils/get-permissions.js +3 -4
- package/dist/utils/get-schema.js +1 -2
- package/dist/utils/get-string-byte-size.d.ts +4 -0
- package/dist/utils/get-string-byte-size.js +10 -0
- package/dist/utils/job-queue.d.ts +9 -0
- package/dist/utils/job-queue.js +24 -0
- package/dist/utils/jwt.js +5 -1
- package/dist/utils/sanitize-query.js +4 -5
- package/dist/utils/validate-query.js +50 -0
- package/dist/webhooks.js +5 -1
- package/package.json +75 -74
- package/dist/utils/operation-options.d.ts +0 -3
- package/dist/utils/operation-options.js +0 -45
- package/dist/utils/parse-json.d.ts +0 -5
- package/dist/utils/parse-json.js +0 -19
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const services_1 = require("../../services");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
7
6
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
7
|
id: 'item-create',
|
|
@@ -27,7 +26,7 @@ exports.default = (0, utils_1.defineOperationApi)({
|
|
|
27
26
|
accountability: customAccountability,
|
|
28
27
|
knex: database,
|
|
29
28
|
});
|
|
30
|
-
const payloadObject = (_a = (0,
|
|
29
|
+
const payloadObject = (_a = (0, utils_1.optionToObject)(payload)) !== null && _a !== void 0 ? _a : null;
|
|
31
30
|
let result;
|
|
32
31
|
if (!payloadObject) {
|
|
33
32
|
result = null;
|
|
@@ -3,6 +3,7 @@ declare type Options = {
|
|
|
3
3
|
collection: string;
|
|
4
4
|
key?: PrimaryKey | PrimaryKey[] | null;
|
|
5
5
|
query?: Record<string, any> | string | null;
|
|
6
|
+
emitEvents: boolean;
|
|
6
7
|
permissions: string;
|
|
7
8
|
};
|
|
8
9
|
declare const _default: import("@directus/shared/types").OperationApiConfig<Options>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const services_1 = require("../../services");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
6
|
+
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
7
7
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
8
|
id: 'item-delete',
|
|
9
|
-
handler: async ({ collection, key, query, permissions }, { accountability, database, getSchema }) => {
|
|
9
|
+
handler: async ({ collection, key, query, emitEvents, permissions }, { accountability, database, getSchema }) => {
|
|
10
10
|
const schema = await getSchema({ database });
|
|
11
11
|
let customAccountability;
|
|
12
12
|
if (!permissions || permissions === '$trigger') {
|
|
@@ -26,18 +26,19 @@ exports.default = (0, utils_1.defineOperationApi)({
|
|
|
26
26
|
accountability: customAccountability,
|
|
27
27
|
knex: database,
|
|
28
28
|
});
|
|
29
|
-
const queryObject = query ? (0,
|
|
29
|
+
const queryObject = query ? (0, utils_1.optionToObject)(query) : {};
|
|
30
|
+
const sanitizedQueryObject = (0, sanitize_query_1.sanitizeQuery)(queryObject, customAccountability);
|
|
30
31
|
let result;
|
|
31
|
-
if (!key) {
|
|
32
|
-
result = await itemsService.deleteByQuery(
|
|
32
|
+
if (!key || (Array.isArray(key) && key.length === 0)) {
|
|
33
|
+
result = await itemsService.deleteByQuery(sanitizedQueryObject);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
const keys = (0, utils_1.toArray)(key);
|
|
36
37
|
if (keys.length === 1) {
|
|
37
|
-
result = await itemsService.deleteOne(keys[0]);
|
|
38
|
+
result = await itemsService.deleteOne(keys[0], { emitEvents });
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
result = await itemsService.deleteMany(keys);
|
|
41
|
+
result = await itemsService.deleteMany(keys, { emitEvents });
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
return result;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const services_1 = require("../../services");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
6
|
+
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
7
7
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
8
|
id: 'item-read',
|
|
9
9
|
handler: async ({ collection, key, query, permissions }, { accountability, database, getSchema }) => {
|
|
@@ -26,18 +26,19 @@ exports.default = (0, utils_1.defineOperationApi)({
|
|
|
26
26
|
accountability: customAccountability,
|
|
27
27
|
knex: database,
|
|
28
28
|
});
|
|
29
|
-
const queryObject = query ? (0,
|
|
29
|
+
const queryObject = query ? (0, utils_1.optionToObject)(query) : {};
|
|
30
|
+
const sanitizedQueryObject = (0, sanitize_query_1.sanitizeQuery)(queryObject, customAccountability);
|
|
30
31
|
let result;
|
|
31
|
-
if (!key) {
|
|
32
|
-
result = await itemsService.readByQuery(
|
|
32
|
+
if (!key || (Array.isArray(key) && key.length === 0)) {
|
|
33
|
+
result = await itemsService.readByQuery(sanitizedQueryObject);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
const keys = (0, utils_1.toArray)(key);
|
|
36
37
|
if (keys.length === 1) {
|
|
37
|
-
result = await itemsService.readOne(keys[0],
|
|
38
|
+
result = await itemsService.readOne(keys[0], sanitizedQueryObject);
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
result = await itemsService.readMany(keys,
|
|
41
|
+
result = await itemsService.readMany(keys, sanitizedQueryObject);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
return result;
|
|
@@ -4,6 +4,7 @@ declare type Options = {
|
|
|
4
4
|
key?: PrimaryKey | PrimaryKey[] | null;
|
|
5
5
|
payload?: Record<string, any> | string | null;
|
|
6
6
|
query?: Record<string, any> | string | null;
|
|
7
|
+
emitEvents: boolean;
|
|
7
8
|
permissions: string;
|
|
8
9
|
};
|
|
9
10
|
declare const _default: import("@directus/shared/types").OperationApiConfig<Options>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const services_1 = require("../../services");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
6
|
+
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
7
7
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
8
|
id: 'item-update',
|
|
9
|
-
handler: async ({ collection, key, payload, query, permissions }, { accountability, database, getSchema }) => {
|
|
9
|
+
handler: async ({ collection, key, payload, query, emitEvents, permissions }, { accountability, database, getSchema }) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const schema = await getSchema({ database });
|
|
12
12
|
let customAccountability;
|
|
@@ -27,22 +27,23 @@ exports.default = (0, utils_1.defineOperationApi)({
|
|
|
27
27
|
accountability: customAccountability,
|
|
28
28
|
knex: database,
|
|
29
29
|
});
|
|
30
|
-
const payloadObject = (_a = (0,
|
|
31
|
-
const queryObject = query ? (0,
|
|
30
|
+
const payloadObject = (_a = (0, utils_1.optionToObject)(payload)) !== null && _a !== void 0 ? _a : null;
|
|
31
|
+
const queryObject = query ? (0, utils_1.optionToObject)(query) : {};
|
|
32
|
+
const sanitizedQueryObject = (0, sanitize_query_1.sanitizeQuery)(queryObject, customAccountability);
|
|
32
33
|
if (!payloadObject) {
|
|
33
34
|
return null;
|
|
34
35
|
}
|
|
35
36
|
let result;
|
|
36
|
-
if (!key) {
|
|
37
|
-
result = await itemsService.updateByQuery(
|
|
37
|
+
if (!key || (Array.isArray(key) && key.length === 0)) {
|
|
38
|
+
result = await itemsService.updateByQuery(sanitizedQueryObject, payloadObject, { emitEvents });
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
41
|
const keys = (0, utils_1.toArray)(key);
|
|
41
42
|
if (keys.length === 1) {
|
|
42
|
-
result = await itemsService.updateOne(keys[0], payloadObject);
|
|
43
|
+
result = await itemsService.updateOne(keys[0], payloadObject, { emitEvents });
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
|
-
result = await itemsService.updateMany(keys, payloadObject);
|
|
46
|
+
result = await itemsService.updateMany(keys, payloadObject, { emitEvents });
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
return result;
|
|
@@ -5,10 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("@directus/shared/utils");
|
|
7
7
|
const logger_1 = __importDefault(require("../../logger"));
|
|
8
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
9
8
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
10
9
|
id: 'log',
|
|
11
10
|
handler: ({ message }) => {
|
|
12
|
-
logger_1.default.info((0,
|
|
11
|
+
logger_1.default.info((0, utils_1.optionToString)(message));
|
|
13
12
|
},
|
|
14
13
|
});
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const services_1 = require("../../services");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
const get_accountability_for_role_1 = require("../../utils/get-accountability-for-role");
|
|
7
6
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
8
7
|
id: 'notification',
|
|
@@ -27,7 +26,7 @@ exports.default = (0, utils_1.defineOperationApi)({
|
|
|
27
26
|
accountability: customAccountability,
|
|
28
27
|
knex: database,
|
|
29
28
|
});
|
|
30
|
-
const messageString = message ? (0,
|
|
29
|
+
const messageString = message ? (0, utils_1.optionToString)(message) : null;
|
|
31
30
|
const result = await notificationsService.createOne({
|
|
32
31
|
recipient,
|
|
33
32
|
sender: (_a = customAccountability === null || customAccountability === void 0 ? void 0 : customAccountability.user) !== null && _a !== void 0 ? _a : null,
|
|
@@ -3,7 +3,10 @@ declare type Options = {
|
|
|
3
3
|
url: string;
|
|
4
4
|
method: Method;
|
|
5
5
|
body: Record<string, any> | string | null;
|
|
6
|
-
headers
|
|
6
|
+
headers?: {
|
|
7
|
+
header: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[] | null;
|
|
7
10
|
};
|
|
8
11
|
declare const _default: import("@directus/shared/types").OperationApiConfig<Options>;
|
|
9
12
|
export default _default;
|
|
@@ -8,7 +8,11 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
9
9
|
id: 'request',
|
|
10
10
|
handler: async ({ url, method, body, headers }) => {
|
|
11
|
-
const
|
|
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 });
|
|
12
16
|
return { status: result.status, statusText: result.statusText, headers: result.headers, data: result.data };
|
|
13
17
|
},
|
|
14
18
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
|
-
const parse_json_1 = require("../../utils/parse-json");
|
|
5
4
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
6
5
|
id: 'transform',
|
|
7
6
|
handler: ({ json }) => {
|
|
8
|
-
return (0,
|
|
7
|
+
return (0, utils_1.parseJSON)(json);
|
|
9
8
|
},
|
|
10
9
|
});
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@directus/shared/utils");
|
|
4
4
|
const flows_1 = require("../../flows");
|
|
5
|
-
const operation_options_1 = require("../../utils/operation-options");
|
|
6
5
|
exports.default = (0, utils_1.defineOperationApi)({
|
|
7
6
|
id: 'trigger',
|
|
8
7
|
handler: async ({ flow, payload }, context) => {
|
|
9
8
|
var _a;
|
|
10
9
|
const flowManager = (0, flows_1.getFlowManager)();
|
|
11
|
-
const payloadObject = (_a = (0,
|
|
10
|
+
const payloadObject = (_a = (0, utils_1.optionToObject)(payload)) !== null && _a !== void 0 ? _a : null;
|
|
12
11
|
let result;
|
|
13
12
|
if (Array.isArray(payloadObject)) {
|
|
14
13
|
result = await Promise.all(payloadObject.map((payload) => flowManager.runOperationFlow(flow, payload, context)));
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/services/assets.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import SchemaInspector from '@directus/schema';
|
|
2
|
+
import { Accountability, Field, RawField, SchemaOverview, Type } from '@directus/shared/types';
|
|
3
|
+
import Keyv from 'keyv';
|
|
2
4
|
import { Knex } from 'knex';
|
|
3
5
|
import { Column } from 'knex-schema-inspector/dist/types/column';
|
|
6
|
+
import { Helpers } from '../database/helpers';
|
|
4
7
|
import { ItemsService } from '../services/items';
|
|
5
8
|
import { PayloadService } from '../services/payload';
|
|
6
9
|
import { AbstractServiceOptions } from '../types';
|
|
7
|
-
import { Field, RawField, Type, Accountability, SchemaOverview } from '@directus/shared/types';
|
|
8
|
-
import { Helpers } from '../database/helpers';
|
|
9
|
-
import Keyv from 'keyv';
|
|
10
10
|
export declare class FieldsService {
|
|
11
11
|
knex: Knex;
|
|
12
12
|
helpers: Helpers;
|
package/dist/services/fields.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -24,9 +28,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
29
|
exports.FieldsService = void 0;
|
|
26
30
|
const schema_1 = __importDefault(require("@directus/schema"));
|
|
31
|
+
const constants_1 = require("@directus/shared/constants");
|
|
32
|
+
const utils_1 = require("@directus/shared/utils");
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
27
34
|
const cache_1 = require("../cache");
|
|
28
|
-
const
|
|
35
|
+
const constants_2 = require("../constants");
|
|
29
36
|
const database_1 = __importStar(require("../database"));
|
|
37
|
+
const helpers_1 = require("../database/helpers");
|
|
30
38
|
const fields_1 = require("../database/system-data/fields/");
|
|
31
39
|
const emitter_1 = __importDefault(require("../emitter"));
|
|
32
40
|
const env_1 = __importDefault(require("../env"));
|
|
@@ -36,11 +44,8 @@ const items_1 = require("../services/items");
|
|
|
36
44
|
const payload_1 = require("../services/payload");
|
|
37
45
|
const get_default_value_1 = __importDefault(require("../utils/get-default-value"));
|
|
38
46
|
const get_local_type_1 = __importDefault(require("../utils/get-local-type"));
|
|
39
|
-
const utils_1 = require("@directus/shared/utils");
|
|
40
|
-
const lodash_1 = require("lodash");
|
|
41
47
|
const relations_1 = require("./relations");
|
|
42
|
-
const
|
|
43
|
-
const constants_2 = require("@directus/shared/constants");
|
|
48
|
+
const constants_3 = require("@directus/shared/constants");
|
|
44
49
|
class FieldsService {
|
|
45
50
|
constructor(options) {
|
|
46
51
|
this.knex = options.knex || (0, database_1.default)();
|
|
@@ -112,7 +117,7 @@ class FieldsService {
|
|
|
112
117
|
}
|
|
113
118
|
aliasFields = aliasFields.filter((field) => {
|
|
114
119
|
const specials = (0, utils_1.toArray)(field.special);
|
|
115
|
-
for (const type of
|
|
120
|
+
for (const type of constants_2.ALIAS_TYPES) {
|
|
116
121
|
if (specials.includes(type))
|
|
117
122
|
return true;
|
|
118
123
|
}
|
|
@@ -190,7 +195,6 @@ class FieldsService {
|
|
|
190
195
|
fields_1.systemFieldRows.find((fieldMeta) => fieldMeta.collection === collection && fieldMeta.field === field);
|
|
191
196
|
try {
|
|
192
197
|
column = await this.schemaInspector.columnInfo(collection, field);
|
|
193
|
-
column.default_value = (0, get_default_value_1.default)(column);
|
|
194
198
|
}
|
|
195
199
|
catch {
|
|
196
200
|
// Do nothing
|
|
@@ -198,12 +202,18 @@ class FieldsService {
|
|
|
198
202
|
if (!column && !fieldInfo)
|
|
199
203
|
throw new exceptions_1.ForbiddenException();
|
|
200
204
|
const type = (0, get_local_type_1.default)(column, fieldInfo);
|
|
205
|
+
const columnWithCastDefaultValue = column
|
|
206
|
+
? {
|
|
207
|
+
...column,
|
|
208
|
+
default_value: (0, get_default_value_1.default)(column),
|
|
209
|
+
}
|
|
210
|
+
: null;
|
|
201
211
|
const data = {
|
|
202
212
|
collection,
|
|
203
213
|
field,
|
|
204
214
|
type,
|
|
205
215
|
meta: fieldInfo || null,
|
|
206
|
-
schema: type === 'alias' ? null :
|
|
216
|
+
schema: type === 'alias' ? null : columnWithCastDefaultValue,
|
|
207
217
|
};
|
|
208
218
|
return data;
|
|
209
219
|
}
|
|
@@ -237,7 +247,7 @@ class FieldsService {
|
|
|
237
247
|
schema: this.schema,
|
|
238
248
|
accountability: this.accountability,
|
|
239
249
|
});
|
|
240
|
-
if (hookAdjustedField.type &&
|
|
250
|
+
if (hookAdjustedField.type && constants_2.ALIAS_TYPES.includes(hookAdjustedField.type) === false) {
|
|
241
251
|
if (table) {
|
|
242
252
|
this.addColumnToTable(table, hookAdjustedField);
|
|
243
253
|
}
|
|
@@ -472,10 +482,12 @@ class FieldsService {
|
|
|
472
482
|
else if (field.type.startsWith('geometry')) {
|
|
473
483
|
column = this.helpers.st.createColumn(table, field);
|
|
474
484
|
}
|
|
475
|
-
else {
|
|
476
|
-
// @ts-ignore
|
|
485
|
+
else if (constants_3.KNEX_TYPES.includes(field.type)) {
|
|
477
486
|
column = table[field.type](field.field);
|
|
478
487
|
}
|
|
488
|
+
else {
|
|
489
|
+
throw new exceptions_1.InvalidPayloadException(`Illegal type passed: "${field.type}"`);
|
|
490
|
+
}
|
|
479
491
|
if (((_f = field.schema) === null || _f === void 0 ? void 0 : _f.default_value) !== undefined) {
|
|
480
492
|
if (typeof field.schema.default_value === 'string' &&
|
|
481
493
|
(field.schema.default_value.toLowerCase() === 'now()' || field.schema.default_value === 'CURRENT_TIMESTAMP')) {
|
|
@@ -484,13 +496,9 @@ class FieldsService {
|
|
|
484
496
|
else if (typeof field.schema.default_value === 'string' &&
|
|
485
497
|
field.schema.default_value.includes('CURRENT_TIMESTAMP(') &&
|
|
486
498
|
field.schema.default_value.includes(')')) {
|
|
487
|
-
const precision = field.schema.default_value.match(
|
|
499
|
+
const precision = field.schema.default_value.match(constants_1.REGEX_BETWEEN_PARENS)[1];
|
|
488
500
|
column.defaultTo(this.knex.fn.now(Number(precision)));
|
|
489
501
|
}
|
|
490
|
-
else if (typeof field.schema.default_value === 'string' &&
|
|
491
|
-
['"null"', 'null'].includes(field.schema.default_value.toLowerCase())) {
|
|
492
|
-
column.defaultTo(null);
|
|
493
|
-
}
|
|
494
502
|
else {
|
|
495
503
|
column.defaultTo(field.schema.default_value);
|
|
496
504
|
}
|
package/dist/services/files.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/services/flows.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { FlowRaw } from '@directus/shared/types';
|
|
2
|
-
import { Messenger } from '../messenger';
|
|
3
2
|
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
4
3
|
import { ItemsService } from './items';
|
|
5
4
|
export declare class FlowsService extends ItemsService<FlowRaw> {
|
|
6
|
-
messenger: Messenger;
|
|
7
5
|
constructor(options: AbstractServiceOptions);
|
|
8
6
|
createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
7
|
createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
10
8
|
updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
9
|
+
updateBatch(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
11
10
|
updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]>;
|
|
12
11
|
deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey>;
|
|
13
12
|
deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]>;
|
package/dist/services/flows.js
CHANGED
|
@@ -1,41 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowsService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const flows_1 = require("../flows");
|
|
5
5
|
const items_1 = require("./items");
|
|
6
6
|
class FlowsService extends items_1.ItemsService {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super('directus_flows', options);
|
|
9
|
-
this.messenger = (0, messenger_1.getMessenger)();
|
|
10
9
|
}
|
|
11
10
|
async createOne(data, opts) {
|
|
11
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
12
12
|
const result = await super.createOne(data, opts);
|
|
13
|
-
|
|
13
|
+
await flowManager.reload();
|
|
14
14
|
return result;
|
|
15
15
|
}
|
|
16
16
|
async createMany(data, opts) {
|
|
17
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
17
18
|
const result = await super.createMany(data, opts);
|
|
18
|
-
|
|
19
|
+
await flowManager.reload();
|
|
19
20
|
return result;
|
|
20
21
|
}
|
|
21
22
|
async updateOne(key, data, opts) {
|
|
23
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
22
24
|
const result = await super.updateOne(key, data, opts);
|
|
23
|
-
|
|
25
|
+
await flowManager.reload();
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
async updateBatch(data, opts) {
|
|
29
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
30
|
+
const result = await super.updateBatch(data, opts);
|
|
31
|
+
await flowManager.reload();
|
|
24
32
|
return result;
|
|
25
33
|
}
|
|
26
34
|
async updateMany(keys, data, opts) {
|
|
35
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
27
36
|
const result = await super.updateMany(keys, data, opts);
|
|
28
|
-
|
|
37
|
+
await flowManager.reload();
|
|
29
38
|
return result;
|
|
30
39
|
}
|
|
31
40
|
async deleteOne(key, opts) {
|
|
41
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
32
42
|
const result = await super.deleteOne(key, opts);
|
|
33
|
-
|
|
43
|
+
await flowManager.reload();
|
|
34
44
|
return result;
|
|
35
45
|
}
|
|
36
46
|
async deleteMany(keys, opts) {
|
|
47
|
+
const flowManager = (0, flows_1.getFlowManager)();
|
|
37
48
|
const result = await super.deleteMany(keys, opts);
|
|
38
|
-
|
|
49
|
+
await flowManager.reload();
|
|
39
50
|
return result;
|
|
40
51
|
}
|
|
41
52
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { BaseException } from '@directus/shared/exceptions';
|
|
2
2
|
import { Accountability, Query, SchemaOverview } from '@directus/shared/types';
|
|
3
|
-
import { ArgumentNode, FormattedExecutionResult, FragmentDefinitionNode, GraphQLError, GraphQLResolveInfo,
|
|
3
|
+
import { ArgumentNode, FormattedExecutionResult, FragmentDefinitionNode, GraphQLError, GraphQLResolveInfo, GraphQLSchema, ObjectFieldNode, SelectionNode } from 'graphql';
|
|
4
4
|
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
5
5
|
import { Knex } from 'knex';
|
|
6
|
-
import { AbstractServiceOptions, GraphQLParams, Item } from '
|
|
7
|
-
import { ItemsService } from '
|
|
8
|
-
export declare const GraphQLGeoJSON: GraphQLScalarType;
|
|
9
|
-
export declare const GraphQLDate: GraphQLScalarType;
|
|
6
|
+
import { AbstractServiceOptions, GraphQLParams, Item } from '../../types';
|
|
7
|
+
import { ItemsService } from '../items';
|
|
10
8
|
export declare class GraphQLService {
|
|
11
9
|
accountability: Accountability | null;
|
|
12
10
|
knex: Knex;
|