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.
Files changed (47) hide show
  1. package/dist/cli/commands/roles/create.js +1 -1
  2. package/dist/cli/utils/create-env/env-stub.liquid +3 -2
  3. package/dist/controllers/collections.js +18 -0
  4. package/dist/database/run-ast.js +11 -4
  5. package/dist/database/system-data/fields/activity.yaml +2 -1
  6. package/dist/database/system-data/fields/collections.yaml +8 -4
  7. package/dist/database/system-data/fields/dashboards.yaml +6 -3
  8. package/dist/database/system-data/fields/fields.yaml +18 -9
  9. package/dist/database/system-data/fields/files.yaml +14 -7
  10. package/dist/database/system-data/fields/flows.yaml +10 -5
  11. package/dist/database/system-data/fields/folders.yaml +2 -1
  12. package/dist/database/system-data/fields/operations.yaml +8 -4
  13. package/dist/database/system-data/fields/panels.yaml +8 -4
  14. package/dist/database/system-data/fields/permissions.yaml +8 -4
  15. package/dist/database/system-data/fields/presets.yaml +10 -5
  16. package/dist/database/system-data/fields/relations.yaml +2 -1
  17. package/dist/database/system-data/fields/revisions.yaml +4 -2
  18. package/dist/database/system-data/fields/roles.yaml +12 -6
  19. package/dist/database/system-data/fields/settings.yaml +10 -5
  20. package/dist/database/system-data/fields/shares.yaml +7 -3
  21. package/dist/database/system-data/fields/users.yaml +15 -7
  22. package/dist/database/system-data/fields/webhooks.yaml +8 -4
  23. package/dist/env.js +4 -2
  24. package/dist/env.test.js +1 -0
  25. package/dist/logger.d.ts +2 -2
  26. package/dist/logger.js +10 -3
  27. package/dist/messenger.d.ts +3 -3
  28. package/dist/services/collections.d.ts +4 -0
  29. package/dist/services/collections.js +50 -5
  30. package/dist/services/graphql/index.js +80 -65
  31. package/dist/services/graphql/types/date.d.ts +1 -1
  32. package/dist/services/graphql/types/geojson.d.ts +1 -1
  33. package/dist/services/graphql/types/hash.d.ts +1 -1
  34. package/dist/services/graphql/types/string-or-float.d.ts +1 -1
  35. package/dist/services/graphql/types/void.d.ts +1 -1
  36. package/dist/services/mail/templates/base.liquid +0 -1
  37. package/dist/services/payload.js +2 -2
  38. package/dist/services/payload.test.js +102 -0
  39. package/dist/types/items.d.ts +4 -0
  40. package/dist/utils/apply-query.js +10 -2
  41. package/dist/utils/get-ast-from-query.js +1 -1
  42. package/dist/utils/get-auth-providers.d.ts +1 -0
  43. package/dist/utils/get-auth-providers.js +1 -0
  44. package/dist/utils/get-auth-providers.test.d.ts +1 -0
  45. package/dist/utils/get-auth-providers.test.js +72 -0
  46. package/dist/utils/get-relation-info.js +10 -4
  47. package/package.json +121 -122
@@ -73,7 +73,7 @@ async function getASTFromQuery(collection, query, schema, options) {
73
73
  if (!fields || !Array.isArray(fields))
74
74
  return [];
75
75
  const children = [];
76
- const relationalStructure = {};
76
+ const relationalStructure = Object.create(null);
77
77
  for (const fieldKey of fields) {
78
78
  let name = fieldKey;
79
79
  if (query.alias) {
@@ -1,4 +1,5 @@
1
1
  interface AuthProvider {
2
+ label: string;
2
3
  name: string;
3
4
  driver: string;
4
5
  icon?: string;
@@ -11,6 +11,7 @@ function getAuthProviders() {
11
11
  .filter((provider) => provider && env_1.default[`AUTH_${provider.toUpperCase()}_DRIVER`])
12
12
  .map((provider) => ({
13
13
  name: provider,
14
+ label: env_1.default[`AUTH_${provider.toUpperCase()}_LABEL`],
14
15
  driver: env_1.default[`AUTH_${provider.toUpperCase()}_DRIVER`],
15
16
  icon: env_1.default[`AUTH_${provider.toUpperCase()}_ICON`],
16
17
  }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ let factoryEnv = {};
4
+ jest.mock('../../src/env', () => new Proxy({}, {
5
+ get(target, prop) {
6
+ return factoryEnv[prop];
7
+ },
8
+ }));
9
+ const get_auth_providers_1 = require("../../src/utils/get-auth-providers");
10
+ const scenarios = [
11
+ {
12
+ name: 'when no providers configured',
13
+ input: {},
14
+ output: [],
15
+ },
16
+ {
17
+ name: 'when no driver configured',
18
+ input: {
19
+ AUTH_PROVIDERS: 'directus',
20
+ },
21
+ output: [],
22
+ },
23
+ {
24
+ name: 'when single provider and driver are properly configured',
25
+ input: {
26
+ AUTH_PROVIDERS: 'directus',
27
+ AUTH_DIRECTUS_DRIVER: 'openid',
28
+ AUTH_DIRECTUS_LABEL: 'Directus',
29
+ AUTH_DIRECTUS_ICON: 'hare',
30
+ },
31
+ output: [
32
+ {
33
+ name: 'directus',
34
+ driver: 'openid',
35
+ label: 'Directus',
36
+ icon: 'hare',
37
+ },
38
+ ],
39
+ },
40
+ {
41
+ name: 'when multiple provider and driver are properly configured',
42
+ input: {
43
+ AUTH_PROVIDERS: 'directus,custom',
44
+ AUTH_DIRECTUS_DRIVER: 'openid',
45
+ AUTH_DIRECTUS_LABEL: 'Directus',
46
+ AUTH_DIRECTUS_ICON: 'hare',
47
+ AUTH_CUSTOM_DRIVER: 'openid',
48
+ AUTH_CUSTOM_ICON: 'lock',
49
+ },
50
+ output: [
51
+ {
52
+ name: 'directus',
53
+ driver: 'openid',
54
+ label: 'Directus',
55
+ icon: 'hare',
56
+ },
57
+ {
58
+ name: 'custom',
59
+ driver: 'openid',
60
+ icon: 'lock',
61
+ },
62
+ ],
63
+ },
64
+ ];
65
+ describe('get auth providers', () => {
66
+ for (const scenario of scenarios) {
67
+ test(scenario.name, () => {
68
+ factoryEnv = scenario.input;
69
+ expect((0, get_auth_providers_1.getAuthProviders)()).toEqual(scenario.output);
70
+ });
71
+ }
72
+ });
@@ -2,12 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRelationInfo = void 0;
4
4
  const get_relation_type_1 = require("./get-relation-type");
5
+ function checkImplicitRelation(field) {
6
+ if (field.startsWith('$FOLLOW(') && field.endsWith(')')) {
7
+ return field.slice(8, -1).split(',');
8
+ }
9
+ return null;
10
+ }
5
11
  function getRelationInfo(relations, collection, field) {
6
- var _a, _b;
12
+ var _a;
7
13
  if (field.startsWith('$FOLLOW') && field.length > 500) {
8
14
  throw new Error(`Implicit $FOLLOW statement is too big to parse. Got: "${field.substring(500)}..."`);
9
15
  }
10
- const implicitRelation = (_a = field.match(/^\$FOLLOW\((.*?),(.*?)(?:,(.*?))?\)$/)) === null || _a === void 0 ? void 0 : _a.slice(1);
16
+ const implicitRelation = checkImplicitRelation(field);
11
17
  if (implicitRelation) {
12
18
  if (implicitRelation[2] === undefined) {
13
19
  const [m2oCollection, m2oField] = implicitRelation;
@@ -34,11 +40,11 @@ function getRelationInfo(relations, collection, field) {
34
40
  return { relation, relationType: 'o2a' };
35
41
  }
36
42
  }
37
- const relation = (_b = relations.find((relation) => {
43
+ const relation = (_a = relations.find((relation) => {
38
44
  var _a;
39
45
  return ((relation.collection === collection && relation.field === field) ||
40
46
  (relation.related_collection === collection && ((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === field));
41
- })) !== null && _b !== void 0 ? _b : null;
47
+ })) !== null && _a !== void 0 ? _a : null;
42
48
  const relationType = relation ? (0, get_relation_type_1.getRelationType)({ relation, collection, field }) : null;
43
49
  return { relation, relationType };
44
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus",
3
- "version": "9.18.1",
3
+ "version": "9.19.0",
4
4
  "license": "GPL-3.0-only",
5
5
  "homepage": "https://github.com/directus/directus#readme",
6
6
  "description": "Directus is a real-time API and App dashboard for managing SQL database content.",
@@ -65,110 +65,110 @@
65
65
  "README.md"
66
66
  ],
67
67
  "dependencies": {
68
- "@aws-sdk/client-ses": "^3.107.0",
69
- "@directus/app": "9.18.1",
70
- "@directus/drive": "9.18.1",
71
- "@directus/drive-azure": "9.18.1",
72
- "@directus/drive-gcs": "9.18.1",
73
- "@directus/drive-s3": "9.18.1",
74
- "@directus/extensions-sdk": "^9.14.1",
75
- "@directus/format-title": "^9.15.0",
76
- "@directus/schema": "9.18.1",
77
- "@directus/shared": "9.18.1",
78
- "@directus/specs": "9.18.1",
79
- "@godaddy/terminus": "^4.10.2",
80
- "@rollup/plugin-alias": "^3.1.9",
81
- "@rollup/plugin-virtual": "^2.1.0",
82
- "argon2": "^0.28.5",
83
- "async": "^3.2.4",
84
- "async-mutex": "^0.3.2",
85
- "axios": "^0.27.2",
86
- "busboy": "^1.6.0",
87
- "bytes": "^3.1.2",
88
- "camelcase": "^6.2.0",
89
- "chalk": "^4.1.1",
90
- "chokidar": "^3.5.3",
91
- "commander": "^8.0.0",
92
- "cookie-parser": "^1.4.6",
93
- "cors": "^2.8.5",
94
- "csv-parser": "^3.0.0",
95
- "date-fns": "^2.28.0",
96
- "deep-diff": "^1.0.2",
97
- "deep-map": "^2.0.0",
98
- "destroy": "^1.2.0",
99
- "dotenv": "^10.0.0",
100
- "encodeurl": "^1.0.2",
101
- "eventemitter2": "^6.4.5",
102
- "execa": "^5.1.1",
103
- "exifr": "^7.1.3",
104
- "express": "^4.18.1",
105
- "fast-redact": "^3.1.1",
106
- "flat": "^5.0.2",
107
- "fs-extra": "^10.1.0",
108
- "globby": "^11.0.4",
109
- "graphql": "^15.5.0",
110
- "graphql-compose": "^9.0.8",
111
- "helmet": "^4.6.0",
112
- "inquirer": "^8.2.4",
113
- "ioredis": "^4.27.6",
114
- "joi": "^17.6.0",
115
- "js-yaml": "^4.1.0",
116
- "js2xmlparser": "^4.0.2",
117
- "json2csv": "^5.0.7",
118
- "jsonwebtoken": "^8.5.1",
119
- "keyv": "^4.3.0",
120
- "knex": "2.2.0",
121
- "knex-schema-inspector": "2.0.4",
122
- "ldapjs": "^2.3.3",
123
- "liquidjs": "^9.37.0",
124
- "lodash": "^4.17.21",
125
- "marked": "^4.0.16",
126
- "micromustache": "^8.0.3",
127
- "mime-types": "^2.1.35",
128
- "ms": "^2.1.3",
129
- "nanoid": "^3.1.23",
130
- "node-cron": "^3.0.2",
131
- "node-machine-id": "^1.1.12",
132
- "nodemailer": "^6.7.5",
133
- "object-hash": "^2.2.0",
134
- "openapi3-ts": "^2.0.2",
135
- "openid-client": "^5.1.6",
136
- "ora": "^5.4.0",
137
- "otplib": "^12.0.1",
138
- "pino": "6.13.3",
139
- "pino-colada": "^2.2.2",
140
- "pino-http": "5.8.0",
141
- "qs": "^6.10.5",
142
- "rate-limiter-flexible": "^2.3.7",
143
- "resolve-cwd": "^3.0.0",
144
- "rollup": "^2.75.6",
145
- "sanitize-html": "^2.7.0",
146
- "sharp": "^0.30.6",
147
- "snappy": "^7.1.1",
148
- "stream-json": "^1.7.4",
149
- "strip-bom-stream": "^4.0.0",
150
- "tmp-promise": "^3.0.3",
151
- "update-check": "^1.5.4",
152
- "uuid": "^8.3.2",
68
+ "@aws-sdk/client-ses": "3.190.0",
69
+ "@directus/app": "9.19.0",
70
+ "@directus/drive": "9.19.0",
71
+ "@directus/drive-azure": "9.19.0",
72
+ "@directus/drive-gcs": "9.19.0",
73
+ "@directus/drive-s3": "9.19.0",
74
+ "@directus/extensions-sdk": "9.19.0",
75
+ "@directus/format-title": "9.15.0",
76
+ "@directus/schema": "9.19.0",
77
+ "@directus/shared": "9.19.0",
78
+ "@directus/specs": "9.19.0",
79
+ "@godaddy/terminus": "4.11.2",
80
+ "@rollup/plugin-alias": "4.0.0",
81
+ "@rollup/plugin-virtual": "3.0.0",
82
+ "argon2": "0.30.1",
83
+ "async": "3.2.4",
84
+ "async-mutex": "0.4.0",
85
+ "axios": "1.1.3",
86
+ "busboy": "1.6.0",
87
+ "bytes": "3.1.2",
88
+ "camelcase": "6.3.0",
89
+ "chalk": "4.1.1",
90
+ "chokidar": "3.5.3",
91
+ "commander": "9.4.1",
92
+ "cookie-parser": "1.4.6",
93
+ "cors": "2.8.5",
94
+ "csv-parser": "3.0.0",
95
+ "date-fns": "2.29.3",
96
+ "deep-diff": "1.0.2",
97
+ "deep-map": "2.0.0",
98
+ "destroy": "1.2.0",
99
+ "dotenv": "16.0.3",
100
+ "encodeurl": "1.0.2",
101
+ "eventemitter2": "6.4.9",
102
+ "execa": "5.1.1",
103
+ "exifr": "7.1.3",
104
+ "express": "4.18.2",
105
+ "fast-redact": "3.1.2",
106
+ "flat": "5.0.2",
107
+ "fs-extra": "10.1.0",
108
+ "globby": "11.0.4",
109
+ "graphql": "16.6.0",
110
+ "graphql-compose": "9.0.9",
111
+ "helmet": "6.0.0",
112
+ "inquirer": "8.2.4",
113
+ "ioredis": "5.2.3",
114
+ "joi": "17.6.3",
115
+ "js-yaml": "4.1.0",
116
+ "js2xmlparser": "5.0.0",
117
+ "json2csv": "5.0.7",
118
+ "jsonwebtoken": "8.5.1",
119
+ "keyv": "4.5.0",
120
+ "knex": "2.3.0",
121
+ "knex-schema-inspector": "3.0.0",
122
+ "ldapjs": "2.3.3",
123
+ "liquidjs": "9.42.0",
124
+ "lodash": "4.17.21",
125
+ "marked": "4.1.1",
126
+ "micromustache": "8.0.3",
127
+ "mime-types": "2.1.35",
128
+ "ms": "2.1.3",
129
+ "nanoid": "3.1.23",
130
+ "node-cron": "3.0.2",
131
+ "node-machine-id": "1.1.12",
132
+ "nodemailer": "6.8.0",
133
+ "object-hash": "3.0.0",
134
+ "openapi3-ts": "3.1.1",
135
+ "openid-client": "5.2.0",
136
+ "ora": "5.4.0",
137
+ "otplib": "12.0.1",
138
+ "pino": "8.6.1",
139
+ "pino-http": "8.2.1",
140
+ "pino-http-print": "3.1.0",
141
+ "qs": "6.11.0",
142
+ "rate-limiter-flexible": "2.3.12",
143
+ "resolve-cwd": "3.0.0",
144
+ "rollup": "3.2.3",
145
+ "sanitize-html": "2.7.2",
146
+ "sharp": "0.31.1",
147
+ "snappy": "7.2.0",
148
+ "stream-json": "1.7.4",
149
+ "strip-bom-stream": "4.0.0",
150
+ "tmp-promise": "3.0.3",
151
+ "update-check": "1.5.4",
152
+ "uuid": "9.0.0",
153
153
  "uuid-validate": "0.0.3",
154
- "vm2": "^3.9.10",
155
- "wellknown": "^0.5.0"
154
+ "vm2": "3.9.11",
155
+ "wellknown": "0.5.0"
156
156
  },
157
157
  "optionalDependencies": {
158
- "@keyv/redis": "^2.3.6",
159
- "keyv-memcache": "^1.2.5",
160
- "memcached": "^2.2.2",
161
- "mysql": "^2.18.1",
162
- "nodemailer-mailgun-transport": "^2.1.4",
163
- "nodemailer-sendgrid": "^1.0.3",
164
- "pg": "^8.7.3",
165
- "sqlite3": "^5.0.8",
166
- "tedious": "^13.0.0"
158
+ "@keyv/redis": "2.5.2",
159
+ "keyv-memcache": "1.2.5",
160
+ "memcached": "2.2.2",
161
+ "mysql": "2.18.1",
162
+ "nodemailer-mailgun-transport": "2.1.5",
163
+ "nodemailer-sendgrid": "1.0.3",
164
+ "pg": "8.8.0",
165
+ "sqlite3": "5.1.2",
166
+ "tedious": "15.1.0"
167
167
  },
168
168
  "gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
169
169
  "devDependencies": {
170
- "@otplib/preset-default": "^12.0.1",
171
- "@types/async": "3.2.13",
170
+ "@otplib/preset-default": "12.0.1",
171
+ "@types/async": "3.2.15",
172
172
  "@types/body-parser": "1.19.2",
173
173
  "@types/busboy": "1.5.0",
174
174
  "@types/bytes": "3.1.1",
@@ -176,35 +176,34 @@
176
176
  "@types/cors": "2.8.12",
177
177
  "@types/deep-diff": "1.0.1",
178
178
  "@types/destroy": "1.0.0",
179
- "@types/encodeurl": "^1.0.0",
180
- "@types/express": "4.17.13",
179
+ "@types/encodeurl": "1.0.0",
180
+ "@types/express": "4.17.14",
181
181
  "@types/express-pino-logger": "4.0.3",
182
- "@types/express-serve-static-core": "^4.17.29",
183
- "@types/express-session": "1.17.4",
184
- "@types/fast-redact": "^3.0.1",
182
+ "@types/express-serve-static-core": "4.17.31",
183
+ "@types/express-session": "1.17.5",
184
+ "@types/fast-redact": "3.0.2",
185
185
  "@types/flat": "5.0.2",
186
186
  "@types/fs-extra": "9.0.13",
187
187
  "@types/inquirer": "8.2.1",
188
- "@types/ioredis": "^4.28.10",
189
- "@types/jest": "27.5.2",
188
+ "@types/jest": "29.2.0",
190
189
  "@types/js-yaml": "4.0.5",
191
190
  "@types/json2csv": "5.0.3",
192
- "@types/jsonwebtoken": "8.5.8",
191
+ "@types/jsonwebtoken": "8.5.9",
193
192
  "@types/keyv": "3.1.4",
194
- "@types/ldapjs": "2.2.2",
195
- "@types/lodash": "4.14.182",
196
- "@types/marked": "4.0.3",
193
+ "@types/ldapjs": "2.2.4",
194
+ "@types/lodash": "4.14.186",
195
+ "@types/marked": "4.0.7",
197
196
  "@types/mime-types": "2.1.1",
198
197
  "@types/ms": "0.7.31",
199
- "@types/node": "16.11.9",
200
- "@types/node-cron": "2.0.5",
201
- "@types/nodemailer": "6.4.4",
198
+ "@types/node": "18.11.2",
199
+ "@types/node-cron": "3.0.4",
200
+ "@types/nodemailer": "6.4.6",
202
201
  "@types/object-hash": "2.2.1",
203
- "@types/pino": "6.3.12",
202
+ "@types/pino": "7.0.4",
204
203
  "@types/pino-http": "5.8.1",
205
204
  "@types/qs": "6.9.7",
206
205
  "@types/sanitize-html": "2.6.2",
207
- "@types/sharp": "0.30.4",
206
+ "@types/sharp": "0.31.0",
208
207
  "@types/stream-json": "1.7.2",
209
208
  "@types/supertest": "2.0.12",
210
209
  "@types/uuid": "8.3.4",
@@ -212,15 +211,15 @@
212
211
  "@types/wellknown": "0.5.3",
213
212
  "copyfiles": "2.4.1",
214
213
  "cross-env": "7.0.3",
215
- "form-data": "^4.0.0",
216
- "jest": "28.1.2",
214
+ "form-data": "4.0.0",
215
+ "jest": "29.2.1",
217
216
  "knex-mock-client": "1.8.4",
218
217
  "rimraf": "3.0.2",
219
- "supertest": "^6.2.3",
220
- "ts-jest": "28.0.5",
221
- "ts-node": "^10.8.2",
222
- "ts-node-dev": "1.1.8",
223
- "typescript": "4.7.3"
218
+ "supertest": "6.3.0",
219
+ "ts-jest": "29.0.3",
220
+ "ts-node": "10.9.1",
221
+ "ts-node-dev": "2.0.0",
222
+ "typescript": "4.8.4"
224
223
  },
225
224
  "scripts": {
226
225
  "start": "npx directus start",