directus 9.18.1 → 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 +80 -65
- 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/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
|
@@ -282,15 +282,15 @@ class GraphQLService {
|
|
|
282
282
|
!field.defaultValue &&
|
|
283
283
|
!constants_1.GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
|
|
284
284
|
action !== 'update') {
|
|
285
|
-
type =
|
|
285
|
+
type = new graphql_1.GraphQLNonNull(type);
|
|
286
286
|
}
|
|
287
287
|
if (collection.primary === field.field) {
|
|
288
288
|
if (!field.defaultValue && !field.special.includes('uuid') && action === 'create')
|
|
289
|
-
type =
|
|
289
|
+
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
290
290
|
else if (['create', 'update'].includes(action))
|
|
291
291
|
type = graphql_1.GraphQLID;
|
|
292
292
|
else
|
|
293
|
-
type =
|
|
293
|
+
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
294
294
|
}
|
|
295
295
|
acc[field.field] = {
|
|
296
296
|
type,
|
|
@@ -386,7 +386,7 @@ class GraphQLService {
|
|
|
386
386
|
parent = parent[pathPart];
|
|
387
387
|
}
|
|
388
388
|
const collection = parent[relation.meta.one_collection_field];
|
|
389
|
-
return CollectionTypes[collection].getType();
|
|
389
|
+
return CollectionTypes[collection].getType().name;
|
|
390
390
|
},
|
|
391
391
|
}),
|
|
392
392
|
resolve: (obj, _, __, info) => {
|
|
@@ -421,6 +421,9 @@ class GraphQLService {
|
|
|
421
421
|
_contains: {
|
|
422
422
|
type: graphql_1.GraphQLString,
|
|
423
423
|
},
|
|
424
|
+
_icontains: {
|
|
425
|
+
type: graphql_1.GraphQLString,
|
|
426
|
+
},
|
|
424
427
|
_ncontains: {
|
|
425
428
|
type: graphql_1.GraphQLString,
|
|
426
429
|
},
|
|
@@ -500,6 +503,12 @@ class GraphQLService {
|
|
|
500
503
|
_nnull: {
|
|
501
504
|
type: graphql_1.GraphQLBoolean,
|
|
502
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
|
+
},
|
|
503
512
|
_between: {
|
|
504
513
|
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
505
514
|
},
|
|
@@ -571,6 +580,12 @@ class GraphQLService {
|
|
|
571
580
|
_nintersects_bbox: {
|
|
572
581
|
type: geojson_1.GraphQLGeoJSON,
|
|
573
582
|
},
|
|
583
|
+
_null: {
|
|
584
|
+
type: graphql_1.GraphQLBoolean,
|
|
585
|
+
},
|
|
586
|
+
_nnull: {
|
|
587
|
+
type: graphql_1.GraphQLBoolean,
|
|
588
|
+
},
|
|
574
589
|
},
|
|
575
590
|
});
|
|
576
591
|
const HashFilterOperators = schemaComposer.createInputTC({
|
|
@@ -840,7 +855,7 @@ class GraphQLService {
|
|
|
840
855
|
name: `${collection.collection}_by_id`,
|
|
841
856
|
type: ReadCollectionTypes[collection.collection],
|
|
842
857
|
args: {
|
|
843
|
-
id:
|
|
858
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
844
859
|
},
|
|
845
860
|
resolve: async ({ info, context }) => {
|
|
846
861
|
const result = await self.resolveQuery(info);
|
|
@@ -1001,7 +1016,7 @@ class GraphQLService {
|
|
|
1001
1016
|
...(collectionIsReadable
|
|
1002
1017
|
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
1003
1018
|
: {}),
|
|
1004
|
-
ids:
|
|
1019
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1005
1020
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1006
1021
|
},
|
|
1007
1022
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
@@ -1010,7 +1025,7 @@ class GraphQLService {
|
|
|
1010
1025
|
name: `update_${collection.collection}_item`,
|
|
1011
1026
|
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
1012
1027
|
args: {
|
|
1013
|
-
id:
|
|
1028
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1014
1029
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1015
1030
|
},
|
|
1016
1031
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
@@ -1021,13 +1036,13 @@ class GraphQLService {
|
|
|
1021
1036
|
DeleteCollectionTypes.many = schemaComposer.createObjectTC({
|
|
1022
1037
|
name: `delete_many`,
|
|
1023
1038
|
fields: {
|
|
1024
|
-
ids:
|
|
1039
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1025
1040
|
},
|
|
1026
1041
|
});
|
|
1027
1042
|
DeleteCollectionTypes.one = schemaComposer.createObjectTC({
|
|
1028
1043
|
name: `delete_one`,
|
|
1029
1044
|
fields: {
|
|
1030
|
-
id:
|
|
1045
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1031
1046
|
},
|
|
1032
1047
|
});
|
|
1033
1048
|
for (const collection of Object.values(schema.delete.collections)) {
|
|
@@ -1035,7 +1050,7 @@ class GraphQLService {
|
|
|
1035
1050
|
name: `delete_${collection.collection}_items`,
|
|
1036
1051
|
type: DeleteCollectionTypes.many,
|
|
1037
1052
|
args: {
|
|
1038
|
-
ids:
|
|
1053
|
+
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1039
1054
|
},
|
|
1040
1055
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1041
1056
|
});
|
|
@@ -1043,7 +1058,7 @@ class GraphQLService {
|
|
|
1043
1058
|
name: `delete_${collection.collection}_item`,
|
|
1044
1059
|
type: DeleteCollectionTypes.one,
|
|
1045
1060
|
args: {
|
|
1046
|
-
id:
|
|
1061
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1047
1062
|
},
|
|
1048
1063
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1049
1064
|
});
|
|
@@ -1236,7 +1251,7 @@ class GraphQLService {
|
|
|
1236
1251
|
return Boolean(node.value);
|
|
1237
1252
|
case 'EnumValue':
|
|
1238
1253
|
default:
|
|
1239
|
-
return node.value;
|
|
1254
|
+
return 'value' in node ? node.value : null;
|
|
1240
1255
|
}
|
|
1241
1256
|
};
|
|
1242
1257
|
const argsObject = Object.fromEntries(args.map((arg) => [arg.name.value, parse(arg.value)]));
|
|
@@ -1615,8 +1630,8 @@ class GraphQLService {
|
|
|
1615
1630
|
auth_login: {
|
|
1616
1631
|
type: AuthTokens,
|
|
1617
1632
|
args: {
|
|
1618
|
-
email:
|
|
1619
|
-
password:
|
|
1633
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1634
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1620
1635
|
mode: AuthMode,
|
|
1621
1636
|
otp: graphql_1.GraphQLString,
|
|
1622
1637
|
},
|
|
@@ -1715,7 +1730,7 @@ class GraphQLService {
|
|
|
1715
1730
|
auth_password_request: {
|
|
1716
1731
|
type: graphql_1.GraphQLBoolean,
|
|
1717
1732
|
args: {
|
|
1718
|
-
email:
|
|
1733
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1719
1734
|
reset_url: graphql_1.GraphQLString,
|
|
1720
1735
|
},
|
|
1721
1736
|
resolve: async (_, args, { req }) => {
|
|
@@ -1740,8 +1755,8 @@ class GraphQLService {
|
|
|
1740
1755
|
auth_password_reset: {
|
|
1741
1756
|
type: graphql_1.GraphQLBoolean,
|
|
1742
1757
|
args: {
|
|
1743
|
-
token:
|
|
1744
|
-
password:
|
|
1758
|
+
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1759
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1745
1760
|
},
|
|
1746
1761
|
resolve: async (_, args, { req }) => {
|
|
1747
1762
|
const accountability = {
|
|
@@ -1764,7 +1779,7 @@ class GraphQLService {
|
|
|
1764
1779
|
},
|
|
1765
1780
|
}),
|
|
1766
1781
|
args: {
|
|
1767
|
-
password:
|
|
1782
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1768
1783
|
},
|
|
1769
1784
|
resolve: async (_, args) => {
|
|
1770
1785
|
var _a;
|
|
@@ -1786,8 +1801,8 @@ class GraphQLService {
|
|
|
1786
1801
|
users_me_tfa_enable: {
|
|
1787
1802
|
type: graphql_1.GraphQLBoolean,
|
|
1788
1803
|
args: {
|
|
1789
|
-
otp:
|
|
1790
|
-
secret:
|
|
1804
|
+
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1805
|
+
secret: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1791
1806
|
},
|
|
1792
1807
|
resolve: async (_, args) => {
|
|
1793
1808
|
var _a;
|
|
@@ -1804,7 +1819,7 @@ class GraphQLService {
|
|
|
1804
1819
|
users_me_tfa_disable: {
|
|
1805
1820
|
type: graphql_1.GraphQLBoolean,
|
|
1806
1821
|
args: {
|
|
1807
|
-
otp:
|
|
1822
|
+
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1808
1823
|
},
|
|
1809
1824
|
resolve: async (_, args) => {
|
|
1810
1825
|
var _a;
|
|
@@ -1825,7 +1840,7 @@ class GraphQLService {
|
|
|
1825
1840
|
utils_hash_generate: {
|
|
1826
1841
|
type: graphql_1.GraphQLString,
|
|
1827
1842
|
args: {
|
|
1828
|
-
string:
|
|
1843
|
+
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1829
1844
|
},
|
|
1830
1845
|
resolve: async (_, args) => {
|
|
1831
1846
|
return await (0, generate_hash_1.generateHash)(args.string);
|
|
@@ -1834,8 +1849,8 @@ class GraphQLService {
|
|
|
1834
1849
|
utils_hash_verify: {
|
|
1835
1850
|
type: graphql_1.GraphQLBoolean,
|
|
1836
1851
|
args: {
|
|
1837
|
-
string:
|
|
1838
|
-
hash:
|
|
1852
|
+
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1853
|
+
hash: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1839
1854
|
},
|
|
1840
1855
|
resolve: async (_, args) => {
|
|
1841
1856
|
return await argon2_1.default.verify(args.hash, args.string);
|
|
@@ -1844,9 +1859,9 @@ class GraphQLService {
|
|
|
1844
1859
|
utils_sort: {
|
|
1845
1860
|
type: graphql_1.GraphQLBoolean,
|
|
1846
1861
|
args: {
|
|
1847
|
-
collection:
|
|
1848
|
-
item:
|
|
1849
|
-
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),
|
|
1850
1865
|
},
|
|
1851
1866
|
resolve: async (_, args) => {
|
|
1852
1867
|
const service = new utils_1.UtilsService({
|
|
@@ -1861,7 +1876,7 @@ class GraphQLService {
|
|
|
1861
1876
|
utils_revert: {
|
|
1862
1877
|
type: graphql_1.GraphQLBoolean,
|
|
1863
1878
|
args: {
|
|
1864
|
-
revision:
|
|
1879
|
+
revision: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1865
1880
|
},
|
|
1866
1881
|
resolve: async (_, args) => {
|
|
1867
1882
|
const service = new revisions_1.RevisionsService({
|
|
@@ -1888,8 +1903,8 @@ class GraphQLService {
|
|
|
1888
1903
|
users_invite_accept: {
|
|
1889
1904
|
type: graphql_1.GraphQLBoolean,
|
|
1890
1905
|
args: {
|
|
1891
|
-
token:
|
|
1892
|
-
password:
|
|
1906
|
+
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1907
|
+
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1893
1908
|
},
|
|
1894
1909
|
resolve: async (_, args) => {
|
|
1895
1910
|
const service = new users_1.UsersService({
|
|
@@ -1910,7 +1925,7 @@ class GraphQLService {
|
|
|
1910
1925
|
acc[field.field] = {
|
|
1911
1926
|
type: field.nullable
|
|
1912
1927
|
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
1913
|
-
:
|
|
1928
|
+
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
1914
1929
|
description: field.note,
|
|
1915
1930
|
};
|
|
1916
1931
|
return acc;
|
|
@@ -1938,7 +1953,7 @@ class GraphQLService {
|
|
|
1938
1953
|
collections_by_name: {
|
|
1939
1954
|
type: Collection,
|
|
1940
1955
|
args: {
|
|
1941
|
-
name:
|
|
1956
|
+
name: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1942
1957
|
},
|
|
1943
1958
|
resolve: async (_, args) => {
|
|
1944
1959
|
const collectionsService = new collections_1.CollectionsService({
|
|
@@ -1961,7 +1976,7 @@ class GraphQLService {
|
|
|
1961
1976
|
acc[field.field] = {
|
|
1962
1977
|
type: field.nullable
|
|
1963
1978
|
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
1964
|
-
:
|
|
1979
|
+
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
1965
1980
|
description: field.note,
|
|
1966
1981
|
};
|
|
1967
1982
|
return acc;
|
|
@@ -2001,7 +2016,7 @@ class GraphQLService {
|
|
|
2001
2016
|
fields_in_collection: {
|
|
2002
2017
|
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Field.getType()))),
|
|
2003
2018
|
args: {
|
|
2004
|
-
collection:
|
|
2019
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2005
2020
|
},
|
|
2006
2021
|
resolve: async (_, args) => {
|
|
2007
2022
|
const service = new fields_1.FieldsService({
|
|
@@ -2014,8 +2029,8 @@ class GraphQLService {
|
|
|
2014
2029
|
fields_by_name: {
|
|
2015
2030
|
type: Field,
|
|
2016
2031
|
args: {
|
|
2017
|
-
collection:
|
|
2018
|
-
field:
|
|
2032
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2033
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2019
2034
|
},
|
|
2020
2035
|
resolve: async (_, args) => {
|
|
2021
2036
|
const service = new fields_1.FieldsService({
|
|
@@ -2035,13 +2050,13 @@ class GraphQLService {
|
|
|
2035
2050
|
schema: schemaComposer.createObjectTC({
|
|
2036
2051
|
name: 'directus_relations_schema',
|
|
2037
2052
|
fields: {
|
|
2038
|
-
table:
|
|
2039
|
-
column:
|
|
2040
|
-
foreign_key_table:
|
|
2041
|
-
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),
|
|
2042
2057
|
constraint_name: graphql_1.GraphQLString,
|
|
2043
|
-
on_update:
|
|
2044
|
-
on_delete:
|
|
2058
|
+
on_update: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2059
|
+
on_delete: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2045
2060
|
},
|
|
2046
2061
|
}),
|
|
2047
2062
|
meta: schemaComposer.createObjectTC({
|
|
@@ -2069,7 +2084,7 @@ class GraphQLService {
|
|
|
2069
2084
|
relations_in_collection: {
|
|
2070
2085
|
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Relation.getType()))),
|
|
2071
2086
|
args: {
|
|
2072
|
-
collection:
|
|
2087
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2073
2088
|
},
|
|
2074
2089
|
resolve: async (_, args) => {
|
|
2075
2090
|
const service = new relations_1.RelationsService({
|
|
@@ -2082,8 +2097,8 @@ class GraphQLService {
|
|
|
2082
2097
|
relations_by_name: {
|
|
2083
2098
|
type: Relation,
|
|
2084
2099
|
args: {
|
|
2085
|
-
collection:
|
|
2086
|
-
field:
|
|
2100
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2101
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2087
2102
|
},
|
|
2088
2103
|
resolve: async (_, args) => {
|
|
2089
2104
|
const service = new relations_1.RelationsService({
|
|
@@ -2120,7 +2135,7 @@ class GraphQLService {
|
|
|
2120
2135
|
update_collections_item: {
|
|
2121
2136
|
type: Collection,
|
|
2122
2137
|
args: {
|
|
2123
|
-
collection:
|
|
2138
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2124
2139
|
data: (0, graphql_compose_1.toInputObjectType)(Collection.clone('update_directus_collections'), {
|
|
2125
2140
|
postfix: '_input',
|
|
2126
2141
|
}).removeField(['collection', 'schema']).NonNull,
|
|
@@ -2142,7 +2157,7 @@ class GraphQLService {
|
|
|
2142
2157
|
},
|
|
2143
2158
|
}),
|
|
2144
2159
|
args: {
|
|
2145
|
-
collection:
|
|
2160
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2146
2161
|
},
|
|
2147
2162
|
resolve: async (_, args) => {
|
|
2148
2163
|
const collectionsService = new collections_1.CollectionsService({
|
|
@@ -2158,7 +2173,7 @@ class GraphQLService {
|
|
|
2158
2173
|
create_fields_item: {
|
|
2159
2174
|
type: Field,
|
|
2160
2175
|
args: {
|
|
2161
|
-
collection:
|
|
2176
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2162
2177
|
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('create_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2163
2178
|
},
|
|
2164
2179
|
resolve: async (_, args) => {
|
|
@@ -2173,8 +2188,8 @@ class GraphQLService {
|
|
|
2173
2188
|
update_fields_item: {
|
|
2174
2189
|
type: Field,
|
|
2175
2190
|
args: {
|
|
2176
|
-
collection:
|
|
2177
|
-
field:
|
|
2191
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2192
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2178
2193
|
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('update_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2179
2194
|
},
|
|
2180
2195
|
resolve: async (_, args) => {
|
|
@@ -2198,8 +2213,8 @@ class GraphQLService {
|
|
|
2198
2213
|
},
|
|
2199
2214
|
}),
|
|
2200
2215
|
args: {
|
|
2201
|
-
collection:
|
|
2202
|
-
field:
|
|
2216
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2217
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2203
2218
|
},
|
|
2204
2219
|
resolve: async (_, args) => {
|
|
2205
2220
|
const service = new fields_1.FieldsService({
|
|
@@ -2230,8 +2245,8 @@ class GraphQLService {
|
|
|
2230
2245
|
update_relations_item: {
|
|
2231
2246
|
type: Relation,
|
|
2232
2247
|
args: {
|
|
2233
|
-
collection:
|
|
2234
|
-
field:
|
|
2248
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2249
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2235
2250
|
data: (0, graphql_compose_1.toInputObjectType)(Relation.clone('update_directus_relations'), { postfix: '_input' }).NonNull,
|
|
2236
2251
|
},
|
|
2237
2252
|
resolve: async (_, args) => {
|
|
@@ -2252,8 +2267,8 @@ class GraphQLService {
|
|
|
2252
2267
|
},
|
|
2253
2268
|
}),
|
|
2254
2269
|
args: {
|
|
2255
|
-
collection:
|
|
2256
|
-
field:
|
|
2270
|
+
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2271
|
+
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2257
2272
|
},
|
|
2258
2273
|
resolve: async (_, args) => {
|
|
2259
2274
|
const relationsService = new relations_1.RelationsService({
|
|
@@ -2313,9 +2328,9 @@ class GraphQLService {
|
|
|
2313
2328
|
create_comment: {
|
|
2314
2329
|
type: (_d = ReadCollectionTypes['directus_activity']) !== null && _d !== void 0 ? _d : graphql_1.GraphQLBoolean,
|
|
2315
2330
|
args: {
|
|
2316
|
-
collection:
|
|
2317
|
-
item:
|
|
2318
|
-
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),
|
|
2319
2334
|
},
|
|
2320
2335
|
resolve: async (_, args, __, info) => {
|
|
2321
2336
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -2346,8 +2361,8 @@ class GraphQLService {
|
|
|
2346
2361
|
update_comment: {
|
|
2347
2362
|
type: (_e = ReadCollectionTypes['directus_activity']) !== null && _e !== void 0 ? _e : graphql_1.GraphQLBoolean,
|
|
2348
2363
|
args: {
|
|
2349
|
-
id:
|
|
2350
|
-
comment:
|
|
2364
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2365
|
+
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2351
2366
|
},
|
|
2352
2367
|
resolve: async (_, args, __, info) => {
|
|
2353
2368
|
var _a, _b;
|
|
@@ -2371,7 +2386,7 @@ class GraphQLService {
|
|
|
2371
2386
|
delete_comment: {
|
|
2372
2387
|
type: DeleteCollectionTypes.one,
|
|
2373
2388
|
args: {
|
|
2374
|
-
id:
|
|
2389
|
+
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2375
2390
|
},
|
|
2376
2391
|
resolve: async (_, args) => {
|
|
2377
2392
|
const service = new activity_1.ActivityService({
|
|
@@ -2389,7 +2404,7 @@ class GraphQLService {
|
|
|
2389
2404
|
import_file: {
|
|
2390
2405
|
type: (_f = ReadCollectionTypes['directus_files']) !== null && _f !== void 0 ? _f : graphql_1.GraphQLBoolean,
|
|
2391
2406
|
args: {
|
|
2392
|
-
url:
|
|
2407
|
+
url: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2393
2408
|
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes['directus_files']).setTypeName('create_directus_files_input'),
|
|
2394
2409
|
},
|
|
2395
2410
|
resolve: async (_, args, __, info) => {
|
|
@@ -2414,8 +2429,8 @@ class GraphQLService {
|
|
|
2414
2429
|
users_invite: {
|
|
2415
2430
|
type: graphql_1.GraphQLBoolean,
|
|
2416
2431
|
args: {
|
|
2417
|
-
email:
|
|
2418
|
-
role:
|
|
2432
|
+
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2433
|
+
role: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2419
2434
|
invite_url: graphql_1.GraphQLString,
|
|
2420
2435
|
},
|
|
2421
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>;
|
|
@@ -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
|
});
|
package/dist/types/items.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export declare type MutationOptions = {
|
|
|
23
23
|
* Flag to disable the auto purging of the cache. Is ignored when CACHE_AUTO_PURGE isn't enabled.
|
|
24
24
|
*/
|
|
25
25
|
autoPurgeCache?: false;
|
|
26
|
+
/**
|
|
27
|
+
* Flag to disable the auto purging of the system cache.
|
|
28
|
+
*/
|
|
29
|
+
autoPurgeSystemCache?: false;
|
|
26
30
|
/**
|
|
27
31
|
* Allow disabling the emitting of hooks. Useful if a custom hook is fired (like files.upload)
|
|
28
32
|
*/
|
|
@@ -212,11 +212,13 @@ function applyFilter(knex, schema, rootQuery, rootFilter, collection, subQuery =
|
|
|
212
212
|
const { columnPath, targetCollection } = (0, get_column_path_1.getColumnPath)({ path: filterPath, collection, relations, aliasMap });
|
|
213
213
|
if (!columnPath)
|
|
214
214
|
continue;
|
|
215
|
-
|
|
215
|
+
const { type, special } = validateFilterField(schema.collections[targetCollection].fields, (0, strip_function_1.stripFunction)(filterPath[filterPath.length - 1]), targetCollection);
|
|
216
|
+
validateFilterOperator(type, filterOperator, special);
|
|
216
217
|
applyFilterToQuery(columnPath, filterOperator, filterValue, logical, targetCollection);
|
|
217
218
|
}
|
|
218
219
|
else {
|
|
219
|
-
|
|
220
|
+
const { type, special } = validateFilterField(schema.collections[collection].fields, (0, strip_function_1.stripFunction)(filterPath[0]), collection);
|
|
221
|
+
validateFilterOperator(type, filterOperator, special);
|
|
220
222
|
applyFilterToQuery(`${collection}.${filterPath[0]}`, filterOperator, filterValue, logical);
|
|
221
223
|
}
|
|
222
224
|
}
|
|
@@ -248,6 +250,12 @@ function applyFilter(knex, schema, rootQuery, rootFilter, collection, subQuery =
|
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
}
|
|
253
|
+
function validateFilterField(fields, key, collection = 'unknown') {
|
|
254
|
+
if (fields[key] === undefined) {
|
|
255
|
+
throw new invalid_query_1.InvalidQueryException(`Invalid filter key "${key}" on "${collection}"`);
|
|
256
|
+
}
|
|
257
|
+
return fields[key];
|
|
258
|
+
}
|
|
251
259
|
function validateFilterOperator(type, filterOperator, special) {
|
|
252
260
|
if (filterOperator.startsWith('_')) {
|
|
253
261
|
filterOperator = filterOperator.slice(1);
|