directus 9.18.0 → 9.19.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/cli/commands/roles/create.js +1 -1
- package/dist/cli/utils/create-env/env-stub.liquid +3 -2
- package/dist/controllers/collections.js +18 -0
- package/dist/database/run-ast.js +11 -4
- package/dist/database/system-data/fields/activity.yaml +2 -1
- package/dist/database/system-data/fields/collections.yaml +8 -4
- package/dist/database/system-data/fields/dashboards.yaml +6 -3
- package/dist/database/system-data/fields/fields.yaml +18 -9
- package/dist/database/system-data/fields/files.yaml +14 -7
- package/dist/database/system-data/fields/flows.yaml +10 -5
- package/dist/database/system-data/fields/folders.yaml +2 -1
- package/dist/database/system-data/fields/operations.yaml +8 -4
- package/dist/database/system-data/fields/panels.yaml +8 -4
- package/dist/database/system-data/fields/permissions.yaml +8 -4
- package/dist/database/system-data/fields/presets.yaml +10 -5
- package/dist/database/system-data/fields/relations.yaml +2 -1
- package/dist/database/system-data/fields/revisions.yaml +4 -2
- package/dist/database/system-data/fields/roles.yaml +12 -6
- package/dist/database/system-data/fields/settings.yaml +10 -5
- package/dist/database/system-data/fields/shares.yaml +7 -3
- package/dist/database/system-data/fields/users.yaml +15 -7
- package/dist/database/system-data/fields/webhooks.yaml +8 -4
- package/dist/env.js +4 -2
- package/dist/env.test.js +1 -0
- package/dist/logger.d.ts +2 -2
- package/dist/logger.js +10 -3
- package/dist/messenger.d.ts +3 -3
- package/dist/services/collections.d.ts +4 -0
- package/dist/services/collections.js +50 -5
- package/dist/services/graphql/index.js +92 -69
- package/dist/services/graphql/types/date.d.ts +1 -1
- package/dist/services/graphql/types/geojson.d.ts +1 -1
- package/dist/services/graphql/types/hash.d.ts +1 -1
- package/dist/services/graphql/types/string-or-float.d.ts +1 -1
- package/dist/services/graphql/types/void.d.ts +1 -1
- package/dist/services/items.js +3 -1
- package/dist/services/mail/templates/base.liquid +0 -1
- package/dist/services/payload.js +2 -2
- package/dist/services/payload.test.js +102 -0
- package/dist/types/items.d.ts +4 -0
- package/dist/utils/apply-query.js +10 -2
- package/dist/utils/get-ast-from-query.js +1 -1
- package/dist/utils/get-auth-providers.d.ts +1 -0
- package/dist/utils/get-auth-providers.js +1 -0
- package/dist/utils/get-auth-providers.test.d.ts +1 -0
- package/dist/utils/get-auth-providers.test.js +72 -0
- package/dist/utils/get-relation-info.js +10 -4
- package/package.json +121 -122
|
@@ -279,12 +279,18 @@ class GraphQLService {
|
|
|
279
279
|
// can't non-null in update, as that would require every not-nullable field to be
|
|
280
280
|
// submitted on updates
|
|
281
281
|
if (field.nullable === false &&
|
|
282
|
+
!field.defaultValue &&
|
|
282
283
|
!constants_1.GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
|
|
283
284
|
action !== 'update') {
|
|
284
|
-
type =
|
|
285
|
+
type = new graphql_1.GraphQLNonNull(type);
|
|
285
286
|
}
|
|
286
287
|
if (collection.primary === field.field) {
|
|
287
|
-
|
|
288
|
+
if (!field.defaultValue && !field.special.includes('uuid') && action === 'create')
|
|
289
|
+
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
290
|
+
else if (['create', 'update'].includes(action))
|
|
291
|
+
type = graphql_1.GraphQLID;
|
|
292
|
+
else
|
|
293
|
+
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
288
294
|
}
|
|
289
295
|
acc[field.field] = {
|
|
290
296
|
type,
|
|
@@ -380,7 +386,7 @@ class GraphQLService {
|
|
|
380
386
|
parent = parent[pathPart];
|
|
381
387
|
}
|
|
382
388
|
const collection = parent[relation.meta.one_collection_field];
|
|
383
|
-
return CollectionTypes[collection].getType();
|
|
389
|
+
return CollectionTypes[collection].getType().name;
|
|
384
390
|
},
|
|
385
391
|
}),
|
|
386
392
|
resolve: (obj, _, __, info) => {
|
|
@@ -397,7 +403,7 @@ class GraphQLService {
|
|
|
397
403
|
* Create readable types and attach resolvers for each. Also prepares full filter argument structures
|
|
398
404
|
*/
|
|
399
405
|
function getReadableTypes() {
|
|
400
|
-
var _a, _b, _c, _d, _e, _f;
|
|
406
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
401
407
|
const { CollectionTypes: ReadCollectionTypes } = getTypes('read');
|
|
402
408
|
const ReadableCollectionFilterTypes = {};
|
|
403
409
|
const AggregatedFunctions = {};
|
|
@@ -415,6 +421,9 @@ class GraphQLService {
|
|
|
415
421
|
_contains: {
|
|
416
422
|
type: graphql_1.GraphQLString,
|
|
417
423
|
},
|
|
424
|
+
_icontains: {
|
|
425
|
+
type: graphql_1.GraphQLString,
|
|
426
|
+
},
|
|
418
427
|
_ncontains: {
|
|
419
428
|
type: graphql_1.GraphQLString,
|
|
420
429
|
},
|
|
@@ -494,6 +503,12 @@ class GraphQLService {
|
|
|
494
503
|
_nnull: {
|
|
495
504
|
type: graphql_1.GraphQLBoolean,
|
|
496
505
|
},
|
|
506
|
+
_in: {
|
|
507
|
+
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
508
|
+
},
|
|
509
|
+
_nin: {
|
|
510
|
+
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
511
|
+
},
|
|
497
512
|
_between: {
|
|
498
513
|
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
499
514
|
},
|
|
@@ -565,6 +580,12 @@ class GraphQLService {
|
|
|
565
580
|
_nintersects_bbox: {
|
|
566
581
|
type: geojson_1.GraphQLGeoJSON,
|
|
567
582
|
},
|
|
583
|
+
_null: {
|
|
584
|
+
type: graphql_1.GraphQLBoolean,
|
|
585
|
+
},
|
|
586
|
+
_nnull: {
|
|
587
|
+
type: graphql_1.GraphQLBoolean,
|
|
588
|
+
},
|
|
568
589
|
},
|
|
569
590
|
});
|
|
570
591
|
const HashFilterOperators = schemaComposer.createInputTC({
|
|
@@ -834,7 +855,7 @@ class GraphQLService {
|
|
|
834
855
|
name: `${collection.collection}_by_id`,
|
|
835
856
|
type: ReadCollectionTypes[collection.collection],
|
|
836
857
|
args: {
|
|
837
|
-
id:
|
|
858
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
838
859
|
},
|
|
839
860
|
resolve: async ({ info, context }) => {
|
|
840
861
|
const result = await self.resolveQuery(info);
|
|
@@ -894,10 +915,12 @@ class GraphQLService {
|
|
|
894
915
|
}
|
|
895
916
|
}
|
|
896
917
|
else if ((_f = relation.meta) === null || _f === void 0 ? void 0 : _f.one_allowed_collections) {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
918
|
+
(_g = ReadableCollectionFilterTypes[relation.collection]) === null || _g === void 0 ? void 0 : _g.removeField('item');
|
|
919
|
+
for (const collection of relation.meta.one_allowed_collections) {
|
|
920
|
+
(_h = ReadableCollectionFilterTypes[relation.collection]) === null || _h === void 0 ? void 0 : _h.addFields({
|
|
921
|
+
[`item__${collection}`]: ReadableCollectionFilterTypes[collection],
|
|
922
|
+
});
|
|
923
|
+
}
|
|
901
924
|
}
|
|
902
925
|
}
|
|
903
926
|
return { ReadCollectionTypes, ReadableCollectionFilterTypes };
|
|
@@ -993,7 +1016,7 @@ class GraphQLService {
|
|
|
993
1016
|
...(collectionIsReadable
|
|
994
1017
|
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
995
1018
|
: {}),
|
|
996
|
-
ids:
|
|
1019
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
997
1020
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
998
1021
|
},
|
|
999
1022
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
@@ -1002,7 +1025,7 @@ class GraphQLService {
|
|
|
1002
1025
|
name: `update_${collection.collection}_item`,
|
|
1003
1026
|
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
1004
1027
|
args: {
|
|
1005
|
-
id:
|
|
1028
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1006
1029
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1007
1030
|
},
|
|
1008
1031
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
@@ -1013,13 +1036,13 @@ class GraphQLService {
|
|
|
1013
1036
|
DeleteCollectionTypes.many = schemaComposer.createObjectTC({
|
|
1014
1037
|
name: `delete_many`,
|
|
1015
1038
|
fields: {
|
|
1016
|
-
ids:
|
|
1039
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1017
1040
|
},
|
|
1018
1041
|
});
|
|
1019
1042
|
DeleteCollectionTypes.one = schemaComposer.createObjectTC({
|
|
1020
1043
|
name: `delete_one`,
|
|
1021
1044
|
fields: {
|
|
1022
|
-
id:
|
|
1045
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1023
1046
|
},
|
|
1024
1047
|
});
|
|
1025
1048
|
for (const collection of Object.values(schema.delete.collections)) {
|
|
@@ -1027,7 +1050,7 @@ class GraphQLService {
|
|
|
1027
1050
|
name: `delete_${collection.collection}_items`,
|
|
1028
1051
|
type: DeleteCollectionTypes.many,
|
|
1029
1052
|
args: {
|
|
1030
|
-
ids:
|
|
1053
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1031
1054
|
},
|
|
1032
1055
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1033
1056
|
});
|
|
@@ -1035,7 +1058,7 @@ class GraphQLService {
|
|
|
1035
1058
|
name: `delete_${collection.collection}_item`,
|
|
1036
1059
|
type: DeleteCollectionTypes.one,
|
|
1037
1060
|
args: {
|
|
1038
|
-
id:
|
|
1061
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1039
1062
|
},
|
|
1040
1063
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1041
1064
|
});
|
|
@@ -1228,7 +1251,7 @@ class GraphQLService {
|
|
|
1228
1251
|
return Boolean(node.value);
|
|
1229
1252
|
case 'EnumValue':
|
|
1230
1253
|
default:
|
|
1231
|
-
return node.value;
|
|
1254
|
+
return 'value' in node ? node.value : null;
|
|
1232
1255
|
}
|
|
1233
1256
|
};
|
|
1234
1257
|
const argsObject = Object.fromEntries(args.map((arg) => [arg.name.value, parse(arg.value)]));
|
|
@@ -1607,8 +1630,8 @@ class GraphQLService {
|
|
|
1607
1630
|
auth_login: {
|
|
1608
1631
|
type: AuthTokens,
|
|
1609
1632
|
args: {
|
|
1610
|
-
email:
|
|
1611
|
-
password:
|
|
1633
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1634
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1612
1635
|
mode: AuthMode,
|
|
1613
1636
|
otp: graphql_1.GraphQLString,
|
|
1614
1637
|
},
|
|
@@ -1707,7 +1730,7 @@ class GraphQLService {
|
|
|
1707
1730
|
auth_password_request: {
|
|
1708
1731
|
type: graphql_1.GraphQLBoolean,
|
|
1709
1732
|
args: {
|
|
1710
|
-
email:
|
|
1733
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1711
1734
|
reset_url: graphql_1.GraphQLString,
|
|
1712
1735
|
},
|
|
1713
1736
|
resolve: async (_, args, { req }) => {
|
|
@@ -1732,8 +1755,8 @@ class GraphQLService {
|
|
|
1732
1755
|
auth_password_reset: {
|
|
1733
1756
|
type: graphql_1.GraphQLBoolean,
|
|
1734
1757
|
args: {
|
|
1735
|
-
token:
|
|
1736
|
-
password:
|
|
1758
|
+
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1759
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1737
1760
|
},
|
|
1738
1761
|
resolve: async (_, args, { req }) => {
|
|
1739
1762
|
const accountability = {
|
|
@@ -1756,7 +1779,7 @@ class GraphQLService {
|
|
|
1756
1779
|
},
|
|
1757
1780
|
}),
|
|
1758
1781
|
args: {
|
|
1759
|
-
password:
|
|
1782
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1760
1783
|
},
|
|
1761
1784
|
resolve: async (_, args) => {
|
|
1762
1785
|
var _a;
|
|
@@ -1778,8 +1801,8 @@ class GraphQLService {
|
|
|
1778
1801
|
users_me_tfa_enable: {
|
|
1779
1802
|
type: graphql_1.GraphQLBoolean,
|
|
1780
1803
|
args: {
|
|
1781
|
-
otp:
|
|
1782
|
-
secret:
|
|
1804
|
+
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1805
|
+
secret: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1783
1806
|
},
|
|
1784
1807
|
resolve: async (_, args) => {
|
|
1785
1808
|
var _a;
|
|
@@ -1796,7 +1819,7 @@ class GraphQLService {
|
|
|
1796
1819
|
users_me_tfa_disable: {
|
|
1797
1820
|
type: graphql_1.GraphQLBoolean,
|
|
1798
1821
|
args: {
|
|
1799
|
-
otp:
|
|
1822
|
+
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1800
1823
|
},
|
|
1801
1824
|
resolve: async (_, args) => {
|
|
1802
1825
|
var _a;
|
|
@@ -1817,7 +1840,7 @@ class GraphQLService {
|
|
|
1817
1840
|
utils_hash_generate: {
|
|
1818
1841
|
type: graphql_1.GraphQLString,
|
|
1819
1842
|
args: {
|
|
1820
|
-
string:
|
|
1843
|
+
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1821
1844
|
},
|
|
1822
1845
|
resolve: async (_, args) => {
|
|
1823
1846
|
return await (0, generate_hash_1.generateHash)(args.string);
|
|
@@ -1826,8 +1849,8 @@ class GraphQLService {
|
|
|
1826
1849
|
utils_hash_verify: {
|
|
1827
1850
|
type: graphql_1.GraphQLBoolean,
|
|
1828
1851
|
args: {
|
|
1829
|
-
string:
|
|
1830
|
-
hash:
|
|
1852
|
+
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1853
|
+
hash: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1831
1854
|
},
|
|
1832
1855
|
resolve: async (_, args) => {
|
|
1833
1856
|
return await argon2_1.default.verify(args.hash, args.string);
|
|
@@ -1836,9 +1859,9 @@ class GraphQLService {
|
|
|
1836
1859
|
utils_sort: {
|
|
1837
1860
|
type: graphql_1.GraphQLBoolean,
|
|
1838
1861
|
args: {
|
|
1839
|
-
collection:
|
|
1840
|
-
item:
|
|
1841
|
-
to:
|
|
1862
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1863
|
+
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1864
|
+
to: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1842
1865
|
},
|
|
1843
1866
|
resolve: async (_, args) => {
|
|
1844
1867
|
const service = new utils_1.UtilsService({
|
|
@@ -1853,7 +1876,7 @@ class GraphQLService {
|
|
|
1853
1876
|
utils_revert: {
|
|
1854
1877
|
type: graphql_1.GraphQLBoolean,
|
|
1855
1878
|
args: {
|
|
1856
|
-
revision:
|
|
1879
|
+
revision: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1857
1880
|
},
|
|
1858
1881
|
resolve: async (_, args) => {
|
|
1859
1882
|
const service = new revisions_1.RevisionsService({
|
|
@@ -1880,8 +1903,8 @@ class GraphQLService {
|
|
|
1880
1903
|
users_invite_accept: {
|
|
1881
1904
|
type: graphql_1.GraphQLBoolean,
|
|
1882
1905
|
args: {
|
|
1883
|
-
token:
|
|
1884
|
-
password:
|
|
1906
|
+
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1907
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1885
1908
|
},
|
|
1886
1909
|
resolve: async (_, args) => {
|
|
1887
1910
|
const service = new users_1.UsersService({
|
|
@@ -1902,7 +1925,7 @@ class GraphQLService {
|
|
|
1902
1925
|
acc[field.field] = {
|
|
1903
1926
|
type: field.nullable
|
|
1904
1927
|
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
1905
|
-
:
|
|
1928
|
+
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
1906
1929
|
description: field.note,
|
|
1907
1930
|
};
|
|
1908
1931
|
return acc;
|
|
@@ -1930,7 +1953,7 @@ class GraphQLService {
|
|
|
1930
1953
|
collections_by_name: {
|
|
1931
1954
|
type: Collection,
|
|
1932
1955
|
args: {
|
|
1933
|
-
name:
|
|
1956
|
+
name: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1934
1957
|
},
|
|
1935
1958
|
resolve: async (_, args) => {
|
|
1936
1959
|
const collectionsService = new collections_1.CollectionsService({
|
|
@@ -1953,7 +1976,7 @@ class GraphQLService {
|
|
|
1953
1976
|
acc[field.field] = {
|
|
1954
1977
|
type: field.nullable
|
|
1955
1978
|
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
1956
|
-
:
|
|
1979
|
+
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
1957
1980
|
description: field.note,
|
|
1958
1981
|
};
|
|
1959
1982
|
return acc;
|
|
@@ -1993,7 +2016,7 @@ class GraphQLService {
|
|
|
1993
2016
|
fields_in_collection: {
|
|
1994
2017
|
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Field.getType()))),
|
|
1995
2018
|
args: {
|
|
1996
|
-
collection:
|
|
2019
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1997
2020
|
},
|
|
1998
2021
|
resolve: async (_, args) => {
|
|
1999
2022
|
const service = new fields_1.FieldsService({
|
|
@@ -2006,8 +2029,8 @@ class GraphQLService {
|
|
|
2006
2029
|
fields_by_name: {
|
|
2007
2030
|
type: Field,
|
|
2008
2031
|
args: {
|
|
2009
|
-
collection:
|
|
2010
|
-
field:
|
|
2032
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2033
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2011
2034
|
},
|
|
2012
2035
|
resolve: async (_, args) => {
|
|
2013
2036
|
const service = new fields_1.FieldsService({
|
|
@@ -2027,13 +2050,13 @@ class GraphQLService {
|
|
|
2027
2050
|
schema: schemaComposer.createObjectTC({
|
|
2028
2051
|
name: 'directus_relations_schema',
|
|
2029
2052
|
fields: {
|
|
2030
|
-
table:
|
|
2031
|
-
column:
|
|
2032
|
-
foreign_key_table:
|
|
2033
|
-
foreign_key_column:
|
|
2053
|
+
table: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2054
|
+
column: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2055
|
+
foreign_key_table: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2056
|
+
foreign_key_column: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2034
2057
|
constraint_name: graphql_1.GraphQLString,
|
|
2035
|
-
on_update:
|
|
2036
|
-
on_delete:
|
|
2058
|
+
on_update: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2059
|
+
on_delete: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2037
2060
|
},
|
|
2038
2061
|
}),
|
|
2039
2062
|
meta: schemaComposer.createObjectTC({
|
|
@@ -2061,7 +2084,7 @@ class GraphQLService {
|
|
|
2061
2084
|
relations_in_collection: {
|
|
2062
2085
|
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Relation.getType()))),
|
|
2063
2086
|
args: {
|
|
2064
|
-
collection:
|
|
2087
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2065
2088
|
},
|
|
2066
2089
|
resolve: async (_, args) => {
|
|
2067
2090
|
const service = new relations_1.RelationsService({
|
|
@@ -2074,8 +2097,8 @@ class GraphQLService {
|
|
|
2074
2097
|
relations_by_name: {
|
|
2075
2098
|
type: Relation,
|
|
2076
2099
|
args: {
|
|
2077
|
-
collection:
|
|
2078
|
-
field:
|
|
2100
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2101
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2079
2102
|
},
|
|
2080
2103
|
resolve: async (_, args) => {
|
|
2081
2104
|
const service = new relations_1.RelationsService({
|
|
@@ -2112,7 +2135,7 @@ class GraphQLService {
|
|
|
2112
2135
|
update_collections_item: {
|
|
2113
2136
|
type: Collection,
|
|
2114
2137
|
args: {
|
|
2115
|
-
collection:
|
|
2138
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2116
2139
|
data: (0, graphql_compose_1.toInputObjectType)(Collection.clone('update_directus_collections'), {
|
|
2117
2140
|
postfix: '_input',
|
|
2118
2141
|
}).removeField(['collection', 'schema']).NonNull,
|
|
@@ -2134,7 +2157,7 @@ class GraphQLService {
|
|
|
2134
2157
|
},
|
|
2135
2158
|
}),
|
|
2136
2159
|
args: {
|
|
2137
|
-
collection:
|
|
2160
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2138
2161
|
},
|
|
2139
2162
|
resolve: async (_, args) => {
|
|
2140
2163
|
const collectionsService = new collections_1.CollectionsService({
|
|
@@ -2150,7 +2173,7 @@ class GraphQLService {
|
|
|
2150
2173
|
create_fields_item: {
|
|
2151
2174
|
type: Field,
|
|
2152
2175
|
args: {
|
|
2153
|
-
collection:
|
|
2176
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2154
2177
|
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('create_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2155
2178
|
},
|
|
2156
2179
|
resolve: async (_, args) => {
|
|
@@ -2165,8 +2188,8 @@ class GraphQLService {
|
|
|
2165
2188
|
update_fields_item: {
|
|
2166
2189
|
type: Field,
|
|
2167
2190
|
args: {
|
|
2168
|
-
collection:
|
|
2169
|
-
field:
|
|
2191
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2192
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2170
2193
|
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('update_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2171
2194
|
},
|
|
2172
2195
|
resolve: async (_, args) => {
|
|
@@ -2190,8 +2213,8 @@ class GraphQLService {
|
|
|
2190
2213
|
},
|
|
2191
2214
|
}),
|
|
2192
2215
|
args: {
|
|
2193
|
-
collection:
|
|
2194
|
-
field:
|
|
2216
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2217
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2195
2218
|
},
|
|
2196
2219
|
resolve: async (_, args) => {
|
|
2197
2220
|
const service = new fields_1.FieldsService({
|
|
@@ -2222,8 +2245,8 @@ class GraphQLService {
|
|
|
2222
2245
|
update_relations_item: {
|
|
2223
2246
|
type: Relation,
|
|
2224
2247
|
args: {
|
|
2225
|
-
collection:
|
|
2226
|
-
field:
|
|
2248
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2249
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2227
2250
|
data: (0, graphql_compose_1.toInputObjectType)(Relation.clone('update_directus_relations'), { postfix: '_input' }).NonNull,
|
|
2228
2251
|
},
|
|
2229
2252
|
resolve: async (_, args) => {
|
|
@@ -2244,8 +2267,8 @@ class GraphQLService {
|
|
|
2244
2267
|
},
|
|
2245
2268
|
}),
|
|
2246
2269
|
args: {
|
|
2247
|
-
collection:
|
|
2248
|
-
field:
|
|
2270
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2271
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2249
2272
|
},
|
|
2250
2273
|
resolve: async (_, args) => {
|
|
2251
2274
|
const relationsService = new relations_1.RelationsService({
|
|
@@ -2305,9 +2328,9 @@ class GraphQLService {
|
|
|
2305
2328
|
create_comment: {
|
|
2306
2329
|
type: (_d = ReadCollectionTypes['directus_activity']) !== null && _d !== void 0 ? _d : graphql_1.GraphQLBoolean,
|
|
2307
2330
|
args: {
|
|
2308
|
-
collection:
|
|
2309
|
-
item:
|
|
2310
|
-
comment:
|
|
2331
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2332
|
+
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2333
|
+
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2311
2334
|
},
|
|
2312
2335
|
resolve: async (_, args, __, info) => {
|
|
2313
2336
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -2338,8 +2361,8 @@ class GraphQLService {
|
|
|
2338
2361
|
update_comment: {
|
|
2339
2362
|
type: (_e = ReadCollectionTypes['directus_activity']) !== null && _e !== void 0 ? _e : graphql_1.GraphQLBoolean,
|
|
2340
2363
|
args: {
|
|
2341
|
-
id:
|
|
2342
|
-
comment:
|
|
2364
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2365
|
+
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2343
2366
|
},
|
|
2344
2367
|
resolve: async (_, args, __, info) => {
|
|
2345
2368
|
var _a, _b;
|
|
@@ -2363,7 +2386,7 @@ class GraphQLService {
|
|
|
2363
2386
|
delete_comment: {
|
|
2364
2387
|
type: DeleteCollectionTypes.one,
|
|
2365
2388
|
args: {
|
|
2366
|
-
id:
|
|
2389
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2367
2390
|
},
|
|
2368
2391
|
resolve: async (_, args) => {
|
|
2369
2392
|
const service = new activity_1.ActivityService({
|
|
@@ -2381,7 +2404,7 @@ class GraphQLService {
|
|
|
2381
2404
|
import_file: {
|
|
2382
2405
|
type: (_f = ReadCollectionTypes['directus_files']) !== null && _f !== void 0 ? _f : graphql_1.GraphQLBoolean,
|
|
2383
2406
|
args: {
|
|
2384
|
-
url:
|
|
2407
|
+
url: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2385
2408
|
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes['directus_files']).setTypeName('create_directus_files_input'),
|
|
2386
2409
|
},
|
|
2387
2410
|
resolve: async (_, args, __, info) => {
|
|
@@ -2406,8 +2429,8 @@ class GraphQLService {
|
|
|
2406
2429
|
users_invite: {
|
|
2407
2430
|
type: graphql_1.GraphQLBoolean,
|
|
2408
2431
|
args: {
|
|
2409
|
-
email:
|
|
2410
|
-
role:
|
|
2432
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2433
|
+
role: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2411
2434
|
invite_url: graphql_1.GraphQLString,
|
|
2412
2435
|
},
|
|
2413
2436
|
resolve: async (_, args) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
export declare const GraphQLDate: GraphQLScalarType
|
|
2
|
+
export declare const GraphQLDate: GraphQLScalarType<string, string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
export declare const GraphQLGeoJSON: GraphQLScalarType
|
|
2
|
+
export declare const GraphQLGeoJSON: GraphQLScalarType<unknown, unknown>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
export declare const GraphQLHash: GraphQLScalarType
|
|
2
|
+
export declare const GraphQLHash: GraphQLScalarType<string, string>;
|
|
@@ -2,4 +2,4 @@ import { GraphQLScalarType } from 'graphql';
|
|
|
2
2
|
/**
|
|
3
3
|
* Adopted from https://kamranicus.com/handling-multiple-scalar-types-in-graphql/
|
|
4
4
|
*/
|
|
5
|
-
export declare const GraphQLStringOrFloat: GraphQLScalarType
|
|
5
|
+
export declare const GraphQLStringOrFloat: GraphQLScalarType<string | number, string | number>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
export declare const GraphQLVoid: GraphQLScalarType
|
|
2
|
+
export declare const GraphQLVoid: GraphQLScalarType<null, null>;
|
package/dist/services/items.js
CHANGED
|
@@ -216,7 +216,9 @@ class ItemsService {
|
|
|
216
216
|
*/
|
|
217
217
|
async readByQuery(query, opts) {
|
|
218
218
|
const updatedQuery = (opts === null || opts === void 0 ? void 0 : opts.emitEvents) !== false
|
|
219
|
-
? await emitter_1.default.emitFilter(
|
|
219
|
+
? await emitter_1.default.emitFilter(this.eventScope === 'items'
|
|
220
|
+
? ['items.query', `${this.collection}.items.query`]
|
|
221
|
+
: `${this.eventScope}.query`, query, {
|
|
220
222
|
collection: this.collection,
|
|
221
223
|
}, {
|
|
222
224
|
database: this.knex,
|
|
@@ -103,7 +103,6 @@ blockquote > p {
|
|
|
103
103
|
</style>
|
|
104
104
|
|
|
105
105
|
<meta name="generator" content="Directus">
|
|
106
|
-
<meta property="og:url" content="http://directus-20534155.hs-sites.com/7dea362b-3fac-3e00-956a-4952a3d4f474">
|
|
107
106
|
<meta name="x-apple-disable-message-reformatting">
|
|
108
107
|
<meta name="robots" content="noindex,follow">
|
|
109
108
|
|
package/dist/services/payload.js
CHANGED
|
@@ -223,7 +223,7 @@ class PayloadService {
|
|
|
223
223
|
for (const [name, dateColumn] of dateColumns) {
|
|
224
224
|
for (const payload of payloads) {
|
|
225
225
|
let value = payload[name];
|
|
226
|
-
if (value === null || value === '
|
|
226
|
+
if (value === null || (typeof value === 'string' && /^[.0 :-]{10,}$/.test(value))) {
|
|
227
227
|
payload[name] = null;
|
|
228
228
|
continue;
|
|
229
229
|
}
|
|
@@ -545,7 +545,7 @@ class PayloadService {
|
|
|
545
545
|
.from(relation.collection)
|
|
546
546
|
.where({ [relation.field]: parent })
|
|
547
547
|
.whereNotNull(sortField)
|
|
548
|
-
.max(sortField)
|
|
548
|
+
.max(sortField, { as: 'max' })
|
|
549
549
|
.first();
|
|
550
550
|
createPayload = alterations.create.map((item, index) => {
|
|
551
551
|
const record = (0, lodash_1.cloneDeep)(item);
|
|
@@ -90,5 +90,107 @@ describe('Integration Tests', () => {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
|
+
describe('processDates', () => {
|
|
94
|
+
let service;
|
|
95
|
+
const dateFieldId = 'date_field';
|
|
96
|
+
const dateTimeFieldId = 'datetime_field';
|
|
97
|
+
const timestampFieldId = 'timestamp_field';
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
service = new services_1.PayloadService('test', {
|
|
100
|
+
knex: db,
|
|
101
|
+
schema: {
|
|
102
|
+
collections: {
|
|
103
|
+
test: {
|
|
104
|
+
collection: 'test',
|
|
105
|
+
primary: 'id',
|
|
106
|
+
singleton: false,
|
|
107
|
+
sortField: null,
|
|
108
|
+
note: null,
|
|
109
|
+
accountability: null,
|
|
110
|
+
fields: {
|
|
111
|
+
[dateFieldId]: {
|
|
112
|
+
field: dateFieldId,
|
|
113
|
+
defaultValue: null,
|
|
114
|
+
nullable: true,
|
|
115
|
+
generated: false,
|
|
116
|
+
type: 'date',
|
|
117
|
+
dbType: 'date',
|
|
118
|
+
precision: null,
|
|
119
|
+
scale: null,
|
|
120
|
+
special: [],
|
|
121
|
+
note: null,
|
|
122
|
+
validation: null,
|
|
123
|
+
alias: false,
|
|
124
|
+
},
|
|
125
|
+
[dateTimeFieldId]: {
|
|
126
|
+
field: dateTimeFieldId,
|
|
127
|
+
defaultValue: null,
|
|
128
|
+
nullable: true,
|
|
129
|
+
generated: false,
|
|
130
|
+
type: 'dateTime',
|
|
131
|
+
dbType: 'datetime',
|
|
132
|
+
precision: null,
|
|
133
|
+
scale: null,
|
|
134
|
+
special: [],
|
|
135
|
+
note: null,
|
|
136
|
+
validation: null,
|
|
137
|
+
alias: false,
|
|
138
|
+
},
|
|
139
|
+
[timestampFieldId]: {
|
|
140
|
+
field: timestampFieldId,
|
|
141
|
+
defaultValue: null,
|
|
142
|
+
nullable: true,
|
|
143
|
+
generated: false,
|
|
144
|
+
type: 'timestamp',
|
|
145
|
+
dbType: 'timestamp',
|
|
146
|
+
precision: null,
|
|
147
|
+
scale: null,
|
|
148
|
+
special: [],
|
|
149
|
+
note: null,
|
|
150
|
+
validation: null,
|
|
151
|
+
alias: false,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
relations: [],
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
describe('processes dates', () => {
|
|
161
|
+
it('with zero values', async () => {
|
|
162
|
+
const result = await service.processDates([
|
|
163
|
+
{
|
|
164
|
+
[dateFieldId]: '0000-00-00',
|
|
165
|
+
[dateTimeFieldId]: '0000-00-00 00:00:00',
|
|
166
|
+
[timestampFieldId]: '0000-00-00 00:00:00.000',
|
|
167
|
+
},
|
|
168
|
+
], 'read');
|
|
169
|
+
expect(result).toMatchObject([
|
|
170
|
+
{
|
|
171
|
+
[dateFieldId]: null,
|
|
172
|
+
[dateTimeFieldId]: null,
|
|
173
|
+
[timestampFieldId]: null,
|
|
174
|
+
},
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
it('with typical values', async () => {
|
|
178
|
+
const result = await service.processDates([
|
|
179
|
+
{
|
|
180
|
+
[dateFieldId]: '2022-01-10',
|
|
181
|
+
[dateTimeFieldId]: '2021-09-31 12:34:56',
|
|
182
|
+
[timestampFieldId]: '1980-12-08 00:11:22.333',
|
|
183
|
+
},
|
|
184
|
+
], 'read');
|
|
185
|
+
expect(result).toMatchObject([
|
|
186
|
+
{
|
|
187
|
+
[dateFieldId]: '2022-01-10',
|
|
188
|
+
[dateTimeFieldId]: '2021-10-01T12:34:56',
|
|
189
|
+
[timestampFieldId]: new Date('1980-12-08 00:11:22.333').toISOString(),
|
|
190
|
+
},
|
|
191
|
+
]);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
93
195
|
});
|
|
94
196
|
});
|