directus 9.23.1 → 9.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/dist/app.js +25 -21
  2. package/dist/auth/auth.d.ts +3 -3
  3. package/dist/auth/auth.js +2 -0
  4. package/dist/auth/drivers/ldap.d.ts +1 -1
  5. package/dist/auth/drivers/ldap.js +57 -46
  6. package/dist/auth/drivers/local.d.ts +1 -1
  7. package/dist/auth/drivers/local.js +20 -17
  8. package/dist/auth/drivers/oauth2.d.ts +1 -1
  9. package/dist/auth/drivers/oauth2.js +44 -35
  10. package/dist/auth/drivers/openid.d.ts +1 -1
  11. package/dist/auth/drivers/openid.js +50 -41
  12. package/dist/auth/drivers/saml.d.ts +1 -1
  13. package/dist/auth/drivers/saml.js +20 -17
  14. package/dist/auth.d.ts +1 -1
  15. package/dist/auth.js +8 -7
  16. package/dist/cache.d.ts +9 -1
  17. package/dist/cache.js +66 -18
  18. package/dist/cli/commands/bootstrap/index.js +7 -6
  19. package/dist/cli/commands/init/index.js +3 -3
  20. package/dist/cli/commands/schema/apply.js +14 -15
  21. package/dist/cli/commands/schema/snapshot.js +2 -2
  22. package/dist/cli/utils/create-db-connection.d.ts +1 -1
  23. package/dist/cli/utils/create-db-connection.js +3 -2
  24. package/dist/cli/utils/create-env/index.d.ts +2 -2
  25. package/dist/cli/utils/create-env/index.js +1 -1
  26. package/dist/cli/utils/drivers.d.ts +1 -1
  27. package/dist/constants.d.ts +3 -2
  28. package/dist/constants.js +7 -7
  29. package/dist/controllers/activity.js +10 -11
  30. package/dist/controllers/assets.js +31 -25
  31. package/dist/controllers/auth.js +40 -26
  32. package/dist/controllers/collections.js +10 -10
  33. package/dist/controllers/dashboards.js +14 -11
  34. package/dist/controllers/extensions.js +3 -3
  35. package/dist/controllers/fields.js +20 -20
  36. package/dist/controllers/files.js +26 -20
  37. package/dist/controllers/flows.js +16 -13
  38. package/dist/controllers/folders.js +14 -11
  39. package/dist/controllers/graphql.js +6 -8
  40. package/dist/controllers/items.js +22 -19
  41. package/dist/controllers/not-found.d.ts +1 -1
  42. package/dist/controllers/not-found.js +1 -2
  43. package/dist/controllers/notifications.js +14 -11
  44. package/dist/controllers/operations.js +14 -11
  45. package/dist/controllers/panels.js +14 -11
  46. package/dist/controllers/permissions.js +14 -11
  47. package/dist/controllers/presets.js +14 -11
  48. package/dist/controllers/relations.js +10 -10
  49. package/dist/controllers/revisions.js +3 -3
  50. package/dist/controllers/roles.js +14 -11
  51. package/dist/controllers/schema.js +5 -5
  52. package/dist/controllers/server.js +7 -7
  53. package/dist/controllers/settings.js +2 -2
  54. package/dist/controllers/shares.js +21 -18
  55. package/dist/controllers/users.js +32 -36
  56. package/dist/controllers/utils.js +10 -15
  57. package/dist/controllers/webhooks.js +14 -11
  58. package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
  59. package/dist/database/helpers/fn/dialects/mssql.js +10 -11
  60. package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
  61. package/dist/database/helpers/fn/dialects/mysql.js +2 -3
  62. package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
  63. package/dist/database/helpers/fn/dialects/oracle.js +10 -11
  64. package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
  65. package/dist/database/helpers/fn/dialects/postgres.js +10 -11
  66. package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
  67. package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
  68. package/dist/database/helpers/fn/types.d.ts +5 -6
  69. package/dist/database/helpers/fn/types.js +4 -5
  70. package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
  71. package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
  72. package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
  73. package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
  74. package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
  75. package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
  76. package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
  77. package/dist/database/helpers/geometry/types.d.ts +2 -2
  78. package/dist/database/helpers/geometry/types.js +1 -2
  79. package/dist/database/helpers/index.d.ts +5 -5
  80. package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
  81. package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
  82. package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
  83. package/dist/database/helpers/schema/dialects/mysql.js +1 -2
  84. package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
  85. package/dist/database/helpers/schema/dialects/oracle.js +4 -6
  86. package/dist/database/helpers/schema/types.d.ts +4 -4
  87. package/dist/database/helpers/types.d.ts +1 -1
  88. package/dist/database/helpers/types.js +1 -0
  89. package/dist/database/index.d.ts +1 -1
  90. package/dist/database/index.js +13 -13
  91. package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
  92. package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
  93. package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
  94. package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
  95. package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
  96. package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
  97. package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
  98. package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
  99. package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
  100. package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
  101. package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
  102. package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
  103. package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
  104. package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
  105. package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
  106. package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
  107. package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
  108. package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
  109. package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
  110. package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
  111. package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
  112. package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
  113. package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
  114. package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
  115. package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
  116. package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
  117. package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
  118. package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
  119. package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
  120. package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
  121. package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
  122. package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
  123. package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
  124. package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
  125. package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
  126. package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
  127. package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
  128. package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
  129. package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
  130. package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
  131. package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
  132. package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
  133. package/dist/database/migrations/20211007A-update-presets.js +7 -9
  134. package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
  135. package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
  136. package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
  137. package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
  138. package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
  139. package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
  140. package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
  141. package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
  142. package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
  143. package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
  144. package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
  145. package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
  146. package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
  147. package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
  148. package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
  149. package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
  150. package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
  151. package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
  152. package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
  153. package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
  154. package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
  155. package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
  156. package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
  157. package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
  158. package/dist/database/migrations/run.d.ts +1 -1
  159. package/dist/database/migrations/run.js +1 -1
  160. package/dist/database/run-ast.d.ts +3 -3
  161. package/dist/database/run-ast.js +21 -30
  162. package/dist/database/seeds/run.d.ts +1 -1
  163. package/dist/database/seeds/run.js +1 -2
  164. package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
  165. package/dist/database/system-data/collections/index.d.ts +1 -1
  166. package/dist/database/system-data/collections/index.js +2 -2
  167. package/dist/database/system-data/fields/collections.yaml +2 -0
  168. package/dist/database/system-data/fields/index.d.ts +1 -1
  169. package/dist/database/system-data/fields/index.js +3 -4
  170. package/dist/database/system-data/fields/settings.yaml +4 -0
  171. package/dist/database/system-data/relations/index.d.ts +1 -1
  172. package/dist/emitter.d.ts +1 -1
  173. package/dist/emitter.js +3 -0
  174. package/dist/env.js +11 -3
  175. package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
  176. package/dist/exceptions/database/dialects/mssql.js +5 -6
  177. package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
  178. package/dist/exceptions/database/dialects/mysql.js +19 -25
  179. package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
  180. package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
  181. package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
  182. package/dist/exceptions/database/translate.d.ts +1 -1
  183. package/dist/exceptions/database/value-out-of-range.js +1 -1
  184. package/dist/exceptions/range-not-satisfiable.js +2 -3
  185. package/dist/extensions.d.ts +1 -1
  186. package/dist/extensions.js +43 -33
  187. package/dist/flows.js +65 -46
  188. package/dist/logger.d.ts +2 -1
  189. package/dist/logger.js +35 -19
  190. package/dist/logger.test.d.ts +1 -0
  191. package/dist/mailer.js +16 -16
  192. package/dist/messenger.js +9 -7
  193. package/dist/middleware/authenticate.d.ts +1 -1
  194. package/dist/middleware/authenticate.js +13 -6
  195. package/dist/middleware/cache.d.ts +1 -1
  196. package/dist/middleware/cache.js +16 -16
  197. package/dist/middleware/check-ip.d.ts +1 -1
  198. package/dist/middleware/check-ip.js +1 -1
  199. package/dist/middleware/collection-exists.d.ts +1 -1
  200. package/dist/middleware/collection-exists.js +5 -5
  201. package/dist/middleware/cors.d.ts +1 -1
  202. package/dist/middleware/cors.js +7 -7
  203. package/dist/middleware/error-handler.d.ts +1 -1
  204. package/dist/middleware/error-handler.js +11 -12
  205. package/dist/middleware/extract-token.d.ts +1 -1
  206. package/dist/middleware/extract-token.js +2 -2
  207. package/dist/middleware/get-permissions.d.ts +1 -1
  208. package/dist/middleware/graphql.d.ts +1 -1
  209. package/dist/middleware/graphql.js +15 -9
  210. package/dist/middleware/rate-limiter-global.d.ts +5 -0
  211. package/dist/middleware/rate-limiter-global.js +48 -0
  212. package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
  213. package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +5 -5
  214. package/dist/middleware/respond.d.ts +1 -1
  215. package/dist/middleware/respond.js +18 -19
  216. package/dist/middleware/sanitize-query.d.ts +1 -1
  217. package/dist/middleware/sanitize-query.js +1 -1
  218. package/dist/middleware/schema.d.ts +1 -1
  219. package/dist/middleware/use-collection.d.ts +1 -1
  220. package/dist/operations/condition/index.d.ts +1 -1
  221. package/dist/operations/exec/index.js +15 -4
  222. package/dist/operations/item-create/index.js +1 -2
  223. package/dist/operations/item-delete/index.d.ts +1 -1
  224. package/dist/operations/item-read/index.d.ts +1 -1
  225. package/dist/operations/item-update/index.d.ts +1 -1
  226. package/dist/operations/item-update/index.js +1 -2
  227. package/dist/operations/notification/index.js +1 -2
  228. package/dist/operations/request/index.js +19 -19
  229. package/dist/operations/trigger/index.js +2 -3
  230. package/dist/rate-limiter.d.ts +1 -1
  231. package/dist/rate-limiter.js +9 -9
  232. package/dist/request/validate-ip.js +2 -2
  233. package/dist/server.js +12 -13
  234. package/dist/services/activity.d.ts +1 -1
  235. package/dist/services/activity.js +17 -16
  236. package/dist/services/assets.d.ts +3 -3
  237. package/dist/services/assets.js +35 -37
  238. package/dist/services/authentication.d.ts +2 -2
  239. package/dist/services/authentication.js +22 -19
  240. package/dist/services/authorization.d.ts +3 -3
  241. package/dist/services/authorization.js +27 -31
  242. package/dist/services/collections.d.ts +5 -5
  243. package/dist/services/collections.js +54 -50
  244. package/dist/services/dashboards.d.ts +1 -1
  245. package/dist/services/fields.d.ts +5 -5
  246. package/dist/services/fields.js +50 -50
  247. package/dist/services/files.d.ts +1 -2
  248. package/dist/services/files.js +33 -27
  249. package/dist/services/flows.d.ts +2 -2
  250. package/dist/services/folders.d.ts +1 -1
  251. package/dist/services/graphql/index.d.ts +4 -4
  252. package/dist/services/graphql/index.js +259 -252
  253. package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
  254. package/dist/services/graphql/utils/process-error.d.ts +2 -2
  255. package/dist/services/graphql/utils/process-error.js +11 -4
  256. package/dist/services/import-export.d.ts +3 -3
  257. package/dist/services/import-export.js +30 -27
  258. package/dist/services/items.d.ts +3 -3
  259. package/dist/services/items.js +42 -36
  260. package/dist/services/mail/index.d.ts +4 -4
  261. package/dist/services/mail/index.js +14 -10
  262. package/dist/services/meta.d.ts +3 -3
  263. package/dist/services/meta.js +11 -9
  264. package/dist/services/notifications.d.ts +3 -3
  265. package/dist/services/notifications.js +10 -9
  266. package/dist/services/operations.d.ts +2 -2
  267. package/dist/services/panels.d.ts +1 -1
  268. package/dist/services/payload.d.ts +3 -3
  269. package/dist/services/payload.js +124 -122
  270. package/dist/services/permissions.d.ts +3 -3
  271. package/dist/services/permissions.js +11 -11
  272. package/dist/services/presets.d.ts +1 -1
  273. package/dist/services/relations.d.ts +6 -6
  274. package/dist/services/relations.js +45 -43
  275. package/dist/services/revisions.d.ts +1 -1
  276. package/dist/services/revisions.js +3 -3
  277. package/dist/services/roles.d.ts +2 -2
  278. package/dist/services/roles.js +7 -7
  279. package/dist/services/schema.d.ts +3 -3
  280. package/dist/services/schema.js +9 -11
  281. package/dist/services/server.d.ts +3 -3
  282. package/dist/services/server.js +88 -32
  283. package/dist/services/settings.d.ts +1 -1
  284. package/dist/services/shares.d.ts +1 -1
  285. package/dist/services/shares.js +14 -15
  286. package/dist/services/specifications.d.ts +4 -4
  287. package/dist/services/specifications.js +137 -119
  288. package/dist/services/tfa.d.ts +2 -2
  289. package/dist/services/tfa.js +7 -5
  290. package/dist/services/users.d.ts +2 -6
  291. package/dist/services/users.js +37 -40
  292. package/dist/services/utils.d.ts +3 -3
  293. package/dist/services/utils.js +10 -8
  294. package/dist/services/webhooks.d.ts +2 -2
  295. package/dist/services/webhooks.js +2 -1
  296. package/dist/storage/register-locations.js +1 -1
  297. package/dist/types/assets.d.ts +1 -1
  298. package/dist/types/ast.d.ts +1 -1
  299. package/dist/types/auth.d.ts +2 -2
  300. package/dist/types/collection.d.ts +2 -2
  301. package/dist/types/events.d.ts +2 -2
  302. package/dist/types/graphql.d.ts +2 -2
  303. package/dist/types/items.d.ts +3 -3
  304. package/dist/types/services.d.ts +5 -5
  305. package/dist/types/snapshot.d.ts +4 -4
  306. package/dist/utils/apply-diff.d.ts +3 -3
  307. package/dist/utils/apply-diff.js +25 -28
  308. package/dist/utils/apply-query.d.ts +3 -3
  309. package/dist/utils/apply-query.js +10 -12
  310. package/dist/utils/apply-snapshot.d.ts +3 -3
  311. package/dist/utils/apply-snapshot.js +5 -6
  312. package/dist/utils/construct-flow-tree.d.ts +1 -1
  313. package/dist/utils/construct-flow-tree.js +2 -2
  314. package/dist/utils/dynamic-import.js +1 -1
  315. package/dist/utils/filter-items.d.ts +1 -1
  316. package/dist/utils/generate-hash.js +1 -1
  317. package/dist/utils/get-accountability-for-role.d.ts +2 -2
  318. package/dist/utils/get-accountability-for-role.js +1 -1
  319. package/dist/utils/get-ast-from-query.d.ts +3 -3
  320. package/dist/utils/get-ast-from-query.js +22 -28
  321. package/dist/utils/get-auth-providers.js +1 -1
  322. package/dist/utils/get-cache-headers.d.ts +1 -1
  323. package/dist/utils/get-cache-headers.js +6 -7
  324. package/dist/utils/get-cache-key.d.ts +1 -1
  325. package/dist/utils/get-cache-key.js +2 -3
  326. package/dist/utils/get-collection-from-alias.d.ts +1 -1
  327. package/dist/utils/get-collection-from-alias.js +1 -0
  328. package/dist/utils/get-column-path.d.ts +2 -2
  329. package/dist/utils/get-column-path.js +3 -4
  330. package/dist/utils/get-column.d.ts +4 -4
  331. package/dist/utils/get-column.js +4 -5
  332. package/dist/utils/get-default-value.d.ts +2 -2
  333. package/dist/utils/get-default-value.js +2 -3
  334. package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
  335. package/dist/utils/get-graphql-query-and-variables.js +1 -2
  336. package/dist/utils/get-graphql-type.d.ts +2 -2
  337. package/dist/utils/get-graphql-type.js +1 -1
  338. package/dist/utils/get-ip-from-req.d.ts +1 -1
  339. package/dist/utils/get-ip-from-req.js +2 -2
  340. package/dist/utils/get-local-type.d.ts +1 -1
  341. package/dist/utils/get-local-type.js +3 -3
  342. package/dist/utils/get-milliseconds.js +1 -2
  343. package/dist/utils/get-permissions.d.ts +1 -1
  344. package/dist/utils/get-permissions.js +12 -12
  345. package/dist/utils/get-relation-info.d.ts +1 -1
  346. package/dist/utils/get-relation-info.js +3 -5
  347. package/dist/utils/get-relation-type.d.ts +1 -1
  348. package/dist/utils/get-relation-type.js +3 -4
  349. package/dist/utils/get-schema.d.ts +2 -2
  350. package/dist/utils/get-schema.js +20 -22
  351. package/dist/utils/get-snapshot-diff.js +2 -3
  352. package/dist/utils/get-snapshot.d.ts +3 -3
  353. package/dist/utils/get-snapshot.js +6 -8
  354. package/dist/utils/is-directus-jwt.js +1 -1
  355. package/dist/utils/is-url-allowed.js +5 -2
  356. package/dist/utils/job-queue.js +2 -0
  357. package/dist/utils/jwt.d.ts +1 -1
  358. package/dist/utils/merge-permissions-for-share.d.ts +1 -1
  359. package/dist/utils/merge-permissions-for-share.js +3 -4
  360. package/dist/utils/merge-permissions.d.ts +3 -3
  361. package/dist/utils/reduce-schema.d.ts +1 -1
  362. package/dist/utils/reduce-schema.js +12 -12
  363. package/dist/utils/sanitize-query.d.ts +1 -1
  364. package/dist/utils/sanitize-query.js +27 -27
  365. package/dist/utils/sanitize-schema.d.ts +2 -2
  366. package/dist/utils/should-skip-cache.d.ts +7 -0
  367. package/dist/utils/should-skip-cache.js +21 -0
  368. package/dist/utils/should-skip-cache.test.d.ts +1 -0
  369. package/dist/utils/track.js +16 -16
  370. package/dist/utils/transformations.d.ts +1 -1
  371. package/dist/utils/transformations.js +2 -4
  372. package/dist/utils/url.js +7 -2
  373. package/dist/utils/user-name.d.ts +1 -1
  374. package/dist/utils/validate-diff.js +7 -8
  375. package/dist/utils/validate-keys.d.ts +2 -2
  376. package/dist/utils/validate-keys.js +1 -1
  377. package/dist/utils/validate-query.d.ts +1 -1
  378. package/dist/utils/validate-query.js +3 -3
  379. package/dist/utils/validate-storage.js +8 -8
  380. package/dist/webhooks.js +3 -3
  381. package/package.json +36 -37
  382. package/dist/utils/with-timeout.d.ts +0 -1
  383. package/dist/utils/with-timeout.js +0 -16
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyAggregate = exports.applySearch = exports.applyFilter = exports.applyOffset = exports.applyLimit = exports.applySort = exports.generateAlias = void 0;
7
+ const utils_1 = require("@directus/shared/utils");
7
8
  const lodash_1 = require("lodash");
8
9
  const uuid_validate_1 = __importDefault(require("uuid-validate"));
9
10
  const helpers_1 = require("../database/helpers");
@@ -11,7 +12,6 @@ const invalid_query_1 = require("../exceptions/invalid-query");
11
12
  const get_column_1 = require("./get-column");
12
13
  const get_column_path_1 = require("./get-column-path");
13
14
  const get_relation_info_1 = require("./get-relation-info");
14
- const utils_1 = require("@directus/shared/utils");
15
15
  const strip_function_1 = require("./strip-function");
16
16
  // @ts-ignore
17
17
  const non_secure_1 = require("nanoid/non-secure");
@@ -20,8 +20,7 @@ exports.generateAlias = (0, non_secure_1.customAlphabet)('abcdefghijklmnopqrstuv
20
20
  * Apply the Query to a given Knex query builder instance
21
21
  */
22
22
  function applyQuery(knex, collection, dbQuery, query, schema, options) {
23
- var _a;
24
- const aliasMap = (_a = options === null || options === void 0 ? void 0 : options.aliasMap) !== null && _a !== void 0 ? _a : Object.create(null);
23
+ const aliasMap = options?.aliasMap ?? Object.create(null);
25
24
  let hasMultiRelationalFilter = false;
26
25
  applyLimit(knex, dbQuery, query.limit);
27
26
  if (query.offset) {
@@ -30,7 +29,7 @@ function applyQuery(knex, collection, dbQuery, query, schema, options) {
30
29
  if (query.page && query.limit && query.limit !== -1) {
31
30
  applyOffset(knex, dbQuery, query.limit * (query.page - 1));
32
31
  }
33
- if (query.sort && !(options === null || options === void 0 ? void 0 : options.isInnerQuery) && !(options === null || options === void 0 ? void 0 : options.hasMultiRelationalSort)) {
32
+ if (query.sort && !options?.isInnerQuery && !options?.hasMultiRelationalSort) {
34
33
  applySort(knex, schema, dbQuery, query.sort, collection, aliasMap);
35
34
  }
36
35
  if (query.search) {
@@ -54,7 +53,6 @@ function addJoin({ path, collection, aliasMap, rootQuery, schema, relations, kne
54
53
  followRelation(path);
55
54
  return hasMultiRelational;
56
55
  function followRelation(pathParts, parentCollection = collection, parentFields) {
57
- var _a, _b, _c;
58
56
  /**
59
57
  * For A2M fields, the path can contain an optional collection scope <field>:<scope>
60
58
  */
@@ -64,12 +62,12 @@ function addJoin({ path, collection, aliasMap, rootQuery, schema, relations, kne
64
62
  return;
65
63
  }
66
64
  const existingAlias = parentFields
67
- ? (_a = aliasMap[`${parentFields}.${pathParts[0]}`]) === null || _a === void 0 ? void 0 : _a.alias
68
- : (_b = aliasMap[pathParts[0]]) === null || _b === void 0 ? void 0 : _b.alias;
65
+ ? aliasMap[`${parentFields}.${pathParts[0]}`]?.alias
66
+ : aliasMap[pathParts[0]]?.alias;
69
67
  if (!existingAlias) {
70
68
  const alias = (0, exports.generateAlias)();
71
69
  const aliasKey = parentFields ? `${parentFields}.${pathParts[0]}` : pathParts[0];
72
- const aliasedParentCollection = ((_c = aliasMap[parentFields !== null && parentFields !== void 0 ? parentFields : '']) === null || _c === void 0 ? void 0 : _c.alias) || parentCollection;
70
+ const aliasedParentCollection = aliasMap[parentFields ?? '']?.alias || parentCollection;
73
71
  aliasMap[aliasKey] = { alias, collection: '' };
74
72
  if (relationType === 'm2o') {
75
73
  rootQuery.leftJoin({ [alias]: relation.related_collection }, `${aliasedParentCollection}.${relation.field}`, `${alias}.${schema.collections[relation.related_collection].primary}`);
@@ -136,7 +134,7 @@ function applySort(knex, schema, rootQuery, rootSort, collection, aliasMap, retu
136
134
  if (column.length === 1) {
137
135
  const pathRoot = column[0].split(':')[0];
138
136
  const { relation, relationType } = (0, get_relation_info_1.getRelationInfo)(relations, collection, pathRoot);
139
- if (!relation || ['m2o', 'a2o'].includes(relationType !== null && relationType !== void 0 ? relationType : '')) {
137
+ if (!relation || ['m2o', 'a2o'].includes(relationType ?? '')) {
140
138
  return {
141
139
  order,
142
140
  column: returnRecords ? column[0] : (0, get_column_1.getColumn)(knex, collection, column[0], false, schema),
@@ -173,6 +171,7 @@ function applySort(knex, schema, rootQuery, rootSort, collection, aliasMap, retu
173
171
  // Clears the order if any, eg: from MSSQL offset
174
172
  rootQuery.clear('order');
175
173
  rootQuery.orderBy(sortRecords);
174
+ return undefined;
176
175
  }
177
176
  exports.applySort = applySort;
178
177
  function applyLimit(knex, rootQuery, limit) {
@@ -225,7 +224,6 @@ function applyFilter(knex, schema, rootQuery, rootFilter, collection, aliasMap)
225
224
  }
226
225
  }
227
226
  function addWhereClauses(knex, dbQuery, filter, collection, logical = 'and') {
228
- var _a;
229
227
  for (const [key, value] of Object.entries(filter)) {
230
228
  if (key === '_or' || key === '_and') {
231
229
  // If the _or array contains an empty object (full permissions), we should short-circuit and ignore all other
@@ -267,7 +265,7 @@ function applyFilter(knex, schema, rootQuery, rootFilter, collection, aliasMap)
267
265
  .whereNotNull(column);
268
266
  applyQuery(knex, relation.collection, subQueryKnex, { filter }, schema);
269
267
  };
270
- const childKey = (_a = Object.keys(value)) === null || _a === void 0 ? void 0 : _a[0];
268
+ const childKey = Object.keys(value)?.[0];
271
269
  if (childKey === '_none') {
272
270
  dbQuery[logical].whereNotIn(pkField, subQueryBuilder(Object.values(value)[0]));
273
271
  continue;
@@ -340,7 +338,7 @@ function applyFilter(knex, schema, rootQuery, rootFilter, collection, aliasMap)
340
338
  }
341
339
  if (operator === '_nempty' || (operator === '_empty' && compareValue === false)) {
342
340
  dbQuery[logical].andWhere((query) => {
343
- query.whereNotNull(key).orWhere(key, '!=', '');
341
+ query.whereNotNull(key).andWhere(key, '!=', '');
344
342
  });
345
343
  }
346
344
  // The following fields however, require a value to be run. If no value is passed, we
@@ -1,6 +1,6 @@
1
- import { SchemaOverview } from '@directus/shared/types';
2
- import { Knex } from 'knex';
3
- import { Snapshot, SnapshotDiff } from '../types';
1
+ import type { SchemaOverview } from '@directus/shared/types';
2
+ import type { Knex } from 'knex';
3
+ import type { Snapshot, SnapshotDiff } from '../types';
4
4
  export declare function applySnapshot(snapshot: Snapshot, options?: {
5
5
  database?: Knex;
6
6
  schema?: SchemaOverview;
@@ -11,13 +11,12 @@ const get_schema_1 = require("./get-schema");
11
11
  const get_snapshot_1 = require("./get-snapshot");
12
12
  const get_snapshot_diff_1 = require("./get-snapshot-diff");
13
13
  async function applySnapshot(snapshot, options) {
14
- var _a, _b, _c, _d;
15
- const database = (_a = options === null || options === void 0 ? void 0 : options.database) !== null && _a !== void 0 ? _a : (0, database_1.default)();
16
- const schema = (_b = options === null || options === void 0 ? void 0 : options.schema) !== null && _b !== void 0 ? _b : (await (0, get_schema_1.getSchema)({ database, bypassCache: true }));
14
+ const database = options?.database ?? (0, database_1.default)();
15
+ const schema = options?.schema ?? (await (0, get_schema_1.getSchema)({ database, bypassCache: true }));
17
16
  const { systemCache } = (0, cache_1.getCache)();
18
- const current = (_c = options === null || options === void 0 ? void 0 : options.current) !== null && _c !== void 0 ? _c : (await (0, get_snapshot_1.getSnapshot)({ database, schema }));
19
- const snapshotDiff = (_d = options === null || options === void 0 ? void 0 : options.diff) !== null && _d !== void 0 ? _d : (0, get_snapshot_diff_1.getSnapshotDiff)(current, snapshot);
17
+ const current = options?.current ?? (await (0, get_snapshot_1.getSnapshot)({ database, schema }));
18
+ const snapshotDiff = options?.diff ?? (0, get_snapshot_diff_1.getSnapshotDiff)(current, snapshot);
20
19
  await (0, apply_diff_1.applyDiff)(current, snapshotDiff, { database, schema });
21
- await (systemCache === null || systemCache === void 0 ? void 0 : systemCache.clear());
20
+ await systemCache?.clear();
22
21
  }
23
22
  exports.applySnapshot = applySnapshot;
@@ -1,2 +1,2 @@
1
- import { Flow, FlowRaw } from '@directus/shared/types';
1
+ import type { Flow, FlowRaw } from '@directus/shared/types';
2
2
  export declare function constructFlowTree(flow: FlowRaw): Flow;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.constructFlowTree = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  function constructFlowTree(flow) {
6
- var _a;
7
- const rootOperation = (_a = flow.operations.find((operation) => operation.id === flow.operation)) !== null && _a !== void 0 ? _a : null;
6
+ const rootOperation = flow.operations.find((operation) => operation.id === flow.operation) ?? null;
8
7
  const operationTree = constructOperationTree(rootOperation, flow.operations);
9
8
  const flowTree = {
10
9
  ...(0, lodash_1.omit)(flow, 'operations'),
11
10
  operation: operationTree,
11
+ options: flow.options ?? {},
12
12
  };
13
13
  return flowTree;
14
14
  }
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dynamicImport = void 0;
4
4
  const dynamicImport = async (mod) => {
5
- return process.env.VITEST ? await import(mod) : require(mod);
5
+ return process.env['VITEST'] ? await import(mod) : require(mod);
6
6
  };
7
7
  exports.dynamicImport = dynamicImport;
@@ -1,2 +1,2 @@
1
- import { Query } from '@directus/shared/types';
1
+ import type { Query } from '@directus/shared/types';
2
2
  export declare function filterItems(items: Record<string, any>[], filter: Query['filter']): Record<string, any>[];
@@ -10,7 +10,7 @@ function generateHash(stringToHash) {
10
10
  const argon2HashConfigOptions = (0, get_config_from_env_1.getConfigFromEnv)('HASH_', 'HASH_RAW'); // Disallow the HASH_RAW option, see https://github.com/directus/directus/discussions/7670#discussioncomment-1255805
11
11
  // associatedData, if specified, must be passed as a Buffer to argon2.hash, see https://github.com/ranisalt/node-argon2/wiki/Options#associateddata
12
12
  'associatedData' in argon2HashConfigOptions &&
13
- (argon2HashConfigOptions.associatedData = Buffer.from(argon2HashConfigOptions.associatedData));
13
+ (argon2HashConfigOptions['associatedData'] = Buffer.from(argon2HashConfigOptions['associatedData']));
14
14
  return argon2_1.default.hash(stringToHash, argon2HashConfigOptions);
15
15
  }
16
16
  exports.generateHash = generateHash;
@@ -1,5 +1,5 @@
1
- import { Accountability, SchemaOverview } from '@directus/shared/types';
2
- import { Knex } from 'knex';
1
+ import type { Accountability, SchemaOverview } from '@directus/shared/types';
2
+ import type { Knex } from 'knex';
3
3
  export declare function getAccountabilityForRole(role: null | string, context: {
4
4
  accountability: null | Accountability;
5
5
  schema: SchemaOverview;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAccountabilityForRole = void 0;
4
- const get_permissions_1 = require("./get-permissions");
5
4
  const exceptions_1 = require("../exceptions");
5
+ const get_permissions_1 = require("./get-permissions");
6
6
  async function getAccountabilityForRole(role, context) {
7
7
  let generatedAccountability = context.accountability;
8
8
  if (role === null) {
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Generate an AST based on a given collection and query
3
3
  */
4
- import { Knex } from 'knex';
5
- import { AST } from '../types';
6
- import { Query, PermissionsAction, Accountability, SchemaOverview } from '@directus/shared/types';
4
+ import type { Accountability, PermissionsAction, Query, SchemaOverview } from '@directus/shared/types';
5
+ import type { Knex } from 'knex';
6
+ import type { AST } from '../types';
7
7
  type GetASTOptions = {
8
8
  accountability?: Accountability | null;
9
9
  action?: PermissionsAction;
@@ -3,18 +3,17 @@
3
3
  * Generate an AST based on a given collection and query
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const constants_1 = require("@directus/shared/constants");
6
7
  const lodash_1 = require("lodash");
7
8
  const get_relation_type_1 = require("../utils/get-relation-type");
8
- const constants_1 = require("@directus/shared/constants");
9
9
  async function getASTFromQuery(collection, query, schema, options) {
10
- var _a, _b, _c, _d, _e;
11
10
  query = (0, lodash_1.cloneDeep)(query);
12
- const accountability = options === null || options === void 0 ? void 0 : options.accountability;
13
- const action = (options === null || options === void 0 ? void 0 : options.action) || 'read';
11
+ const accountability = options?.accountability;
12
+ const action = options?.action || 'read';
14
13
  const permissions = accountability && accountability.admin !== true
15
- ? (_b = (_a = accountability === null || accountability === void 0 ? void 0 : accountability.permissions) === null || _a === void 0 ? void 0 : _a.filter((permission) => {
14
+ ? accountability?.permissions?.filter((permission) => {
16
15
  return permission.action === action;
17
- })) !== null && _b !== void 0 ? _b : []
16
+ }) ?? []
18
17
  : null;
19
18
  const ast = {
20
19
  type: 'root',
@@ -49,24 +48,23 @@ async function getASTFromQuery(collection, query, schema, options) {
49
48
  // We'll default to the primary key for the standard sort output
50
49
  let sortField = schema.collections[collection].primary;
51
50
  // If a custom manual sort field is configured, use that
52
- if ((_c = schema.collections[collection]) === null || _c === void 0 ? void 0 : _c.sortField) {
51
+ if (schema.collections[collection]?.sortField) {
53
52
  sortField = schema.collections[collection].sortField;
54
53
  }
55
54
  // When group by is used, default to the first column provided in the group by clause
56
- if ((_d = query.group) === null || _d === void 0 ? void 0 : _d[0]) {
55
+ if (query.group?.[0]) {
57
56
  sortField = query.group[0];
58
57
  }
59
58
  query.sort = [sortField];
60
59
  }
61
60
  // When no group by is supplied, but an aggregate function is used, only a single row will be
62
61
  // returned. In those cases, we'll ignore the sort field altogether
63
- if (query.aggregate && Object.keys(query.aggregate).length && !((_e = query.group) === null || _e === void 0 ? void 0 : _e[0])) {
62
+ if (query.aggregate && Object.keys(query.aggregate).length && !query.group?.[0]) {
64
63
  delete query.sort;
65
64
  }
66
65
  ast.children = await parseFields(collection, fields, deep);
67
66
  return ast;
68
67
  async function parseFields(parentCollection, fields, deep) {
69
- var _a, _b;
70
68
  if (!fields)
71
69
  return [];
72
70
  fields = await convertWildcards(parentCollection, fields);
@@ -85,7 +83,7 @@ async function getASTFromQuery(collection, query, schema, options) {
85
83
  const isRelational = name.includes('.') ||
86
84
  // We'll always treat top level o2m fields as a related item. This is an alias field, otherwise it won't return
87
85
  // anything
88
- !!schema.relations.find((relation) => { var _a; return relation.related_collection === parentCollection && ((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === name; });
86
+ !!schema.relations.find((relation) => relation.related_collection === parentCollection && relation.meta?.one_field === name);
89
87
  if (isRelational) {
90
88
  // field is relational
91
89
  const parts = fieldKey.split('.');
@@ -123,7 +121,7 @@ async function getASTFromQuery(collection, query, schema, options) {
123
121
  const columnName = fieldKey.match(constants_1.REGEX_BETWEEN_PARENS)[1];
124
122
  const foundField = schema.collections[parentCollection].fields[columnName];
125
123
  if (foundField && foundField.type === 'alias') {
126
- const foundRelation = schema.relations.find((relation) => { var _a; return relation.related_collection === parentCollection && ((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === columnName; });
124
+ const foundRelation = schema.relations.find((relation) => relation.related_collection === parentCollection && relation.meta?.one_field === columnName);
127
125
  if (foundRelation) {
128
126
  children.push({
129
127
  type: 'functionField',
@@ -173,8 +171,8 @@ async function getASTFromQuery(collection, query, schema, options) {
173
171
  relation: relation,
174
172
  };
175
173
  for (const relatedCollection of allowedCollections) {
176
- child.children[relatedCollection] = await parseFields(relatedCollection, Array.isArray(nestedFields) ? nestedFields : nestedFields[relatedCollection] || ['*'], deep === null || deep === void 0 ? void 0 : deep[`${fieldKey}:${relatedCollection}`]);
177
- child.query[relatedCollection] = getDeepQuery((deep === null || deep === void 0 ? void 0 : deep[`${fieldKey}:${relatedCollection}`]) || {});
174
+ child.children[relatedCollection] = await parseFields(relatedCollection, Array.isArray(nestedFields) ? nestedFields : nestedFields[relatedCollection] || [], deep?.[`${fieldKey}:${relatedCollection}`]);
175
+ child.query[relatedCollection] = getDeepQuery(deep?.[`${fieldKey}:${relatedCollection}`] || {});
178
176
  child.relatedKey[relatedCollection] = schema.collections[relatedCollection].primary;
179
177
  }
180
178
  }
@@ -183,7 +181,7 @@ async function getASTFromQuery(collection, query, schema, options) {
183
181
  continue;
184
182
  }
185
183
  // update query alias for children parseFields
186
- const deepAlias = (_a = getDeepQuery((deep === null || deep === void 0 ? void 0 : deep[fieldKey]) || {})) === null || _a === void 0 ? void 0 : _a.alias;
184
+ const deepAlias = getDeepQuery(deep?.[fieldKey] || {})?.['alias'];
187
185
  if (!(0, lodash_1.isEmpty)(deepAlias))
188
186
  query.alias = deepAlias;
189
187
  child = {
@@ -193,11 +191,11 @@ async function getASTFromQuery(collection, query, schema, options) {
193
191
  parentKey: schema.collections[parentCollection].primary,
194
192
  relatedKey: schema.collections[relatedCollection].primary,
195
193
  relation: relation,
196
- query: getDeepQuery((deep === null || deep === void 0 ? void 0 : deep[fieldKey]) || {}),
197
- children: await parseFields(relatedCollection, nestedFields, (deep === null || deep === void 0 ? void 0 : deep[fieldKey]) || {}),
194
+ query: getDeepQuery(deep?.[fieldKey] || {}),
195
+ children: await parseFields(relatedCollection, nestedFields, deep?.[fieldKey] || {}),
198
196
  };
199
197
  if (relationType === 'o2m' && !child.query.sort) {
200
- child.query.sort = [((_b = relation.meta) === null || _b === void 0 ? void 0 : _b.sort_field) || schema.collections[relation.collection].primary];
198
+ child.query.sort = [relation.meta?.sort_field || schema.collections[relation.collection].primary];
201
199
  }
202
200
  }
203
201
  if (child) {
@@ -214,12 +212,11 @@ async function getASTFromQuery(collection, query, schema, options) {
214
212
  });
215
213
  }
216
214
  async function convertWildcards(parentCollection, fields) {
217
- var _a, _b, _c;
218
215
  fields = (0, lodash_1.cloneDeep)(fields);
219
216
  const fieldsInCollection = Object.entries(schema.collections[parentCollection].fields).map(([name]) => name);
220
217
  let allowedFields = fieldsInCollection;
221
218
  if (permissions) {
222
- const permittedFields = (_a = permissions.find((permission) => parentCollection === permission.collection)) === null || _a === void 0 ? void 0 : _a.fields;
219
+ const permittedFields = permissions.find((permission) => parentCollection === permission.collection)?.fields;
223
220
  if (permittedFields !== undefined)
224
221
  allowedFields = permittedFields;
225
222
  }
@@ -233,7 +230,7 @@ async function getASTFromQuery(collection, query, schema, options) {
233
230
  if (fieldKey.includes('*') === false)
234
231
  continue;
235
232
  if (fieldKey === '*') {
236
- const aliases = Object.keys((_b = query.alias) !== null && _b !== void 0 ? _b : {});
233
+ const aliases = Object.keys(query.alias ?? {});
237
234
  // Set to all fields in collection
238
235
  if (allowedFields.includes('*')) {
239
236
  fields.splice(index, 1, ...fieldsInCollection, ...aliases);
@@ -254,13 +251,12 @@ async function getASTFromQuery(collection, query, schema, options) {
254
251
  ? schema.relations
255
252
  .filter((relation) => relation.collection === parentCollection || relation.related_collection === parentCollection)
256
253
  .map((relation) => {
257
- var _a;
258
254
  const isMany = relation.collection === parentCollection;
259
- return isMany ? relation.field : (_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field;
255
+ return isMany ? relation.field : relation.meta?.one_field;
260
256
  })
261
257
  : allowedFields.filter((fieldKey) => !!getRelation(parentCollection, fieldKey));
262
258
  const nonRelationalFields = allowedFields.filter((fieldKey) => relationalFields.includes(fieldKey) === false);
263
- const aliasFields = Object.keys((_c = query.alias) !== null && _c !== void 0 ? _c : {}).map((fieldKey) => {
259
+ const aliasFields = Object.keys(query.alias ?? {}).map((fieldKey) => {
264
260
  const name = query.alias[fieldKey];
265
261
  if (relationalFields.includes(name)) {
266
262
  return `${fieldKey}.${parts.slice(1).join('.')}`;
@@ -280,21 +276,19 @@ async function getASTFromQuery(collection, query, schema, options) {
280
276
  }
281
277
  function getRelation(collection, field) {
282
278
  const relation = schema.relations.find((relation) => {
283
- var _a;
284
279
  return ((relation.collection === collection && relation.field === field) ||
285
- (relation.related_collection === collection && ((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === field));
280
+ (relation.related_collection === collection && relation.meta?.one_field === field));
286
281
  });
287
282
  return relation;
288
283
  }
289
284
  function getRelatedCollection(collection, field) {
290
- var _a;
291
285
  const relation = getRelation(collection, field);
292
286
  if (!relation)
293
287
  return null;
294
288
  if (relation.collection === collection && relation.field === field) {
295
289
  return relation.related_collection || null;
296
290
  }
297
- if (relation.related_collection === collection && ((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === field) {
291
+ if (relation.related_collection === collection && relation.meta?.one_field === field) {
298
292
  return relation.collection || null;
299
293
  }
300
294
  return null;
@@ -7,7 +7,7 @@ exports.getAuthProviders = void 0;
7
7
  const utils_1 = require("@directus/shared/utils");
8
8
  const env_1 = __importDefault(require("../env"));
9
9
  function getAuthProviders() {
10
- return (0, utils_1.toArray)(env_1.default.AUTH_PROVIDERS)
10
+ return (0, utils_1.toArray)(env_1.default['AUTH_PROVIDERS'])
11
11
  .filter((provider) => provider && env_1.default[`AUTH_${provider.toUpperCase()}_DRIVER`])
12
12
  .map((provider) => ({
13
13
  name: provider,
@@ -1,4 +1,4 @@
1
- import { Request } from 'express';
1
+ import type { Request } from 'express';
2
2
  /**
3
3
  * Returns the Cache-Control header for the current request
4
4
  *
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getCacheControlHeader = void 0;
7
7
  const env_1 = __importDefault(require("../env"));
8
+ const should_skip_cache_1 = require("./should-skip-cache");
8
9
  /**
9
10
  * Returns the Cache-Control header for the current request
10
11
  *
@@ -14,30 +15,28 @@ const env_1 = __importDefault(require("../env"));
14
15
  * @param personalized Whether requests depend on the authentication status of users
15
16
  */
16
17
  function getCacheControlHeader(req, ttl, globalCacheSettings, personalized) {
17
- var _a, _b, _c;
18
- const noCacheRequested = ((_a = req.headers['cache-control']) === null || _a === void 0 ? void 0 : _a.includes('no-store')) || ((_b = req.headers['Cache-Control']) === null || _b === void 0 ? void 0 : _b.includes('no-store'));
19
18
  // When the user explicitly asked to skip the cache
20
- if (noCacheRequested)
19
+ if ((0, should_skip_cache_1.shouldSkipCache)(req))
21
20
  return 'no-store';
22
21
  // When the resource / current request shouldn't be cached
23
22
  if (ttl === undefined || ttl < 0)
24
23
  return 'no-cache';
25
24
  // When the API cache can invalidate at any moment
26
- if (globalCacheSettings && env_1.default.CACHE_AUTO_PURGE === true)
25
+ if (globalCacheSettings && env_1.default['CACHE_AUTO_PURGE'] === true)
27
26
  return 'no-cache';
28
27
  const headerValues = [];
29
28
  // When caching depends on the authentication status of the users
30
29
  if (personalized) {
31
30
  // Allow response to be stored in shared cache (public) or local cache only (private)
32
- const access = !!((_c = req.accountability) === null || _c === void 0 ? void 0 : _c.role) === false ? 'public' : 'private';
31
+ const access = !!req.accountability?.role === false ? 'public' : 'private';
33
32
  headerValues.push(access);
34
33
  }
35
34
  // Cache control header uses seconds for everything
36
35
  const ttlSeconds = Math.round(ttl / 1000);
37
36
  headerValues.push(`max-age=${ttlSeconds}`);
38
37
  // When the s-maxage flag should be included
39
- if (globalCacheSettings && Number.isInteger(env_1.default.CACHE_CONTROL_S_MAXAGE) && env_1.default.CACHE_CONTROL_S_MAXAGE >= 0) {
40
- headerValues.push(`s-maxage=${env_1.default.CACHE_CONTROL_S_MAXAGE}`);
38
+ if (globalCacheSettings && Number.isInteger(env_1.default['CACHE_CONTROL_S_MAXAGE']) && env_1.default['CACHE_CONTROL_S_MAXAGE'] >= 0) {
39
+ headerValues.push(`s-maxage=${env_1.default['CACHE_CONTROL_S_MAXAGE']}`);
41
40
  }
42
41
  return headerValues.join(', ');
43
42
  }
@@ -1,2 +1,2 @@
1
- import { Request } from 'express';
1
+ import type { Request } from 'express';
2
2
  export declare function getCacheKey(req: Request): string;
@@ -8,11 +8,10 @@ const object_hash_1 = __importDefault(require("object-hash"));
8
8
  const url_1 = __importDefault(require("url"));
9
9
  const get_graphql_query_and_variables_1 = require("./get-graphql-query-and-variables");
10
10
  function getCacheKey(req) {
11
- var _a;
12
11
  const path = url_1.default.parse(req.originalUrl).pathname;
13
- const isGraphQl = path === null || path === void 0 ? void 0 : path.startsWith('/graphql');
12
+ const isGraphQl = path?.startsWith('/graphql');
14
13
  const info = {
15
- user: ((_a = req.accountability) === null || _a === void 0 ? void 0 : _a.user) || null,
14
+ user: req.accountability?.user || null,
16
15
  path,
17
16
  query: isGraphQl ? (0, get_graphql_query_and_variables_1.getGraphqlQueryAndVariables)(req) : req.sanitizedQuery,
18
17
  };
@@ -1,4 +1,4 @@
1
- import { AliasMap } from './get-column-path';
1
+ import type { AliasMap } from './get-column-path';
2
2
  /**
3
3
  * Extract the collection of an alias within an aliasMap
4
4
  * For example: 'ljnsv.name' -> 'authors'
@@ -11,5 +11,6 @@ function getCollectionFromAlias(alias, aliasMap) {
11
11
  return aliasValue.collection;
12
12
  }
13
13
  }
14
+ return undefined;
14
15
  }
15
16
  exports.getCollectionFromAlias = getCollectionFromAlias;
@@ -1,4 +1,4 @@
1
- import { Relation, SchemaOverview } from '@directus/shared/types';
1
+ import type { Relation, SchemaOverview } from '@directus/shared/types';
2
2
  export type AliasMap = {
3
3
  [key: string]: {
4
4
  alias: string;
@@ -15,7 +15,7 @@ export type ColPathProps = {
15
15
  export type ColPathResult = {
16
16
  columnPath: string;
17
17
  targetCollection: string;
18
- addNestedPkField?: string;
18
+ addNestedPkField: string | undefined;
19
19
  };
20
20
  /**
21
21
  * Converts a Directus field list path to the correct SQL names based on the constructed alias map.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getColumnPath = void 0;
4
- const get_relation_info_1 = require("./get-relation-info");
5
4
  const exceptions_1 = require("../exceptions");
5
+ const get_relation_info_1 = require("./get-relation-info");
6
6
  /**
7
7
  * Converts a Directus field list path to the correct SQL names based on the constructed alias map.
8
8
  * For example: ['author', 'role', 'name'] -> 'ljnsv.name'
@@ -12,7 +12,6 @@ const exceptions_1 = require("../exceptions");
12
12
  function getColumnPath({ path, collection, aliasMap, relations, schema }) {
13
13
  return followRelation(path);
14
14
  function followRelation(pathParts, parentCollection = collection, parentFields, addNestedPkField) {
15
- var _a, _b, _c, _d;
16
15
  /**
17
16
  * For A2M fields, the path can contain an optional collection scope <field>:<scope>
18
17
  */
@@ -21,7 +20,7 @@ function getColumnPath({ path, collection, aliasMap, relations, schema }) {
21
20
  if (!relation) {
22
21
  throw new exceptions_1.InvalidQueryException(`"${parentCollection}.${pathRoot}" is not a relational field`);
23
22
  }
24
- const alias = parentFields ? (_a = aliasMap[`${parentFields}.${pathParts[0]}`]) === null || _a === void 0 ? void 0 : _a.alias : (_b = aliasMap[pathParts[0]]) === null || _b === void 0 ? void 0 : _b.alias;
23
+ const alias = parentFields ? aliasMap[`${parentFields}.${pathParts[0]}`]?.alias : aliasMap[pathParts[0]]?.alias;
25
24
  const remainingParts = pathParts.slice(1);
26
25
  let parent;
27
26
  if (relationType === 'a2o') {
@@ -38,7 +37,7 @@ function getColumnPath({ path, collection, aliasMap, relations, schema }) {
38
37
  parent = relation.collection;
39
38
  }
40
39
  // Top level alias field
41
- if (schema && !(((_c = remainingParts[0]) !== null && _c !== void 0 ? _c : parent).includes('(') && ((_d = remainingParts[0]) !== null && _d !== void 0 ? _d : parent).includes(')'))) {
40
+ if (schema && !((remainingParts[0] ?? parent).includes('(') && (remainingParts[0] ?? parent).includes(')'))) {
42
41
  if (remainingParts.length === 0) {
43
42
  remainingParts.push(schema.collections[parent].primary);
44
43
  addNestedPkField = schema.collections[parent].primary;
@@ -1,8 +1,8 @@
1
- import { Query, SchemaOverview } from '@directus/shared/types';
2
- import { Knex } from 'knex';
1
+ import type { Query, SchemaOverview } from '@directus/shared/types';
2
+ import type { Knex } from 'knex';
3
3
  type GetColumnOptions = {
4
- query?: Query;
5
- originalCollectionName?: string;
4
+ query?: Query | undefined;
5
+ originalCollectionName?: string | undefined;
6
6
  };
7
7
  /**
8
8
  * Return column prefixed by table. If column includes functions (like `year(date_created)`), the
@@ -19,22 +19,21 @@ const apply_function_to_column_name_1 = require("./apply-function-to-column-name
19
19
  * @returns Knex raw instance
20
20
  */
21
21
  function getColumn(knex, table, column, alias = (0, apply_function_to_column_name_1.applyFunctionToColumnName)(column), schema, options) {
22
- var _a, _b, _c, _d;
23
22
  const fn = (0, helpers_1.getFunctions)(knex, schema);
24
23
  if (column.includes('(') && column.includes(')')) {
25
24
  const functionName = column.split('(')[0];
26
25
  const columnName = column.match(constants_1.REGEX_BETWEEN_PARENS)[1];
27
26
  if (functionName in fn) {
28
- const collectionName = (options === null || options === void 0 ? void 0 : options.originalCollectionName) || table;
29
- const type = (_d = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.collections[collectionName]) === null || _a === void 0 ? void 0 : _a.fields) === null || _b === void 0 ? void 0 : _b[columnName]) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : 'unknown';
27
+ const collectionName = options?.originalCollectionName || table;
28
+ const type = schema?.collections[collectionName]?.fields?.[columnName]?.type ?? 'unknown';
30
29
  const allowedFunctions = (0, utils_1.getFunctionsForType)(type);
31
30
  if (allowedFunctions.includes(functionName) === false) {
32
31
  throw new exceptions_1.InvalidQueryException(`Invalid function specified "${functionName}"`);
33
32
  }
34
33
  const result = fn[functionName](table, columnName, {
35
34
  type,
36
- query: options === null || options === void 0 ? void 0 : options.query,
37
- originalCollectionName: options === null || options === void 0 ? void 0 : options.originalCollectionName,
35
+ query: options?.query,
36
+ originalCollectionName: options?.originalCollectionName,
38
37
  });
39
38
  if (alias) {
40
39
  return knex.raw(result + ' AS ??', [alias]);
@@ -1,3 +1,3 @@
1
- import { SchemaOverview } from '@directus/schema/types/overview';
2
- import { Column } from 'knex-schema-inspector/dist/types/column';
1
+ import type { SchemaOverview } from '@directus/schema/types/overview';
2
+ import type { Column } from 'knex-schema-inspector/dist/types/column';
3
3
  export default function getDefaultValue(column: SchemaOverview[string]['columns'][string] | Column): string | boolean | number | Record<string, any> | any[] | null;
@@ -8,9 +8,8 @@ const env_1 = __importDefault(require("../env"));
8
8
  const logger_1 = __importDefault(require("../logger"));
9
9
  const get_local_type_1 = __importDefault(require("./get-local-type"));
10
10
  function getDefaultValue(column) {
11
- var _a;
12
11
  const type = (0, get_local_type_1.default)(column);
13
- const defaultValue = (_a = column.default_value) !== null && _a !== void 0 ? _a : null;
12
+ const defaultValue = column.default_value ?? null;
14
13
  if (defaultValue === null)
15
14
  return null;
16
15
  if (defaultValue === '0000-00-00 00:00:00')
@@ -53,7 +52,7 @@ function castToObject(value) {
53
52
  return (0, utils_1.parseJSON)(value);
54
53
  }
55
54
  catch (err) {
56
- if (env_1.default.NODE_ENV === 'development') {
55
+ if (env_1.default['NODE_ENV'] === 'development') {
57
56
  logger_1.default.error(err);
58
57
  }
59
58
  return value;
@@ -1,2 +1,2 @@
1
- import { Request } from 'express';
1
+ import type { Request } from 'express';
2
2
  export declare function getGraphqlQueryAndVariables(req: Request): Pick<any, "query" | "variables">;
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGraphqlQueryAndVariables = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  function getGraphqlQueryAndVariables(req) {
6
- var _a;
7
- const isGet = ((_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'get';
6
+ const isGet = req.method?.toLowerCase() === 'get';
8
7
  return (0, lodash_1.pick)(isGet ? req.query : req.body, ['query', 'variables']);
9
8
  }
10
9
  exports.getGraphqlQueryAndVariables = getGraphqlQueryAndVariables;
@@ -1,3 +1,3 @@
1
- import { GraphQLScalarType, GraphQLList, GraphQLType } from 'graphql';
2
- import { Type } from '@directus/shared/types';
1
+ import type { Type } from '@directus/shared/types';
2
+ import { GraphQLList, GraphQLScalarType, GraphQLType } from 'graphql';
3
3
  export declare function getGraphQLType(localType: Type | 'alias' | 'unknown', special: string[]): GraphQLScalarType | GraphQLList<GraphQLType>;