directus 9.23.3 → 9.23.4
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 +12 -12
- package/dist/auth/drivers/ldap.js +22 -22
- package/dist/auth/drivers/local.js +7 -7
- package/dist/auth/drivers/oauth2.js +27 -25
- package/dist/auth/drivers/openid.js +32 -30
- package/dist/auth/drivers/saml.js +10 -10
- package/dist/auth.js +4 -3
- package/dist/cache.js +16 -11
- package/dist/cli/commands/bootstrap/index.js +5 -4
- package/dist/cli/utils/create-db-connection.js +1 -1
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +6 -5
- package/dist/controllers/activity.js +9 -9
- package/dist/controllers/assets.js +19 -18
- package/dist/controllers/auth.js +13 -13
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +9 -9
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +16 -16
- package/dist/controllers/files.js +16 -15
- package/dist/controllers/flows.js +11 -11
- package/dist/controllers/folders.js +9 -9
- package/dist/controllers/graphql.js +6 -6
- package/dist/controllers/items.js +17 -17
- package/dist/controllers/notifications.js +9 -9
- package/dist/controllers/operations.js +9 -9
- package/dist/controllers/panels.js +9 -9
- package/dist/controllers/permissions.js +9 -9
- package/dist/controllers/presets.js +9 -9
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +9 -9
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +13 -13
- package/dist/controllers/users.js +16 -16
- package/dist/controllers/utils.js +5 -5
- package/dist/controllers/webhooks.js +9 -9
- package/dist/database/helpers/fn/types.d.ts +0 -1
- package/dist/database/helpers/fn/types.js +0 -2
- package/dist/database/helpers/index.d.ts +3 -3
- package/dist/database/index.js +5 -5
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast.js +4 -4
- package/dist/database/system-data/collections/index.js +2 -2
- package/dist/database/system-data/fields/index.js +3 -3
- package/dist/env.js +1 -1
- package/dist/extensions.js +10 -10
- package/dist/flows.js +33 -31
- package/dist/logger.d.ts +1 -0
- package/dist/logger.js +32 -32
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +4 -4
- package/dist/middleware/authenticate.js +1 -1
- package/dist/middleware/cache.js +11 -11
- package/dist/middleware/collection-exists.js +3 -3
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.js +2 -2
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/graphql.js +12 -6
- package/dist/middleware/rate-limiter-global.js +5 -5
- package/dist/middleware/rate-limiter-ip.js +2 -2
- package/dist/middleware/respond.js +16 -16
- package/dist/middleware/sanitize-query.js +1 -1
- package/dist/operations/exec/index.js +2 -2
- package/dist/rate-limiter.js +1 -1
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +4 -4
- package/dist/services/activity.js +14 -14
- package/dist/services/assets.js +6 -6
- package/dist/services/authentication.js +9 -9
- package/dist/services/collections.js +9 -9
- package/dist/services/fields.js +5 -5
- package/dist/services/files.js +12 -12
- package/dist/services/graphql/index.js +100 -98
- package/dist/services/import-export.js +6 -6
- package/dist/services/items.js +6 -6
- package/dist/services/mail/index.js +5 -5
- package/dist/services/meta.js +1 -0
- package/dist/services/notifications.js +4 -4
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.js +5 -5
- package/dist/services/server.js +27 -27
- package/dist/services/shares.js +9 -9
- package/dist/services/specifications.js +5 -3
- package/dist/services/users.d.ts +1 -5
- package/dist/services/users.js +24 -27
- package/dist/storage/register-locations.js +1 -1
- package/dist/utils/apply-query.js +2 -1
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/generate-hash.js +1 -1
- package/dist/utils/get-ast-from-query.js +1 -1
- package/dist/utils/get-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.js +3 -3
- package/dist/utils/get-collection-from-alias.js +1 -0
- package/dist/utils/get-default-value.js +1 -1
- package/dist/utils/get-ip-from-req.js +2 -2
- package/dist/utils/get-permissions.js +11 -11
- package/dist/utils/get-schema.js +2 -2
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/sanitize-query.js +26 -26
- package/dist/utils/should-skip-cache.js +2 -2
- package/dist/utils/track.js +16 -16
- package/dist/utils/validate-query.js +1 -1
- package/dist/utils/validate-storage.js +8 -8
- package/dist/webhooks.js +2 -2
- package/package.json +13 -13
- package/dist/utils/redact-header-cookies.d.ts +0 -1
- package/dist/utils/redact-header-cookies.js +0 -11
- /package/dist/{utils/redact-header-cookies.test.d.ts → logger.test.d.ts} +0 -0
|
@@ -55,7 +55,7 @@ const void_1 = require("./types/void");
|
|
|
55
55
|
const add_path_to_validation_error_1 = require("./utils/add-path-to-validation-error");
|
|
56
56
|
const process_error_1 = __importDefault(require("./utils/process-error"));
|
|
57
57
|
const validationRules = Array.from(graphql_1.specifiedRules);
|
|
58
|
-
if (env_1.default
|
|
58
|
+
if (env_1.default['GRAPHQL_INTROSPECTION'] === false) {
|
|
59
59
|
validationRules.push(graphql_1.NoSchemaIntrospectionCustomRule);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -103,12 +103,12 @@ class GraphQLService {
|
|
|
103
103
|
throw new exceptions_1.InvalidPayloadException('GraphQL execution error.', { graphqlErrors: [err.message] });
|
|
104
104
|
}
|
|
105
105
|
const formattedResult = {};
|
|
106
|
-
if (result
|
|
107
|
-
formattedResult.data = result
|
|
108
|
-
if (result
|
|
109
|
-
formattedResult.errors = result
|
|
110
|
-
if (result
|
|
111
|
-
formattedResult.extensions = result
|
|
106
|
+
if (result['data'])
|
|
107
|
+
formattedResult.data = result['data'];
|
|
108
|
+
if (result['errors'])
|
|
109
|
+
formattedResult.errors = result['errors'].map((error) => (0, process_error_1.default)(this.accountability, error));
|
|
110
|
+
if (result['extensions'])
|
|
111
|
+
formattedResult.extensions = result['extensions'];
|
|
112
112
|
return formattedResult;
|
|
113
113
|
}
|
|
114
114
|
getSchema(type = 'schema') {
|
|
@@ -209,8 +209,8 @@ class GraphQLService {
|
|
|
209
209
|
.filter((collection) => READ_ONLY.includes(collection.collection) === false)
|
|
210
210
|
.reduce((acc, collection) => {
|
|
211
211
|
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
212
|
-
acc[`delete_${collectionName}_items`] = DeleteCollectionTypes
|
|
213
|
-
acc[`delete_${collectionName}_item`] = DeleteCollectionTypes
|
|
212
|
+
acc[`delete_${collectionName}_items`] = DeleteCollectionTypes['many'].getResolver(`delete_${collection.collection}_items`);
|
|
213
|
+
acc[`delete_${collectionName}_item`] = DeleteCollectionTypes['one'].getResolver(`delete_${collection.collection}_item`);
|
|
214
214
|
return acc;
|
|
215
215
|
}, {}));
|
|
216
216
|
}
|
|
@@ -386,7 +386,7 @@ class GraphQLService {
|
|
|
386
386
|
currentPath = currentPath.prev;
|
|
387
387
|
}
|
|
388
388
|
path = path.reverse().slice(0, -1);
|
|
389
|
-
let parent = context
|
|
389
|
+
let parent = context['data'];
|
|
390
390
|
for (const pathPart of path) {
|
|
391
391
|
parent = parent[pathPart];
|
|
392
392
|
}
|
|
@@ -809,7 +809,7 @@ class GraphQLService {
|
|
|
809
809
|
: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType()))),
|
|
810
810
|
resolve: async ({ info, context }) => {
|
|
811
811
|
const result = await self.resolveQuery(info);
|
|
812
|
-
context
|
|
812
|
+
context['data'] = result;
|
|
813
813
|
return result;
|
|
814
814
|
},
|
|
815
815
|
};
|
|
@@ -858,7 +858,7 @@ class GraphQLService {
|
|
|
858
858
|
},
|
|
859
859
|
resolve: async ({ info, context }) => {
|
|
860
860
|
const result = await self.resolveQuery(info);
|
|
861
|
-
context
|
|
861
|
+
context['data'] = result;
|
|
862
862
|
return result;
|
|
863
863
|
},
|
|
864
864
|
});
|
|
@@ -871,7 +871,7 @@ class GraphQLService {
|
|
|
871
871
|
},
|
|
872
872
|
resolve: async ({ info, context }) => {
|
|
873
873
|
const result = await self.resolveQuery(info);
|
|
874
|
-
context
|
|
874
|
+
context['data'] = result;
|
|
875
875
|
return result;
|
|
876
876
|
},
|
|
877
877
|
});
|
|
@@ -1047,30 +1047,30 @@ class GraphQLService {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
|
-
DeleteCollectionTypes
|
|
1050
|
+
DeleteCollectionTypes['many'] = schemaComposer.createObjectTC({
|
|
1051
1051
|
name: `delete_many`,
|
|
1052
1052
|
fields: {
|
|
1053
1053
|
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1054
1054
|
},
|
|
1055
1055
|
});
|
|
1056
|
-
DeleteCollectionTypes
|
|
1056
|
+
DeleteCollectionTypes['one'] = schemaComposer.createObjectTC({
|
|
1057
1057
|
name: `delete_one`,
|
|
1058
1058
|
fields: {
|
|
1059
1059
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1060
1060
|
},
|
|
1061
1061
|
});
|
|
1062
1062
|
for (const collection of Object.values(schema.delete.collections)) {
|
|
1063
|
-
DeleteCollectionTypes
|
|
1063
|
+
DeleteCollectionTypes['many'].addResolver({
|
|
1064
1064
|
name: `delete_${collection.collection}_items`,
|
|
1065
|
-
type: DeleteCollectionTypes
|
|
1065
|
+
type: DeleteCollectionTypes['many'],
|
|
1066
1066
|
args: {
|
|
1067
1067
|
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1068
1068
|
},
|
|
1069
1069
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1070
1070
|
});
|
|
1071
|
-
DeleteCollectionTypes
|
|
1071
|
+
DeleteCollectionTypes['one'].addResolver({
|
|
1072
1072
|
name: `delete_${collection.collection}_item`,
|
|
1073
|
-
type: DeleteCollectionTypes
|
|
1073
|
+
type: DeleteCollectionTypes['one'],
|
|
1074
1074
|
args: {
|
|
1075
1075
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1076
1076
|
},
|
|
@@ -1104,13 +1104,13 @@ class GraphQLService {
|
|
|
1104
1104
|
collection = collection.slice(0, -6);
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
|
-
if (args
|
|
1107
|
+
if (args['id']) {
|
|
1108
1108
|
query.filter = {
|
|
1109
1109
|
_and: [
|
|
1110
1110
|
query.filter || {},
|
|
1111
1111
|
{
|
|
1112
1112
|
[this.schema.collections[collection].primary]: {
|
|
1113
|
-
_eq: args
|
|
1113
|
+
_eq: args['id'],
|
|
1114
1114
|
},
|
|
1115
1115
|
},
|
|
1116
1116
|
],
|
|
@@ -1124,14 +1124,14 @@ class GraphQLService {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
1126
|
const result = await this.read(collection, query);
|
|
1127
|
-
if (args
|
|
1127
|
+
if (args['id']) {
|
|
1128
1128
|
return result?.[0] || null;
|
|
1129
1129
|
}
|
|
1130
1130
|
if (query.group) {
|
|
1131
1131
|
// for every entry in result add a group field based on query.group;
|
|
1132
1132
|
const aggregateKeys = Object.keys(query.aggregate ?? {});
|
|
1133
|
-
result
|
|
1134
|
-
field
|
|
1133
|
+
result['map']((field) => {
|
|
1134
|
+
field['group'] = (0, lodash_1.omit)(field, aggregateKeys);
|
|
1135
1135
|
});
|
|
1136
1136
|
}
|
|
1137
1137
|
return result;
|
|
@@ -1156,44 +1156,46 @@ class GraphQLService {
|
|
|
1156
1156
|
if (collection.endsWith('_item'))
|
|
1157
1157
|
collection = collection.slice(0, -5);
|
|
1158
1158
|
if (singleton && action === 'update') {
|
|
1159
|
-
return await this.upsertSingleton(collection, args
|
|
1159
|
+
return await this.upsertSingleton(collection, args['data'], query);
|
|
1160
1160
|
}
|
|
1161
1161
|
const service = this.getService(collection);
|
|
1162
1162
|
const hasQuery = (query.fields || []).length > 0;
|
|
1163
1163
|
try {
|
|
1164
1164
|
if (single) {
|
|
1165
1165
|
if (action === 'create') {
|
|
1166
|
-
const key = await service.createOne(args
|
|
1166
|
+
const key = await service.createOne(args['data']);
|
|
1167
1167
|
return hasQuery ? await service.readOne(key, query) : true;
|
|
1168
1168
|
}
|
|
1169
1169
|
if (action === 'update') {
|
|
1170
|
-
const key = await service.updateOne(args
|
|
1170
|
+
const key = await service.updateOne(args['id'], args['data']);
|
|
1171
1171
|
return hasQuery ? await service.readOne(key, query) : true;
|
|
1172
1172
|
}
|
|
1173
1173
|
if (action === 'delete') {
|
|
1174
|
-
await service.deleteOne(args
|
|
1175
|
-
return { id: args
|
|
1174
|
+
await service.deleteOne(args['id']);
|
|
1175
|
+
return { id: args['id'] };
|
|
1176
1176
|
}
|
|
1177
|
+
return undefined;
|
|
1177
1178
|
}
|
|
1178
1179
|
else {
|
|
1179
1180
|
if (action === 'create') {
|
|
1180
|
-
const keys = await service.createMany(args
|
|
1181
|
+
const keys = await service.createMany(args['data']);
|
|
1181
1182
|
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1182
1183
|
}
|
|
1183
1184
|
if (action === 'update') {
|
|
1184
1185
|
const keys = [];
|
|
1185
1186
|
if (batchUpdate) {
|
|
1186
|
-
keys.push(...(await service.updateBatch(args
|
|
1187
|
+
keys.push(...(await service.updateBatch(args['data'])));
|
|
1187
1188
|
}
|
|
1188
1189
|
else {
|
|
1189
|
-
keys.push(...(await service.updateMany(args
|
|
1190
|
+
keys.push(...(await service.updateMany(args['ids'], args['data'])));
|
|
1190
1191
|
}
|
|
1191
1192
|
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1192
1193
|
}
|
|
1193
1194
|
if (action === 'delete') {
|
|
1194
|
-
const keys = await service.deleteMany(args
|
|
1195
|
+
const keys = await service.deleteMany(args['ids']);
|
|
1195
1196
|
return { ids: keys };
|
|
1196
1197
|
}
|
|
1198
|
+
return undefined;
|
|
1197
1199
|
}
|
|
1198
1200
|
}
|
|
1199
1201
|
catch (err) {
|
|
@@ -1235,7 +1237,7 @@ class GraphQLService {
|
|
|
1235
1237
|
* of arguments
|
|
1236
1238
|
*/
|
|
1237
1239
|
parseArgs(args, variableValues) {
|
|
1238
|
-
if (!args || args
|
|
1240
|
+
if (!args || args['length'] === 0)
|
|
1239
1241
|
return {};
|
|
1240
1242
|
const parse = (node) => {
|
|
1241
1243
|
switch (node.kind) {
|
|
@@ -1259,7 +1261,7 @@ class GraphQLService {
|
|
|
1259
1261
|
return 'value' in node ? node.value : null;
|
|
1260
1262
|
}
|
|
1261
1263
|
};
|
|
1262
|
-
const argsObject = Object.fromEntries(args
|
|
1264
|
+
const argsObject = Object.fromEntries(args['map']((arg) => [arg.name.value, parse(arg.value)]));
|
|
1263
1265
|
return argsObject;
|
|
1264
1266
|
}
|
|
1265
1267
|
/**
|
|
@@ -1408,10 +1410,10 @@ class GraphQLService {
|
|
|
1408
1410
|
*/
|
|
1409
1411
|
formatError(error) {
|
|
1410
1412
|
if (Array.isArray(error)) {
|
|
1411
|
-
error[0].extensions
|
|
1413
|
+
error[0].extensions['code'] = error[0].code;
|
|
1412
1414
|
return new graphql_1.GraphQLError(error[0].message, undefined, undefined, undefined, undefined, error[0]);
|
|
1413
1415
|
}
|
|
1414
|
-
error.extensions
|
|
1416
|
+
error.extensions['code'] = error.code;
|
|
1415
1417
|
return new graphql_1.GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
|
|
1416
1418
|
}
|
|
1417
1419
|
/**
|
|
@@ -1482,7 +1484,7 @@ class GraphQLService {
|
|
|
1482
1484
|
name: 'auth_tokens',
|
|
1483
1485
|
fields: {
|
|
1484
1486
|
access_token: graphql_1.GraphQLString,
|
|
1485
|
-
expires:
|
|
1487
|
+
expires: bigint_1.GraphQLBigInt,
|
|
1486
1488
|
refresh_token: graphql_1.GraphQLString,
|
|
1487
1489
|
},
|
|
1488
1490
|
});
|
|
@@ -1595,7 +1597,7 @@ class GraphQLService {
|
|
|
1595
1597
|
const service = new GraphQLService({
|
|
1596
1598
|
schema: this.schema,
|
|
1597
1599
|
accountability: this.accountability,
|
|
1598
|
-
scope: args
|
|
1600
|
+
scope: args['scope'] ?? 'items',
|
|
1599
1601
|
});
|
|
1600
1602
|
return service.getSchema('sdl');
|
|
1601
1603
|
},
|
|
@@ -1661,19 +1663,19 @@ class GraphQLService {
|
|
|
1661
1663
|
schema: this.schema,
|
|
1662
1664
|
});
|
|
1663
1665
|
const result = await authenticationService.login(constants_2.DEFAULT_AUTH_PROVIDER, args, args?.otp);
|
|
1664
|
-
if (args
|
|
1665
|
-
res?.cookie(env_1.default
|
|
1666
|
+
if (args['mode'] === 'cookie') {
|
|
1667
|
+
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1666
1668
|
httpOnly: true,
|
|
1667
|
-
domain: env_1.default
|
|
1668
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
1669
|
-
secure: env_1.default
|
|
1670
|
-
sameSite: env_1.default
|
|
1669
|
+
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1670
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1671
|
+
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1672
|
+
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1671
1673
|
});
|
|
1672
1674
|
}
|
|
1673
1675
|
return {
|
|
1674
|
-
access_token: result
|
|
1675
|
-
expires: result
|
|
1676
|
-
refresh_token: result
|
|
1676
|
+
access_token: result['accessToken'],
|
|
1677
|
+
expires: result['expires'],
|
|
1678
|
+
refresh_token: result['refreshToken'],
|
|
1677
1679
|
};
|
|
1678
1680
|
},
|
|
1679
1681
|
},
|
|
@@ -1697,24 +1699,24 @@ class GraphQLService {
|
|
|
1697
1699
|
accountability: accountability,
|
|
1698
1700
|
schema: this.schema,
|
|
1699
1701
|
});
|
|
1700
|
-
const currentRefreshToken = args
|
|
1702
|
+
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1701
1703
|
if (!currentRefreshToken) {
|
|
1702
1704
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1703
1705
|
}
|
|
1704
1706
|
const result = await authenticationService.refresh(currentRefreshToken);
|
|
1705
|
-
if (args
|
|
1706
|
-
res?.cookie(env_1.default
|
|
1707
|
+
if (args['mode'] === 'cookie') {
|
|
1708
|
+
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1707
1709
|
httpOnly: true,
|
|
1708
|
-
domain: env_1.default
|
|
1709
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
1710
|
-
secure: env_1.default
|
|
1711
|
-
sameSite: env_1.default
|
|
1710
|
+
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1711
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1712
|
+
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1713
|
+
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1712
1714
|
});
|
|
1713
1715
|
}
|
|
1714
1716
|
return {
|
|
1715
|
-
access_token: result
|
|
1716
|
-
expires: result
|
|
1717
|
-
refresh_token: result
|
|
1717
|
+
access_token: result['accessToken'],
|
|
1718
|
+
expires: result['expires'],
|
|
1719
|
+
refresh_token: result['refreshToken'],
|
|
1718
1720
|
};
|
|
1719
1721
|
},
|
|
1720
1722
|
},
|
|
@@ -1737,7 +1739,7 @@ class GraphQLService {
|
|
|
1737
1739
|
accountability: accountability,
|
|
1738
1740
|
schema: this.schema,
|
|
1739
1741
|
});
|
|
1740
|
-
const currentRefreshToken = args
|
|
1742
|
+
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1741
1743
|
if (!currentRefreshToken) {
|
|
1742
1744
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1743
1745
|
}
|
|
@@ -1763,7 +1765,7 @@ class GraphQLService {
|
|
|
1763
1765
|
accountability.origin = origin;
|
|
1764
1766
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1765
1767
|
try {
|
|
1766
|
-
await service.requestPasswordReset(args
|
|
1768
|
+
await service.requestPasswordReset(args['email'], args['reset_url'] || null);
|
|
1767
1769
|
}
|
|
1768
1770
|
catch (err) {
|
|
1769
1771
|
if (err instanceof exceptions_1.InvalidPayloadException) {
|
|
@@ -1790,7 +1792,7 @@ class GraphQLService {
|
|
|
1790
1792
|
if (origin)
|
|
1791
1793
|
accountability.origin = origin;
|
|
1792
1794
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1793
|
-
await service.resetPassword(args
|
|
1795
|
+
await service.resetPassword(args['token'], args['password']);
|
|
1794
1796
|
return true;
|
|
1795
1797
|
},
|
|
1796
1798
|
},
|
|
@@ -1816,7 +1818,7 @@ class GraphQLService {
|
|
|
1816
1818
|
accountability: this.accountability,
|
|
1817
1819
|
schema: this.schema,
|
|
1818
1820
|
});
|
|
1819
|
-
await authService.verifyPassword(this.accountability.user, args
|
|
1821
|
+
await authService.verifyPassword(this.accountability.user, args['password']);
|
|
1820
1822
|
const { url, secret } = await service.generateTFA(this.accountability.user);
|
|
1821
1823
|
return { secret, otpauth_url: url };
|
|
1822
1824
|
},
|
|
@@ -1834,7 +1836,7 @@ class GraphQLService {
|
|
|
1834
1836
|
accountability: this.accountability,
|
|
1835
1837
|
schema: this.schema,
|
|
1836
1838
|
});
|
|
1837
|
-
await service.enableTFA(this.accountability.user, args
|
|
1839
|
+
await service.enableTFA(this.accountability.user, args['otp'], args['secret']);
|
|
1838
1840
|
return true;
|
|
1839
1841
|
},
|
|
1840
1842
|
},
|
|
@@ -1850,7 +1852,7 @@ class GraphQLService {
|
|
|
1850
1852
|
accountability: this.accountability,
|
|
1851
1853
|
schema: this.schema,
|
|
1852
1854
|
});
|
|
1853
|
-
const otpValid = await service.verifyOTP(this.accountability.user, args
|
|
1855
|
+
const otpValid = await service.verifyOTP(this.accountability.user, args['otp']);
|
|
1854
1856
|
if (otpValid === false) {
|
|
1855
1857
|
throw new exceptions_1.InvalidPayloadException(`"otp" is invalid`);
|
|
1856
1858
|
}
|
|
@@ -1864,7 +1866,7 @@ class GraphQLService {
|
|
|
1864
1866
|
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1865
1867
|
},
|
|
1866
1868
|
resolve: async (_, args) => {
|
|
1867
|
-
return await (0, generate_hash_1.generateHash)(args
|
|
1869
|
+
return await (0, generate_hash_1.generateHash)(args['string']);
|
|
1868
1870
|
},
|
|
1869
1871
|
},
|
|
1870
1872
|
utils_hash_verify: {
|
|
@@ -1874,7 +1876,7 @@ class GraphQLService {
|
|
|
1874
1876
|
hash: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1875
1877
|
},
|
|
1876
1878
|
resolve: async (_, args) => {
|
|
1877
|
-
return await argon2_1.default.verify(args
|
|
1879
|
+
return await argon2_1.default.verify(args['hash'], args['string']);
|
|
1878
1880
|
},
|
|
1879
1881
|
},
|
|
1880
1882
|
utils_sort: {
|
|
@@ -1890,7 +1892,7 @@ class GraphQLService {
|
|
|
1890
1892
|
schema: this.schema,
|
|
1891
1893
|
});
|
|
1892
1894
|
const { item, to } = args;
|
|
1893
|
-
await service.sort(args
|
|
1895
|
+
await service.sort(args['collection'], { item, to });
|
|
1894
1896
|
return true;
|
|
1895
1897
|
},
|
|
1896
1898
|
},
|
|
@@ -1904,7 +1906,7 @@ class GraphQLService {
|
|
|
1904
1906
|
accountability: this.accountability,
|
|
1905
1907
|
schema: this.schema,
|
|
1906
1908
|
});
|
|
1907
|
-
await service.revert(args
|
|
1909
|
+
await service.revert(args['revision']);
|
|
1908
1910
|
return true;
|
|
1909
1911
|
},
|
|
1910
1912
|
},
|
|
@@ -1931,7 +1933,7 @@ class GraphQLService {
|
|
|
1931
1933
|
accountability: this.accountability,
|
|
1932
1934
|
schema: this.schema,
|
|
1933
1935
|
});
|
|
1934
|
-
await service.acceptInvite(args
|
|
1936
|
+
await service.acceptInvite(args['token'], args['password']);
|
|
1935
1937
|
return true;
|
|
1936
1938
|
},
|
|
1937
1939
|
},
|
|
@@ -1980,7 +1982,7 @@ class GraphQLService {
|
|
|
1980
1982
|
accountability: this.accountability,
|
|
1981
1983
|
schema: this.schema,
|
|
1982
1984
|
});
|
|
1983
|
-
return await collectionsService.readOne(args
|
|
1985
|
+
return await collectionsService.readOne(args['name']);
|
|
1984
1986
|
},
|
|
1985
1987
|
},
|
|
1986
1988
|
});
|
|
@@ -2043,7 +2045,7 @@ class GraphQLService {
|
|
|
2043
2045
|
accountability: this.accountability,
|
|
2044
2046
|
schema: this.schema,
|
|
2045
2047
|
});
|
|
2046
|
-
return await service.readAll(args
|
|
2048
|
+
return await service.readAll(args['collection']);
|
|
2047
2049
|
},
|
|
2048
2050
|
},
|
|
2049
2051
|
fields_by_name: {
|
|
@@ -2057,7 +2059,7 @@ class GraphQLService {
|
|
|
2057
2059
|
accountability: this.accountability,
|
|
2058
2060
|
schema: this.schema,
|
|
2059
2061
|
});
|
|
2060
|
-
return await service.readOne(args
|
|
2062
|
+
return await service.readOne(args['collection'], args['field']);
|
|
2061
2063
|
},
|
|
2062
2064
|
},
|
|
2063
2065
|
});
|
|
@@ -2111,7 +2113,7 @@ class GraphQLService {
|
|
|
2111
2113
|
accountability: this.accountability,
|
|
2112
2114
|
schema: this.schema,
|
|
2113
2115
|
});
|
|
2114
|
-
return await service.readAll(args
|
|
2116
|
+
return await service.readAll(args['collection']);
|
|
2115
2117
|
},
|
|
2116
2118
|
},
|
|
2117
2119
|
relations_by_name: {
|
|
@@ -2125,7 +2127,7 @@ class GraphQLService {
|
|
|
2125
2127
|
accountability: this.accountability,
|
|
2126
2128
|
schema: this.schema,
|
|
2127
2129
|
});
|
|
2128
|
-
return await service.readOne(args
|
|
2130
|
+
return await service.readOne(args['collection'], args['field']);
|
|
2129
2131
|
},
|
|
2130
2132
|
},
|
|
2131
2133
|
});
|
|
@@ -2148,7 +2150,7 @@ class GraphQLService {
|
|
|
2148
2150
|
accountability: this.accountability,
|
|
2149
2151
|
schema: this.schema,
|
|
2150
2152
|
});
|
|
2151
|
-
const collectionKey = await collectionsService.createOne(args
|
|
2153
|
+
const collectionKey = await collectionsService.createOne(args['data']);
|
|
2152
2154
|
return await collectionsService.readOne(collectionKey);
|
|
2153
2155
|
},
|
|
2154
2156
|
},
|
|
@@ -2165,7 +2167,7 @@ class GraphQLService {
|
|
|
2165
2167
|
accountability: this.accountability,
|
|
2166
2168
|
schema: this.schema,
|
|
2167
2169
|
});
|
|
2168
|
-
const collectionKey = await collectionsService.updateOne(args
|
|
2170
|
+
const collectionKey = await collectionsService.updateOne(args['collection'], args['data']);
|
|
2169
2171
|
return await collectionsService.readOne(collectionKey);
|
|
2170
2172
|
},
|
|
2171
2173
|
},
|
|
@@ -2184,8 +2186,8 @@ class GraphQLService {
|
|
|
2184
2186
|
accountability: this.accountability,
|
|
2185
2187
|
schema: this.schema,
|
|
2186
2188
|
});
|
|
2187
|
-
await collectionsService.deleteOne(args
|
|
2188
|
-
return { collection: args
|
|
2189
|
+
await collectionsService.deleteOne(args['collection']);
|
|
2190
|
+
return { collection: args['collection'] };
|
|
2189
2191
|
},
|
|
2190
2192
|
},
|
|
2191
2193
|
});
|
|
@@ -2201,8 +2203,8 @@ class GraphQLService {
|
|
|
2201
2203
|
accountability: this.accountability,
|
|
2202
2204
|
schema: this.schema,
|
|
2203
2205
|
});
|
|
2204
|
-
await service.createField(args
|
|
2205
|
-
return await service.readOne(args
|
|
2206
|
+
await service.createField(args['collection'], args['data']);
|
|
2207
|
+
return await service.readOne(args['collection'], args['data'].field);
|
|
2206
2208
|
},
|
|
2207
2209
|
},
|
|
2208
2210
|
update_fields_item: {
|
|
@@ -2217,11 +2219,11 @@ class GraphQLService {
|
|
|
2217
2219
|
accountability: this.accountability,
|
|
2218
2220
|
schema: this.schema,
|
|
2219
2221
|
});
|
|
2220
|
-
await service.updateField(args
|
|
2221
|
-
...args
|
|
2222
|
-
field: args
|
|
2222
|
+
await service.updateField(args['collection'], {
|
|
2223
|
+
...args['data'],
|
|
2224
|
+
field: args['field'],
|
|
2223
2225
|
});
|
|
2224
|
-
return await service.readOne(args
|
|
2226
|
+
return await service.readOne(args['collection'], args['data'].field);
|
|
2225
2227
|
},
|
|
2226
2228
|
},
|
|
2227
2229
|
delete_fields_item: {
|
|
@@ -2241,7 +2243,7 @@ class GraphQLService {
|
|
|
2241
2243
|
accountability: this.accountability,
|
|
2242
2244
|
schema: this.schema,
|
|
2243
2245
|
});
|
|
2244
|
-
await service.deleteField(args
|
|
2246
|
+
await service.deleteField(args['collection'], args['field']);
|
|
2245
2247
|
const { collection, field } = args;
|
|
2246
2248
|
return { collection, field };
|
|
2247
2249
|
},
|
|
@@ -2258,8 +2260,8 @@ class GraphQLService {
|
|
|
2258
2260
|
accountability: this.accountability,
|
|
2259
2261
|
schema: this.schema,
|
|
2260
2262
|
});
|
|
2261
|
-
await relationsService.createOne(args
|
|
2262
|
-
return await relationsService.readOne(args
|
|
2263
|
+
await relationsService.createOne(args['data']);
|
|
2264
|
+
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2263
2265
|
},
|
|
2264
2266
|
},
|
|
2265
2267
|
update_relations_item: {
|
|
@@ -2274,8 +2276,8 @@ class GraphQLService {
|
|
|
2274
2276
|
accountability: this.accountability,
|
|
2275
2277
|
schema: this.schema,
|
|
2276
2278
|
});
|
|
2277
|
-
await relationsService.updateOne(args
|
|
2278
|
-
return await relationsService.readOne(args
|
|
2279
|
+
await relationsService.updateOne(args['collection'], args['field'], args['data']);
|
|
2280
|
+
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2279
2281
|
},
|
|
2280
2282
|
},
|
|
2281
2283
|
delete_relations_item: {
|
|
@@ -2295,8 +2297,8 @@ class GraphQLService {
|
|
|
2295
2297
|
accountability: this.accountability,
|
|
2296
2298
|
schema: this.schema,
|
|
2297
2299
|
});
|
|
2298
|
-
await relationsService.deleteOne(args
|
|
2299
|
-
return { collection: args
|
|
2300
|
+
await relationsService.deleteOne(args['collection'], args['field']);
|
|
2301
|
+
return { collection: args['collection'], field: args['field'] };
|
|
2300
2302
|
},
|
|
2301
2303
|
},
|
|
2302
2304
|
});
|
|
@@ -2330,7 +2332,7 @@ class GraphQLService {
|
|
|
2330
2332
|
schema: this.schema,
|
|
2331
2333
|
accountability: this.accountability,
|
|
2332
2334
|
});
|
|
2333
|
-
await service.updateOne(this.accountability.user, args
|
|
2335
|
+
await service.updateOne(this.accountability.user, args['data']);
|
|
2334
2336
|
if ('directus_users' in ReadCollectionTypes) {
|
|
2335
2337
|
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2336
2338
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
@@ -2386,7 +2388,7 @@ class GraphQLService {
|
|
|
2386
2388
|
accountability: this.accountability,
|
|
2387
2389
|
schema: this.schema,
|
|
2388
2390
|
});
|
|
2389
|
-
const primaryKey = await service.updateOne(args
|
|
2391
|
+
const primaryKey = await service.updateOne(args['id'], { comment: args['comment'] });
|
|
2390
2392
|
if ('directus_activity' in ReadCollectionTypes) {
|
|
2391
2393
|
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2392
2394
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
@@ -2400,7 +2402,7 @@ class GraphQLService {
|
|
|
2400
2402
|
if ('directus_activity' in schema.delete.collections) {
|
|
2401
2403
|
schemaComposer.Mutation.addFields({
|
|
2402
2404
|
delete_comment: {
|
|
2403
|
-
type: DeleteCollectionTypes
|
|
2405
|
+
type: DeleteCollectionTypes['one'],
|
|
2404
2406
|
args: {
|
|
2405
2407
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2406
2408
|
},
|
|
@@ -2409,8 +2411,8 @@ class GraphQLService {
|
|
|
2409
2411
|
accountability: this.accountability,
|
|
2410
2412
|
schema: this.schema,
|
|
2411
2413
|
});
|
|
2412
|
-
await service.deleteOne(args
|
|
2413
|
-
return { id: args
|
|
2414
|
+
await service.deleteOne(args['id']);
|
|
2415
|
+
return { id: args['id'] };
|
|
2414
2416
|
},
|
|
2415
2417
|
},
|
|
2416
2418
|
});
|
|
@@ -2428,7 +2430,7 @@ class GraphQLService {
|
|
|
2428
2430
|
accountability: this.accountability,
|
|
2429
2431
|
schema: this.schema,
|
|
2430
2432
|
});
|
|
2431
|
-
const primaryKey = await service.importOne(args
|
|
2433
|
+
const primaryKey = await service.importOne(args['url'], args['data']);
|
|
2432
2434
|
if ('directus_files' in ReadCollectionTypes) {
|
|
2433
2435
|
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2434
2436
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
@@ -2453,7 +2455,7 @@ class GraphQLService {
|
|
|
2453
2455
|
accountability: this.accountability,
|
|
2454
2456
|
schema: this.schema,
|
|
2455
2457
|
});
|
|
2456
|
-
await service.inviteUser(args
|
|
2458
|
+
await service.inviteUser(args['email'], args['role'], args['invite_url'] || null);
|
|
2457
2459
|
return true;
|
|
2458
2460
|
},
|
|
2459
2461
|
},
|
|
@@ -182,20 +182,20 @@ class ExportService {
|
|
|
182
182
|
count: ['*'],
|
|
183
183
|
},
|
|
184
184
|
})
|
|
185
|
-
.then((result) => Number(result?.[0]?.count ?? 0));
|
|
185
|
+
.then((result) => Number(result?.[0]?.['count'] ?? 0));
|
|
186
186
|
const count = query.limit ? Math.min(totalCount, query.limit) : totalCount;
|
|
187
187
|
const requestedLimit = query.limit ?? -1;
|
|
188
|
-
const batchesRequired = Math.ceil(count / env_1.default
|
|
188
|
+
const batchesRequired = Math.ceil(count / env_1.default['EXPORT_BATCH_SIZE']);
|
|
189
189
|
let readCount = 0;
|
|
190
190
|
for (let batch = 0; batch < batchesRequired; batch++) {
|
|
191
|
-
let limit = env_1.default
|
|
192
|
-
if (requestedLimit > 0 && env_1.default
|
|
191
|
+
let limit = env_1.default['EXPORT_BATCH_SIZE'];
|
|
192
|
+
if (requestedLimit > 0 && env_1.default['EXPORT_BATCH_SIZE'] > requestedLimit - readCount) {
|
|
193
193
|
limit = requestedLimit - readCount;
|
|
194
194
|
}
|
|
195
195
|
const result = await service.readByQuery({
|
|
196
196
|
...query,
|
|
197
197
|
limit,
|
|
198
|
-
offset: batch * env_1.default
|
|
198
|
+
offset: batch * env_1.default['EXPORT_BATCH_SIZE'],
|
|
199
199
|
});
|
|
200
200
|
readCount += result.length;
|
|
201
201
|
if (result.length) {
|
|
@@ -210,7 +210,7 @@ class ExportService {
|
|
|
210
210
|
accountability: this.accountability,
|
|
211
211
|
schema: this.schema,
|
|
212
212
|
});
|
|
213
|
-
const storage = (0, utils_1.toArray)(env_1.default
|
|
213
|
+
const storage = (0, utils_1.toArray)(env_1.default['STORAGE_LOCATIONS'])[0];
|
|
214
214
|
const title = `export-${collection}-${(0, get_date_formatted_1.getDateFormatted)()}`;
|
|
215
215
|
const filename = `${title}.${format}`;
|
|
216
216
|
const fileWithDefaults = {
|