directus 9.15.1 → 9.17.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 (107) hide show
  1. package/dist/__utils__/items-utils.d.ts +2 -0
  2. package/dist/__utils__/items-utils.js +36 -0
  3. package/dist/__utils__/schemas.d.ts +13 -0
  4. package/dist/__utils__/schemas.js +304 -0
  5. package/dist/__utils__/snapshots.d.ts +5 -0
  6. package/dist/__utils__/snapshots.js +897 -0
  7. package/dist/app.js +8 -7
  8. package/dist/auth/drivers/ldap.js +1 -0
  9. package/dist/auth/drivers/local.js +6 -0
  10. package/dist/auth/drivers/oauth2.js +1 -0
  11. package/dist/auth/drivers/openid.js +1 -0
  12. package/dist/cli/index.test.d.ts +1 -0
  13. package/dist/cli/index.test.js +58 -0
  14. package/dist/cli/utils/create-env/env-stub.liquid +6 -2
  15. package/dist/controllers/activity.js +1 -0
  16. package/dist/controllers/assets.js +20 -16
  17. package/dist/controllers/auth.js +6 -9
  18. package/dist/controllers/files.test.d.ts +1 -0
  19. package/dist/controllers/files.test.js +49 -0
  20. package/dist/controllers/server.js +0 -1
  21. package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +3 -0
  22. package/dist/database/migrations/20220826A-add-origin-to-accountability.js +21 -0
  23. package/dist/database/migrations/run.test.d.ts +1 -0
  24. package/dist/database/migrations/run.test.js +92 -0
  25. package/dist/database/system-data/fields/activity.yaml +6 -0
  26. package/dist/database/system-data/fields/sessions.yaml +2 -0
  27. package/dist/env.js +15 -0
  28. package/dist/env.test.d.ts +8 -0
  29. package/dist/env.test.js +39 -0
  30. package/dist/extensions.d.ts +1 -0
  31. package/dist/extensions.js +16 -3
  32. package/dist/flows.js +28 -17
  33. package/dist/mailer.js +1 -0
  34. package/dist/middleware/authenticate.d.ts +1 -1
  35. package/dist/middleware/authenticate.js +1 -0
  36. package/dist/middleware/authenticate.test.d.ts +1 -0
  37. package/dist/middleware/authenticate.test.js +214 -0
  38. package/dist/middleware/extract-token.test.d.ts +1 -0
  39. package/dist/middleware/extract-token.test.js +60 -0
  40. package/dist/middleware/validate-batch.d.ts +1 -2
  41. package/dist/middleware/validate-batch.js +10 -13
  42. package/dist/middleware/validate-batch.test.d.ts +1 -0
  43. package/dist/middleware/validate-batch.test.js +82 -0
  44. package/dist/operations/exec/index.d.ts +5 -0
  45. package/dist/operations/exec/index.js +26 -0
  46. package/dist/operations/exec/index.test.d.ts +1 -0
  47. package/dist/operations/exec/index.test.js +95 -0
  48. package/dist/operations/notification/index.js +9 -6
  49. package/dist/operations/request/index.js +22 -3
  50. package/dist/operations/transform/index.d.ts +1 -1
  51. package/dist/operations/transform/index.js +1 -1
  52. package/dist/services/authentication.js +13 -3
  53. package/dist/services/files.js +3 -2
  54. package/dist/services/files.test.d.ts +1 -0
  55. package/dist/services/files.test.js +53 -0
  56. package/dist/services/flows.js +4 -0
  57. package/dist/services/graphql/index.d.ts +2 -2
  58. package/dist/services/graphql/index.js +78 -75
  59. package/dist/services/items.js +98 -42
  60. package/dist/services/items.test.d.ts +1 -0
  61. package/dist/services/items.test.js +765 -0
  62. package/dist/services/payload.d.ts +7 -4
  63. package/dist/services/payload.js +63 -12
  64. package/dist/services/payload.test.d.ts +1 -0
  65. package/dist/services/payload.test.js +94 -0
  66. package/dist/services/server.js +10 -7
  67. package/dist/services/shares.js +2 -1
  68. package/dist/services/specifications.test.d.ts +1 -0
  69. package/dist/services/specifications.test.js +96 -0
  70. package/dist/types/items.d.ts +11 -0
  71. package/dist/utils/apply-query.js +7 -3
  72. package/dist/utils/apply-snapshot.js +15 -0
  73. package/dist/utils/apply-snapshot.test.d.ts +1 -0
  74. package/dist/utils/apply-snapshot.test.js +305 -0
  75. package/dist/utils/async-handler.d.ts +2 -6
  76. package/dist/utils/async-handler.js +1 -13
  77. package/dist/utils/async-handler.test.d.ts +1 -0
  78. package/dist/utils/async-handler.test.js +18 -0
  79. package/dist/utils/calculate-field-depth.test.d.ts +1 -0
  80. package/dist/utils/calculate-field-depth.test.js +76 -0
  81. package/dist/utils/filter-items.test.d.ts +1 -0
  82. package/dist/utils/filter-items.test.js +60 -0
  83. package/dist/utils/get-cache-key.test.d.ts +1 -0
  84. package/dist/utils/get-cache-key.test.js +53 -0
  85. package/dist/utils/get-column-path.test.d.ts +1 -0
  86. package/dist/utils/get-column-path.test.js +136 -0
  87. package/dist/utils/get-config-from-env.test.d.ts +1 -0
  88. package/dist/utils/get-config-from-env.test.js +19 -0
  89. package/dist/utils/get-graphql-type.d.ts +1 -1
  90. package/dist/utils/get-graphql-type.js +4 -1
  91. package/dist/utils/get-os-info.d.ts +9 -0
  92. package/dist/utils/get-os-info.js +47 -0
  93. package/dist/utils/get-relation-info.test.d.ts +1 -0
  94. package/dist/utils/get-relation-info.test.js +88 -0
  95. package/dist/utils/get-relation-type.test.d.ts +1 -0
  96. package/dist/utils/get-relation-type.test.js +69 -0
  97. package/dist/utils/get-string-byte-size.test.d.ts +1 -0
  98. package/dist/utils/get-string-byte-size.test.js +8 -0
  99. package/dist/utils/is-directus-jwt.test.d.ts +1 -0
  100. package/dist/utils/is-directus-jwt.test.js +26 -0
  101. package/dist/utils/jwt.test.d.ts +1 -0
  102. package/dist/utils/jwt.test.js +36 -0
  103. package/dist/utils/merge-permissions.test.d.ts +1 -0
  104. package/dist/utils/merge-permissions.test.js +80 -0
  105. package/dist/utils/validate-keys.test.d.ts +1 -0
  106. package/dist/utils/validate-keys.test.js +97 -0
  107. package/package.json +14 -12
@@ -0,0 +1,2 @@
1
+ export declare const sqlFieldFormatter: (schema: Record<string, any>, table: string) => string;
2
+ export declare const sqlFieldList: (schema: Record<string, any>, table: string) => string;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sqlFieldList = exports.sqlFieldFormatter = void 0;
4
+ // dynamically adds fields to the sql strings as the schema grows
5
+ const sqlFieldFormatter = (schema, table) => {
6
+ const fields = [];
7
+ // Exclude alias fields, unable to selected in DB
8
+ for (const field of Object.keys(schema.collections[table].fields)) {
9
+ if (schema.collections[table].fields[field].type !== 'alias') {
10
+ fields.push(field);
11
+ }
12
+ }
13
+ let sql = '';
14
+ for (const field of fields.slice(0, fields.length - 1)) {
15
+ sql += `"${table}"."${field}", `;
16
+ }
17
+ sql += `"${table}"."${fields[fields.length - 1]}"`;
18
+ return sql;
19
+ };
20
+ exports.sqlFieldFormatter = sqlFieldFormatter;
21
+ const sqlFieldList = (schema, table) => {
22
+ const fields = [];
23
+ // Exclude alias fields, unable to selected in DB
24
+ for (const field of Object.keys(schema.collections[table].fields)) {
25
+ if (schema.collections[table].fields[field].type !== 'alias') {
26
+ fields.push(field);
27
+ }
28
+ }
29
+ let sql = '';
30
+ for (const field of fields.slice(0, fields.length - 1)) {
31
+ sql += `"${field}", `;
32
+ }
33
+ sql += `"${fields[fields.length - 1]}"`;
34
+ return sql;
35
+ };
36
+ exports.sqlFieldList = sqlFieldList;
@@ -0,0 +1,13 @@
1
+ import { CollectionsOverview, Relation } from '@directus/shared/types';
2
+ export declare const systemSchema: {
3
+ collections: CollectionsOverview;
4
+ relations: Relation[];
5
+ };
6
+ export declare const userSchema: {
7
+ collections: CollectionsOverview;
8
+ relations: Relation[];
9
+ };
10
+ export declare const snapshotApplyTestSchema: {
11
+ collections: CollectionsOverview;
12
+ relations: Relation[];
13
+ };
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.snapshotApplyTestSchema = exports.userSchema = exports.systemSchema = void 0;
4
+ exports.systemSchema = {
5
+ collections: {
6
+ directus_users: {
7
+ collection: 'directus_users',
8
+ primary: 'id',
9
+ singleton: false,
10
+ note: '$t:directus_collection.directus_users',
11
+ sortField: null,
12
+ accountability: null,
13
+ fields: {
14
+ id: {
15
+ field: 'id',
16
+ defaultValue: null,
17
+ nullable: false,
18
+ generated: false,
19
+ type: 'uuid',
20
+ dbType: 'uuid',
21
+ precision: null,
22
+ scale: null,
23
+ special: [],
24
+ note: null,
25
+ alias: false,
26
+ validation: null,
27
+ },
28
+ name: {
29
+ field: 'name',
30
+ defaultValue: "A User's Name",
31
+ nullable: false,
32
+ generated: false,
33
+ type: 'uuid',
34
+ dbType: 'uuid',
35
+ precision: null,
36
+ scale: null,
37
+ special: [],
38
+ note: null,
39
+ alias: false,
40
+ validation: null,
41
+ },
42
+ items: {
43
+ field: 'items',
44
+ defaultValue: null,
45
+ nullable: true,
46
+ generated: false,
47
+ type: 'alias',
48
+ dbType: null,
49
+ precision: null,
50
+ scale: null,
51
+ special: ['o2m'],
52
+ note: null,
53
+ alias: true,
54
+ validation: null,
55
+ },
56
+ },
57
+ },
58
+ directus_files: {
59
+ collection: 'directus_files',
60
+ primary: 'id',
61
+ singleton: false,
62
+ note: '$t:directus_collection.directus_files',
63
+ sortField: null,
64
+ accountability: null,
65
+ fields: {
66
+ id: {
67
+ field: 'id',
68
+ defaultValue: null,
69
+ nullable: false,
70
+ generated: false,
71
+ type: 'uuid',
72
+ dbType: 'uuid',
73
+ precision: null,
74
+ scale: null,
75
+ special: [],
76
+ note: null,
77
+ alias: false,
78
+ validation: null,
79
+ },
80
+ title: {
81
+ field: 'title',
82
+ defaultValue: "A File's Title",
83
+ nullable: false,
84
+ generated: false,
85
+ type: 'string',
86
+ dbType: 'text',
87
+ precision: null,
88
+ scale: null,
89
+ special: [],
90
+ note: null,
91
+ alias: false,
92
+ validation: null,
93
+ },
94
+ uploaded_by: {
95
+ field: 'uploaded_by',
96
+ defaultValue: null,
97
+ nullable: true,
98
+ generated: false,
99
+ type: 'uuid',
100
+ dbType: 'uuid',
101
+ precision: null,
102
+ scale: null,
103
+ special: [],
104
+ note: null,
105
+ alias: false,
106
+ validation: null,
107
+ },
108
+ },
109
+ },
110
+ },
111
+ relations: [
112
+ {
113
+ collection: 'directus_files',
114
+ field: 'uploaded_by',
115
+ related_collection: 'directus_users',
116
+ schema: {
117
+ table: 'directus_files',
118
+ column: 'uploaded_by',
119
+ foreign_key_table: 'directus_users',
120
+ foreign_key_column: 'id',
121
+ on_update: 'NO ACTION',
122
+ on_delete: 'NO ACTION',
123
+ constraint_name: null,
124
+ },
125
+ meta: {
126
+ system: true,
127
+ many_collection: 'directus_files',
128
+ many_field: 'uploaded_by',
129
+ one_collection: 'directus_users',
130
+ one_field: 'items',
131
+ one_allowed_collections: null,
132
+ one_collection_field: null,
133
+ one_deselect_action: 'nullify',
134
+ junction_field: null,
135
+ sort_field: null,
136
+ },
137
+ },
138
+ ],
139
+ };
140
+ exports.userSchema = {
141
+ collections: {
142
+ authors: {
143
+ collection: 'authors',
144
+ primary: 'id',
145
+ singleton: false,
146
+ note: 'authors',
147
+ sortField: null,
148
+ accountability: null,
149
+ fields: {
150
+ id: {
151
+ field: 'id',
152
+ defaultValue: null,
153
+ nullable: false,
154
+ generated: false,
155
+ type: 'uuid',
156
+ dbType: 'uuid',
157
+ precision: null,
158
+ scale: null,
159
+ special: [],
160
+ note: null,
161
+ alias: false,
162
+ validation: null,
163
+ },
164
+ name: {
165
+ field: 'name',
166
+ defaultValue: "An Author's Name",
167
+ nullable: false,
168
+ generated: false,
169
+ type: 'uuid',
170
+ dbType: 'uuid',
171
+ precision: null,
172
+ scale: null,
173
+ special: [],
174
+ note: null,
175
+ alias: false,
176
+ validation: null,
177
+ },
178
+ items: {
179
+ field: 'items',
180
+ defaultValue: null,
181
+ nullable: true,
182
+ generated: false,
183
+ type: 'alias',
184
+ dbType: null,
185
+ precision: null,
186
+ scale: null,
187
+ special: ['o2m'],
188
+ note: null,
189
+ alias: true,
190
+ validation: null,
191
+ },
192
+ },
193
+ },
194
+ posts: {
195
+ collection: 'posts',
196
+ primary: 'id',
197
+ singleton: false,
198
+ note: 'posts',
199
+ sortField: null,
200
+ accountability: null,
201
+ fields: {
202
+ id: {
203
+ field: 'id',
204
+ defaultValue: null,
205
+ nullable: false,
206
+ generated: false,
207
+ type: 'uuid',
208
+ dbType: 'uuid',
209
+ precision: null,
210
+ scale: null,
211
+ special: [],
212
+ note: null,
213
+ alias: false,
214
+ validation: null,
215
+ },
216
+ title: {
217
+ field: 'title',
218
+ defaultValue: "A Post's Title",
219
+ nullable: false,
220
+ generated: false,
221
+ type: 'string',
222
+ dbType: 'text',
223
+ precision: null,
224
+ scale: null,
225
+ special: [],
226
+ note: null,
227
+ alias: false,
228
+ validation: null,
229
+ },
230
+ uploaded_by: {
231
+ field: 'uploaded_by',
232
+ defaultValue: null,
233
+ nullable: true,
234
+ generated: false,
235
+ type: 'uuid',
236
+ dbType: 'uuid',
237
+ precision: null,
238
+ scale: null,
239
+ special: [],
240
+ note: null,
241
+ alias: false,
242
+ validation: null,
243
+ },
244
+ },
245
+ },
246
+ },
247
+ relations: [
248
+ {
249
+ collection: 'posts',
250
+ field: 'uploaded_by',
251
+ related_collection: 'authors',
252
+ schema: {
253
+ table: 'posts',
254
+ column: 'uploaded_by',
255
+ foreign_key_table: 'authors',
256
+ foreign_key_column: 'id',
257
+ on_update: 'NO ACTION',
258
+ on_delete: 'SET NULL',
259
+ constraint_name: null,
260
+ },
261
+ meta: {
262
+ id: 11,
263
+ many_collection: 'posts',
264
+ many_field: 'uploaded_by',
265
+ one_collection: 'authors',
266
+ one_field: 'items',
267
+ one_collection_field: null,
268
+ one_allowed_collections: null,
269
+ junction_field: null,
270
+ sort_field: null,
271
+ one_deselect_action: 'nullify',
272
+ },
273
+ },
274
+ ],
275
+ };
276
+ exports.snapshotApplyTestSchema = {
277
+ collections: {
278
+ test_table: {
279
+ collection: 'test_table',
280
+ primary: 'id',
281
+ singleton: false,
282
+ note: 'test_table',
283
+ sortField: null,
284
+ accountability: 'all',
285
+ fields: {
286
+ id: {
287
+ field: 'id',
288
+ defaultValue: null,
289
+ nullable: false,
290
+ generated: false,
291
+ type: 'uuid',
292
+ dbType: 'uuid',
293
+ precision: null,
294
+ scale: null,
295
+ special: [],
296
+ note: null,
297
+ alias: false,
298
+ validation: null,
299
+ },
300
+ },
301
+ },
302
+ },
303
+ relations: [],
304
+ };
@@ -0,0 +1,5 @@
1
+ import { Snapshot } from '../types';
2
+ export declare const snapshotBeforeCreateCollection: Snapshot;
3
+ export declare const snapshotCreateCollection: Snapshot;
4
+ export declare const snapshotCreateCollectionNotNested: Snapshot;
5
+ export declare const snapshotBeforeDeleteCollection: Snapshot;