directus 9.22.4 → 9.23.3

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 (404) hide show
  1. package/dist/app.js +19 -14
  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 +2 -2
  5. package/dist/auth/drivers/ldap.js +47 -36
  6. package/dist/auth/drivers/local.d.ts +1 -1
  7. package/dist/auth/drivers/local.js +13 -10
  8. package/dist/auth/drivers/oauth2.d.ts +1 -1
  9. package/dist/auth/drivers/oauth2.js +22 -15
  10. package/dist/auth/drivers/openid.d.ts +1 -1
  11. package/dist/auth/drivers/openid.js +23 -16
  12. package/dist/auth/drivers/saml.d.ts +1 -1
  13. package/dist/auth/drivers/saml.js +10 -7
  14. package/dist/auth.d.ts +1 -1
  15. package/dist/auth.js +4 -4
  16. package/dist/cache.d.ts +9 -1
  17. package/dist/cache.js +59 -16
  18. package/dist/cli/commands/bootstrap/index.js +2 -2
  19. package/dist/cli/commands/init/index.js +3 -3
  20. package/dist/cli/commands/schema/apply.js +21 -20
  21. package/dist/cli/commands/schema/snapshot.js +2 -2
  22. package/dist/cli/utils/create-db-connection.d.ts +2 -1
  23. package/dist/cli/utils/create-db-connection.js +2 -1
  24. package/dist/cli/utils/create-env/env-stub.liquid +1 -1
  25. package/dist/cli/utils/create-env/index.d.ts +2 -2
  26. package/dist/cli/utils/drivers.d.ts +3 -9
  27. package/dist/constants.d.ts +3 -9
  28. package/dist/constants.js +5 -10
  29. package/dist/controllers/activity.js +1 -2
  30. package/dist/controllers/assets.js +17 -12
  31. package/dist/controllers/auth.js +29 -15
  32. package/dist/controllers/dashboards.js +5 -2
  33. package/dist/controllers/extensions.js +7 -7
  34. package/dist/controllers/fields.js +4 -4
  35. package/dist/controllers/files.js +11 -6
  36. package/dist/controllers/flows.js +5 -2
  37. package/dist/controllers/folders.js +5 -2
  38. package/dist/controllers/graphql.js +6 -0
  39. package/dist/controllers/items.js +5 -2
  40. package/dist/controllers/not-found.d.ts +1 -1
  41. package/dist/controllers/not-found.js +1 -2
  42. package/dist/controllers/notifications.js +5 -2
  43. package/dist/controllers/operations.js +5 -2
  44. package/dist/controllers/panels.js +5 -2
  45. package/dist/controllers/permissions.js +5 -2
  46. package/dist/controllers/presets.js +5 -2
  47. package/dist/controllers/roles.js +5 -2
  48. package/dist/controllers/schema.d.ts +2 -0
  49. package/dist/controllers/schema.js +98 -0
  50. package/dist/controllers/shares.js +8 -5
  51. package/dist/controllers/users.js +16 -20
  52. package/dist/controllers/utils.js +6 -11
  53. package/dist/controllers/webhooks.js +5 -2
  54. package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
  55. package/dist/database/helpers/fn/dialects/mssql.js +10 -11
  56. package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
  57. package/dist/database/helpers/fn/dialects/mysql.js +2 -3
  58. package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
  59. package/dist/database/helpers/fn/dialects/oracle.js +10 -11
  60. package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
  61. package/dist/database/helpers/fn/dialects/postgres.js +10 -11
  62. package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
  63. package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
  64. package/dist/database/helpers/fn/types.d.ts +5 -5
  65. package/dist/database/helpers/fn/types.js +5 -4
  66. package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
  67. package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
  68. package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
  69. package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
  70. package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
  71. package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
  72. package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
  73. package/dist/database/helpers/geometry/types.d.ts +2 -2
  74. package/dist/database/helpers/geometry/types.js +1 -2
  75. package/dist/database/helpers/index.d.ts +5 -5
  76. package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +2 -2
  77. package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
  78. package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
  79. package/dist/database/helpers/schema/dialects/mysql.js +1 -2
  80. package/dist/database/helpers/schema/dialects/oracle.d.ts +5 -2
  81. package/dist/database/helpers/schema/dialects/oracle.js +23 -0
  82. package/dist/database/helpers/schema/types.d.ts +9 -7
  83. package/dist/database/helpers/schema/types.js +7 -1
  84. package/dist/database/helpers/types.d.ts +1 -1
  85. package/dist/database/helpers/types.js +1 -0
  86. package/dist/database/index.d.ts +2 -1
  87. package/dist/database/index.js +8 -8
  88. package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
  89. package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
  90. package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
  91. package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
  92. package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
  93. package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
  94. package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
  95. package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
  96. package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
  97. package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
  98. package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
  99. package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
  100. package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
  101. package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
  102. package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
  103. package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
  104. package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
  105. package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
  106. package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
  107. package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
  108. package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
  109. package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
  110. package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
  111. package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
  112. package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
  113. package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
  114. package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
  115. package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
  116. package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
  117. package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
  118. package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
  119. package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
  120. package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
  121. package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
  122. package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
  123. package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
  124. package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
  125. package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
  126. package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
  127. package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
  128. package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
  129. package/dist/database/migrations/20211007A-update-presets.js +7 -9
  130. package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
  131. package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
  132. package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
  133. package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
  134. package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
  135. package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
  136. package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
  137. package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
  138. package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
  139. package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
  140. package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
  141. package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
  142. package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
  143. package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
  144. package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
  145. package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
  146. package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
  147. package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
  148. package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
  149. package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
  150. package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
  151. package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
  152. package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
  153. package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
  154. package/dist/database/migrations/run.d.ts +1 -1
  155. package/dist/database/run-ast.d.ts +3 -3
  156. package/dist/database/run-ast.js +19 -28
  157. package/dist/database/seeds/run.d.ts +1 -1
  158. package/dist/database/seeds/run.js +1 -2
  159. package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
  160. package/dist/database/system-data/collections/index.d.ts +1 -1
  161. package/dist/database/system-data/fields/collections.yaml +2 -0
  162. package/dist/database/system-data/fields/index.d.ts +1 -1
  163. package/dist/database/system-data/fields/index.js +1 -2
  164. package/dist/database/system-data/fields/settings.yaml +4 -0
  165. package/dist/database/system-data/relations/index.d.ts +1 -1
  166. package/dist/emitter.d.ts +1 -1
  167. package/dist/emitter.js +3 -0
  168. package/dist/env.js +19 -4
  169. package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
  170. package/dist/exceptions/database/dialects/mssql.js +5 -6
  171. package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
  172. package/dist/exceptions/database/dialects/mysql.js +19 -25
  173. package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
  174. package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
  175. package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
  176. package/dist/exceptions/database/translate.d.ts +1 -1
  177. package/dist/exceptions/database/value-out-of-range.js +1 -1
  178. package/dist/exceptions/range-not-satisfiable.js +2 -3
  179. package/dist/extensions.d.ts +1 -1
  180. package/dist/extensions.js +34 -24
  181. package/dist/flows.js +56 -30
  182. package/dist/logger.d.ts +1 -1
  183. package/dist/logger.js +19 -3
  184. package/dist/messenger.js +8 -6
  185. package/dist/middleware/authenticate.d.ts +1 -1
  186. package/dist/middleware/authenticate.js +12 -5
  187. package/dist/middleware/cache.d.ts +1 -1
  188. package/dist/middleware/cache.js +7 -7
  189. package/dist/middleware/check-ip.d.ts +1 -1
  190. package/dist/middleware/check-ip.js +1 -1
  191. package/dist/middleware/collection-exists.d.ts +1 -1
  192. package/dist/middleware/collection-exists.js +2 -2
  193. package/dist/middleware/cors.d.ts +1 -1
  194. package/dist/middleware/error-handler.d.ts +1 -1
  195. package/dist/middleware/error-handler.js +9 -10
  196. package/dist/middleware/extract-token.d.ts +1 -1
  197. package/dist/middleware/get-permissions.d.ts +1 -1
  198. package/dist/middleware/graphql.d.ts +1 -1
  199. package/dist/middleware/graphql.js +3 -3
  200. package/dist/middleware/rate-limiter-global.d.ts +5 -0
  201. package/dist/middleware/rate-limiter-global.js +48 -0
  202. package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
  203. package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +3 -3
  204. package/dist/middleware/respond.d.ts +1 -1
  205. package/dist/middleware/respond.js +18 -14
  206. package/dist/middleware/sanitize-query.d.ts +1 -1
  207. package/dist/middleware/schema.d.ts +1 -1
  208. package/dist/middleware/use-collection.d.ts +1 -1
  209. package/dist/operations/condition/index.d.ts +1 -1
  210. package/dist/operations/exec/index.js +14 -3
  211. package/dist/operations/item-create/index.js +1 -2
  212. package/dist/operations/item-delete/index.d.ts +1 -1
  213. package/dist/operations/item-read/index.d.ts +1 -1
  214. package/dist/operations/item-update/index.d.ts +1 -1
  215. package/dist/operations/item-update/index.js +1 -2
  216. package/dist/operations/notification/index.js +1 -2
  217. package/dist/operations/request/index.js +21 -20
  218. package/dist/operations/trigger/index.d.ts +2 -0
  219. package/dist/operations/trigger/index.js +27 -11
  220. package/dist/rate-limiter.d.ts +1 -1
  221. package/dist/rate-limiter.js +8 -8
  222. package/dist/request/index.d.ts +5 -0
  223. package/dist/request/index.js +18 -0
  224. package/dist/request/index.test.d.ts +1 -0
  225. package/dist/request/request-interceptor.d.ts +2 -0
  226. package/dist/request/request-interceptor.js +33 -0
  227. package/dist/request/request-interceptor.test.d.ts +1 -0
  228. package/dist/request/response-interceptor.d.ts +2 -0
  229. package/dist/request/response-interceptor.js +9 -0
  230. package/dist/request/response-interceptor.test.d.ts +1 -0
  231. package/dist/request/validate-ip.d.ts +1 -0
  232. package/dist/request/validate-ip.js +27 -0
  233. package/dist/request/validate-ip.test.d.ts +1 -0
  234. package/dist/server.js +8 -9
  235. package/dist/services/activity.d.ts +1 -1
  236. package/dist/services/activity.js +7 -6
  237. package/dist/services/assets.d.ts +3 -3
  238. package/dist/services/assets.js +33 -26
  239. package/dist/services/authentication.d.ts +2 -2
  240. package/dist/services/authentication.js +18 -15
  241. package/dist/services/authorization.d.ts +3 -3
  242. package/dist/services/authorization.js +27 -31
  243. package/dist/services/collections.d.ts +5 -5
  244. package/dist/services/collections.js +52 -48
  245. package/dist/services/dashboards.d.ts +1 -1
  246. package/dist/services/fields.d.ts +5 -5
  247. package/dist/services/fields.js +49 -48
  248. package/dist/services/files.d.ts +1 -2
  249. package/dist/services/files.js +70 -108
  250. package/dist/services/flows.d.ts +2 -2
  251. package/dist/services/folders.d.ts +1 -1
  252. package/dist/services/graphql/index.d.ts +4 -4
  253. package/dist/services/graphql/index.js +181 -170
  254. package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
  255. package/dist/services/graphql/utils/process-error.d.ts +2 -2
  256. package/dist/services/graphql/utils/process-error.js +29 -9
  257. package/dist/services/import-export.d.ts +7 -5
  258. package/dist/services/import-export.js +41 -24
  259. package/dist/services/import-export.test.d.ts +1 -0
  260. package/dist/services/index.d.ts +1 -0
  261. package/dist/services/index.js +1 -0
  262. package/dist/services/items.d.ts +3 -3
  263. package/dist/services/items.js +67 -42
  264. package/dist/services/mail/index.d.ts +4 -4
  265. package/dist/services/mail/index.js +9 -5
  266. package/dist/services/meta.d.ts +3 -3
  267. package/dist/services/meta.js +10 -9
  268. package/dist/services/notifications.d.ts +3 -3
  269. package/dist/services/notifications.js +7 -6
  270. package/dist/services/operations.d.ts +2 -2
  271. package/dist/services/panels.d.ts +1 -1
  272. package/dist/services/payload.d.ts +3 -3
  273. package/dist/services/payload.js +124 -122
  274. package/dist/services/permissions.d.ts +3 -3
  275. package/dist/services/permissions.js +11 -11
  276. package/dist/services/presets.d.ts +1 -1
  277. package/dist/services/relations.d.ts +6 -6
  278. package/dist/services/relations.js +47 -43
  279. package/dist/services/revisions.d.ts +1 -1
  280. package/dist/services/roles.d.ts +2 -2
  281. package/dist/services/roles.js +34 -13
  282. package/dist/services/schema.d.ts +15 -0
  283. package/dist/services/schema.js +56 -0
  284. package/dist/services/schema.test.d.ts +1 -0
  285. package/dist/services/server.d.ts +3 -3
  286. package/dist/services/server.js +69 -13
  287. package/dist/services/settings.d.ts +1 -1
  288. package/dist/services/shares.d.ts +2 -2
  289. package/dist/services/shares.js +14 -15
  290. package/dist/services/specifications.d.ts +4 -4
  291. package/dist/services/specifications.js +132 -116
  292. package/dist/services/tfa.d.ts +2 -2
  293. package/dist/services/tfa.js +7 -5
  294. package/dist/services/users.d.ts +3 -3
  295. package/dist/services/users.js +89 -62
  296. package/dist/services/utils.d.ts +3 -3
  297. package/dist/services/utils.js +10 -8
  298. package/dist/services/webhooks.d.ts +2 -2
  299. package/dist/services/webhooks.js +2 -1
  300. package/dist/types/assets.d.ts +2 -2
  301. package/dist/types/ast.d.ts +1 -1
  302. package/dist/types/auth.d.ts +2 -2
  303. package/dist/types/collection.d.ts +2 -2
  304. package/dist/types/database.d.ts +3 -0
  305. package/dist/types/database.js +4 -0
  306. package/dist/types/events.d.ts +2 -2
  307. package/dist/types/graphql.d.ts +2 -2
  308. package/dist/types/index.d.ts +1 -0
  309. package/dist/types/index.js +1 -0
  310. package/dist/types/items.d.ts +7 -2
  311. package/dist/types/services.d.ts +5 -5
  312. package/dist/types/snapshot.d.ts +25 -3
  313. package/dist/types/snapshot.js +14 -0
  314. package/dist/utils/apply-diff.d.ts +9 -0
  315. package/dist/utils/apply-diff.js +256 -0
  316. package/dist/utils/apply-diff.test.d.ts +1 -0
  317. package/dist/utils/apply-query.d.ts +3 -3
  318. package/dist/utils/apply-query.js +15 -16
  319. package/dist/utils/apply-snapshot.d.ts +3 -5
  320. package/dist/utils/apply-snapshot.js +9 -240
  321. package/dist/utils/construct-flow-tree.d.ts +1 -1
  322. package/dist/utils/construct-flow-tree.js +2 -2
  323. package/dist/utils/filter-items.d.ts +1 -1
  324. package/dist/utils/get-accountability-for-role.d.ts +2 -2
  325. package/dist/utils/get-accountability-for-role.js +1 -1
  326. package/dist/utils/get-ast-from-query.d.ts +3 -3
  327. package/dist/utils/get-ast-from-query.js +22 -28
  328. package/dist/utils/get-cache-headers.d.ts +4 -2
  329. package/dist/utils/get-cache-headers.js +21 -21
  330. package/dist/utils/get-cache-headers.test.d.ts +1 -0
  331. package/dist/utils/get-cache-key.d.ts +1 -1
  332. package/dist/utils/get-cache-key.js +2 -3
  333. package/dist/utils/get-collection-from-alias.d.ts +1 -1
  334. package/dist/utils/get-column-path.d.ts +2 -2
  335. package/dist/utils/get-column-path.js +3 -4
  336. package/dist/utils/get-column.d.ts +4 -4
  337. package/dist/utils/get-column.js +4 -5
  338. package/dist/utils/get-default-value.d.ts +2 -2
  339. package/dist/utils/get-default-value.js +1 -2
  340. package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
  341. package/dist/utils/get-graphql-query-and-variables.js +1 -2
  342. package/dist/utils/get-graphql-type.d.ts +2 -2
  343. package/dist/utils/get-graphql-type.js +1 -1
  344. package/dist/utils/get-ip-from-req.d.ts +1 -1
  345. package/dist/utils/get-local-type.d.ts +1 -1
  346. package/dist/utils/get-local-type.js +3 -3
  347. package/dist/utils/get-milliseconds.d.ts +4 -0
  348. package/dist/utils/get-milliseconds.js +14 -0
  349. package/dist/utils/get-milliseconds.test.d.ts +1 -0
  350. package/dist/utils/get-permissions.d.ts +1 -1
  351. package/dist/utils/get-permissions.js +1 -1
  352. package/dist/utils/get-relation-info.d.ts +1 -1
  353. package/dist/utils/get-relation-info.js +3 -5
  354. package/dist/utils/get-relation-type.d.ts +1 -1
  355. package/dist/utils/get-relation-type.js +3 -4
  356. package/dist/utils/get-schema.d.ts +2 -2
  357. package/dist/utils/get-schema.js +19 -21
  358. package/dist/utils/get-snapshot-diff.js +10 -7
  359. package/dist/utils/get-snapshot.d.ts +3 -3
  360. package/dist/utils/get-snapshot.js +35 -14
  361. package/dist/utils/get-versioned-hash.d.ts +1 -0
  362. package/dist/utils/get-versioned-hash.js +12 -0
  363. package/dist/utils/get-versioned-hash.test.d.ts +1 -0
  364. package/dist/utils/is-directus-jwt.js +1 -1
  365. package/dist/utils/job-queue.js +2 -0
  366. package/dist/utils/jwt.d.ts +1 -1
  367. package/dist/utils/map-values-deep.d.ts +1 -0
  368. package/dist/utils/map-values-deep.js +29 -0
  369. package/dist/utils/map-values-deep.test.d.ts +1 -0
  370. package/dist/utils/merge-permissions-for-share.d.ts +1 -1
  371. package/dist/utils/merge-permissions-for-share.js +3 -4
  372. package/dist/utils/merge-permissions.d.ts +3 -3
  373. package/dist/utils/redact-header-cookies.d.ts +1 -0
  374. package/dist/utils/redact-header-cookies.js +11 -0
  375. package/dist/utils/redact-header-cookies.test.d.ts +1 -0
  376. package/dist/utils/reduce-schema.d.ts +1 -1
  377. package/dist/utils/reduce-schema.js +12 -12
  378. package/dist/utils/sanitize-query.d.ts +1 -1
  379. package/dist/utils/sanitize-query.js +1 -1
  380. package/dist/utils/sanitize-schema.d.ts +30 -0
  381. package/dist/utils/sanitize-schema.js +80 -0
  382. package/dist/utils/sanitize-schema.test.d.ts +1 -0
  383. package/dist/utils/should-skip-cache.d.ts +7 -0
  384. package/dist/utils/should-skip-cache.js +21 -0
  385. package/dist/utils/should-skip-cache.test.d.ts +1 -0
  386. package/dist/utils/track.js +3 -3
  387. package/dist/utils/transformations.d.ts +1 -1
  388. package/dist/utils/transformations.js +2 -4
  389. package/dist/utils/url.js +9 -8
  390. package/dist/utils/url.test.d.ts +1 -0
  391. package/dist/utils/user-name.d.ts +1 -1
  392. package/dist/utils/validate-diff.d.ts +7 -0
  393. package/dist/utils/validate-diff.js +113 -0
  394. package/dist/utils/validate-diff.test.d.ts +1 -0
  395. package/dist/utils/validate-keys.d.ts +2 -2
  396. package/dist/utils/validate-keys.js +1 -1
  397. package/dist/utils/validate-query.d.ts +1 -1
  398. package/dist/utils/validate-query.js +3 -3
  399. package/dist/utils/validate-query.test.d.ts +1 -0
  400. package/dist/utils/validate-snapshot.d.ts +5 -0
  401. package/dist/utils/validate-snapshot.js +71 -0
  402. package/dist/utils/validate-snapshot.test.d.ts +1 -0
  403. package/dist/webhooks.js +4 -3
  404. package/package.json +62 -62
package/dist/env.js CHANGED
@@ -28,6 +28,7 @@ const allowedEnvironmentVars = [
28
28
  'SERVE_APP',
29
29
  'GRAPHQL_INTROSPECTION',
30
30
  'LOGGER_.+',
31
+ 'ROBOTS_TXT',
31
32
  // server
32
33
  'SERVER_.+',
33
34
  // database
@@ -61,6 +62,7 @@ const allowedEnvironmentVars = [
61
62
  'CORS_CREDENTIALS',
62
63
  'CORS_MAX_AGE',
63
64
  // rate limiting
65
+ 'RATE_LIMITER_GLOBAL_.+',
64
66
  'RATE_LIMITER_.+',
65
67
  // cache
66
68
  'CACHE_ENABLED',
@@ -79,6 +81,7 @@ const allowedEnvironmentVars = [
79
81
  'CACHE_REDIS_PASSWORD',
80
82
  'CACHE_MEMCACHE',
81
83
  'CACHE_VALUE_MAX_SIZE',
84
+ 'CACHE_SKIP_ALLOWED',
82
85
  'CACHE_HEALTHCHECK_THRESHOLD',
83
86
  // storage
84
87
  'STORAGE_LOCATIONS',
@@ -105,6 +108,7 @@ const allowedEnvironmentVars = [
105
108
  'ASSETS_TRANSFORM_MAX_CONCURRENT',
106
109
  'ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION',
107
110
  'ASSETS_TRANSFORM_MAX_OPERATIONS',
111
+ 'ASSETS_TRANSFORM_TIMEOUT',
108
112
  'ASSETS_CONTENT_SECURITY_POLICY',
109
113
  'ASSETS_INVALID_IMAGE_SENSITIVITY_LEVEL',
110
114
  // auth
@@ -143,8 +147,10 @@ const allowedEnvironmentVars = [
143
147
  'AUTH_.+_IDP.+',
144
148
  'AUTH_.+_SP.+',
145
149
  // extensions
150
+ 'PACKAGE_FILE_LOCATION',
146
151
  'EXTENSIONS_PATH',
147
152
  'EXTENSIONS_AUTO_RELOAD',
153
+ 'EXTENSIONS_CACHE_TTL',
148
154
  // messenger
149
155
  'MESSENGER_STORE',
150
156
  'MESSENGER_NAMESPACE',
@@ -193,14 +199,19 @@ const defaults = {
193
199
  PUBLIC_URL: '/',
194
200
  MAX_PAYLOAD_SIZE: '1mb',
195
201
  MAX_RELATIONAL_DEPTH: 10,
202
+ ROBOTS_TXT: 'User-agent: *\nDisallow: /',
196
203
  DB_EXCLUDE_TABLES: 'spatial_ref_sys,sysdiagrams',
197
204
  STORAGE_LOCATIONS: 'local',
198
205
  STORAGE_LOCAL_DRIVER: 'local',
199
206
  STORAGE_LOCAL_ROOT: './uploads',
200
207
  RATE_LIMITER_ENABLED: false,
201
- RATE_LIMITER_POINTS: 25,
208
+ RATE_LIMITER_POINTS: 50,
202
209
  RATE_LIMITER_DURATION: 1,
203
210
  RATE_LIMITER_STORE: 'memory',
211
+ RATE_LIMITER_GLOBAL_ENABLED: false,
212
+ RATE_LIMITER_GLOBAL_POINTS: 1000,
213
+ RATE_LIMITER_GLOBAL_DURATION: 1,
214
+ RATE_LIMITER_GLOBAL_STORE: 'memory',
204
215
  ACCESS_TOKEN_TTL: '15m',
205
216
  REFRESH_TOKEN_TTL: '7d',
206
217
  REFRESH_TOKEN_COOKIE_SECURE: false,
@@ -224,24 +235,27 @@ const defaults = {
224
235
  CACHE_SCHEMA: true,
225
236
  CACHE_PERMISSIONS: true,
226
237
  CACHE_VALUE_MAX_SIZE: false,
238
+ CACHE_SKIP_ALLOWED: false,
227
239
  AUTH_PROVIDERS: '',
228
240
  AUTH_DISABLE_DEFAULT: false,
241
+ PACKAGE_FILE_LOCATION: '.',
229
242
  EXTENSIONS_PATH: './extensions',
230
243
  EXTENSIONS_AUTO_RELOAD: false,
231
- EMAIL_FROM: 'no-reply@directus.io',
244
+ EMAIL_FROM: 'no-reply@example.com',
232
245
  EMAIL_VERIFY_SETUP: true,
233
246
  EMAIL_TRANSPORT: 'sendmail',
234
247
  EMAIL_SENDMAIL_NEW_LINE: 'unix',
235
248
  EMAIL_SENDMAIL_PATH: '/usr/sbin/sendmail',
236
249
  TELEMETRY: true,
237
250
  ASSETS_CACHE_TTL: '30d',
238
- ASSETS_TRANSFORM_MAX_CONCURRENT: 1,
251
+ ASSETS_TRANSFORM_MAX_CONCURRENT: 25,
239
252
  ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION: 6000,
240
253
  ASSETS_TRANSFORM_MAX_OPERATIONS: 5,
254
+ ASSETS_TRANSFORM_TIMEOUT: '7500ms',
241
255
  ASSETS_INVALID_IMAGE_SENSITIVITY_LEVEL: 'warning',
242
256
  IP_TRUST_PROXY: true,
243
257
  IP_CUSTOM_HEADER: false,
244
- IMPORT_IP_DENY_LIST: '0.0.0.0',
258
+ IMPORT_IP_DENY_LIST: ['0.0.0.0', '169.254.169.254'],
245
259
  SERVE_APP: true,
246
260
  RELATIONAL_BATCH_SIZE: 25000,
247
261
  EXPORT_BATCH_SIZE: 5000,
@@ -261,6 +275,7 @@ const typeMap = {
261
275
  DB_DATABASE: 'string',
262
276
  DB_PORT: 'number',
263
277
  DB_EXCLUDE_TABLES: 'array',
278
+ CACHE_SKIP_ALLOWED: 'boolean',
264
279
  IMPORT_IP_DENY_LIST: 'array',
265
280
  FILE_METADATA_ALLOW_LIST: 'array',
266
281
  GRAPHQL_INTROSPECTION: 'boolean',
@@ -1,2 +1,2 @@
1
- import { MSSQLError } from './types';
1
+ import type { MSSQLError } from './types';
2
2
  export declare function extractError(error: MSSQLError): Promise<MSSQLError | Error>;
@@ -48,15 +48,14 @@ async function uniqueViolation(error) {
48
48
  * While it's not ideal, the best next thing we can do is extract the column name from
49
49
  * information_schema when this happens
50
50
  */
51
- var _a, _b, _c;
52
51
  const betweenQuotes = /'([^']+)'/g;
53
52
  const betweenParens = /\(([^)]+)\)/g;
54
53
  const quoteMatches = error.message.match(betweenQuotes);
55
54
  const parenMatches = error.message.match(betweenParens);
56
55
  if (!quoteMatches || !parenMatches)
57
56
  return error;
58
- const keyName = (_a = quoteMatches[1]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
59
- let collection = (_b = quoteMatches[0]) === null || _b === void 0 ? void 0 : _b.slice(1, -1);
57
+ const keyName = quoteMatches[1]?.slice(1, -1);
58
+ let collection = quoteMatches[0]?.slice(1, -1);
60
59
  let field = null;
61
60
  if (keyName) {
62
61
  const database = (0, database_1.default)();
@@ -75,10 +74,10 @@ async function uniqueViolation(error) {
75
74
  })
76
75
  .where('sys.indexes.name', '=', keyName)
77
76
  .first();
78
- collection = constraintUsage === null || constraintUsage === void 0 ? void 0 : constraintUsage.collection;
79
- field = constraintUsage === null || constraintUsage === void 0 ? void 0 : constraintUsage.field;
77
+ collection = constraintUsage?.collection;
78
+ field = constraintUsage?.field;
80
79
  }
81
- const invalid = (_c = parenMatches[parenMatches.length - 1]) === null || _c === void 0 ? void 0 : _c.slice(1, -1);
80
+ const invalid = parenMatches[parenMatches.length - 1]?.slice(1, -1);
82
81
  return new record_not_unique_1.RecordNotUniqueException(field, {
83
82
  collection,
84
83
  field,
@@ -1,2 +1,2 @@
1
- import { MySQLError } from './types';
1
+ import type { MySQLError } from './types';
2
2
  export declare function extractError(error: MySQLError): MySQLError | Error;
@@ -38,7 +38,6 @@ function extractError(error) {
38
38
  }
39
39
  exports.extractError = extractError;
40
40
  function uniqueViolation(error) {
41
- var _a, _b, _c, _d, _e;
42
41
  const betweenQuotes = /'([^']+)'/g;
43
42
  const matches = error.sqlMessage.match(betweenQuotes);
44
43
  if (!matches)
@@ -50,13 +49,13 @@ function uniqueViolation(error) {
50
49
  */
51
50
  /** MySQL 8+ style error message */
52
51
  if (matches[1].includes('.')) {
53
- const collection = (_a = matches[1]) === null || _a === void 0 ? void 0 : _a.slice(1, -1).split('.')[0];
52
+ const collection = matches[1]?.slice(1, -1).split('.')[0];
54
53
  let field = null;
55
- const indexName = (_b = matches[1]) === null || _b === void 0 ? void 0 : _b.slice(1, -1).split('.')[1];
56
- if ((indexName === null || indexName === void 0 ? void 0 : indexName.startsWith(`${collection}_`)) && indexName.endsWith('_unique')) {
57
- field = indexName === null || indexName === void 0 ? void 0 : indexName.slice(collection.length + 1, -7);
54
+ const indexName = matches[1]?.slice(1, -1).split('.')[1];
55
+ if (indexName?.startsWith(`${collection}_`) && indexName.endsWith('_unique')) {
56
+ field = indexName?.slice(collection.length + 1, -7);
58
57
  }
59
- const invalid = (_c = matches[0]) === null || _c === void 0 ? void 0 : _c.slice(1, -1);
58
+ const invalid = matches[0]?.slice(1, -1);
60
59
  return new record_not_unique_1.RecordNotUniqueException(field, {
61
60
  collection,
62
61
  field,
@@ -65,13 +64,13 @@ function uniqueViolation(error) {
65
64
  }
66
65
  else {
67
66
  /** MySQL 5.7 style error message */
68
- const indexName = (_d = matches[1]) === null || _d === void 0 ? void 0 : _d.slice(1, -1);
67
+ const indexName = matches[1]?.slice(1, -1);
69
68
  const collection = indexName.split('_')[0];
70
69
  let field = null;
71
- if ((indexName === null || indexName === void 0 ? void 0 : indexName.startsWith(`${collection}_`)) && indexName.endsWith('_unique')) {
72
- field = indexName === null || indexName === void 0 ? void 0 : indexName.slice(collection.length + 1, -7);
70
+ if (indexName?.startsWith(`${collection}_`) && indexName.endsWith('_unique')) {
71
+ field = indexName?.slice(collection.length + 1, -7);
73
72
  }
74
- const invalid = (_e = matches[0]) === null || _e === void 0 ? void 0 : _e.slice(1, -1);
73
+ const invalid = matches[0]?.slice(1, -1);
75
74
  return new record_not_unique_1.RecordNotUniqueException(field, {
76
75
  collection,
77
76
  field,
@@ -80,61 +79,57 @@ function uniqueViolation(error) {
80
79
  }
81
80
  }
82
81
  function numericValueOutOfRange(error) {
83
- var _a, _b;
84
82
  const betweenTicks = /`([^`]+)`/g;
85
83
  const betweenQuotes = /'([^']+)'/g;
86
84
  const tickMatches = error.sql.match(betweenTicks);
87
85
  const quoteMatches = error.sqlMessage.match(betweenQuotes);
88
86
  if (!tickMatches || !quoteMatches)
89
87
  return error;
90
- const collection = (_a = tickMatches[0]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
91
- const field = (_b = quoteMatches[0]) === null || _b === void 0 ? void 0 : _b.slice(1, -1);
88
+ const collection = tickMatches[0]?.slice(1, -1);
89
+ const field = quoteMatches[0]?.slice(1, -1);
92
90
  return new value_out_of_range_1.ValueOutOfRangeException(field, {
93
91
  collection,
94
92
  field,
95
93
  });
96
94
  }
97
95
  function valueLimitViolation(error) {
98
- var _a, _b;
99
96
  const betweenTicks = /`([^`]+)`/g;
100
97
  const betweenQuotes = /'([^']+)'/g;
101
98
  const tickMatches = error.sql.match(betweenTicks);
102
99
  const quoteMatches = error.sqlMessage.match(betweenQuotes);
103
100
  if (!tickMatches || !quoteMatches)
104
101
  return error;
105
- const collection = (_a = tickMatches[0]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
106
- const field = (_b = quoteMatches[0]) === null || _b === void 0 ? void 0 : _b.slice(1, -1);
102
+ const collection = tickMatches[0]?.slice(1, -1);
103
+ const field = quoteMatches[0]?.slice(1, -1);
107
104
  return new value_too_long_1.ValueTooLongException(field, {
108
105
  collection,
109
106
  field,
110
107
  });
111
108
  }
112
109
  function notNullViolation(error) {
113
- var _a, _b;
114
110
  const betweenTicks = /`([^`]+)`/g;
115
111
  const betweenQuotes = /'([^']+)'/g;
116
112
  const tickMatches = error.sql.match(betweenTicks);
117
113
  const quoteMatches = error.sqlMessage.match(betweenQuotes);
118
114
  if (!tickMatches || !quoteMatches)
119
115
  return error;
120
- const collection = (_a = tickMatches[0]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
121
- const field = (_b = quoteMatches[0]) === null || _b === void 0 ? void 0 : _b.slice(1, -1);
116
+ const collection = tickMatches[0]?.slice(1, -1);
117
+ const field = quoteMatches[0]?.slice(1, -1);
122
118
  return new not_null_violation_1.NotNullViolationException(field, {
123
119
  collection,
124
120
  field,
125
121
  });
126
122
  }
127
123
  function foreignKeyViolation(error) {
128
- var _a, _b, _c;
129
124
  const betweenTicks = /`([^`]+)`/g;
130
125
  const betweenParens = /\(([^)]+)\)/g;
131
126
  const tickMatches = error.sqlMessage.match(betweenTicks);
132
127
  const parenMatches = error.sql.match(betweenParens);
133
128
  if (!tickMatches || !parenMatches)
134
129
  return error;
135
- const collection = (_a = tickMatches[1]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
136
- const field = (_b = tickMatches[3]) === null || _b === void 0 ? void 0 : _b.slice(1, -1);
137
- const invalid = (_c = parenMatches[1]) === null || _c === void 0 ? void 0 : _c.slice(1, -1);
130
+ const collection = tickMatches[1]?.slice(1, -1);
131
+ const field = tickMatches[3]?.slice(1, -1);
132
+ const invalid = parenMatches[1]?.slice(1, -1);
138
133
  return new invalid_foreign_key_1.InvalidForeignKeyException(field, {
139
134
  collection,
140
135
  field,
@@ -142,13 +137,12 @@ function foreignKeyViolation(error) {
142
137
  });
143
138
  }
144
139
  function containsNullValues(error) {
145
- var _a;
146
140
  const betweenTicks = /`([^`]+)`/g;
147
141
  // Normally, we shouldn't read from the executed SQL. In this case, we're altering a single
148
142
  // column, so we shouldn't have the problem where multiple columns are altered at the same time
149
143
  const tickMatches = error.sql.match(betweenTicks);
150
144
  if (!tickMatches)
151
145
  return error;
152
- const field = (_a = tickMatches[1]) === null || _a === void 0 ? void 0 : _a.slice(1, -1);
146
+ const field = tickMatches[1]?.slice(1, -1);
153
147
  return new contains_null_values_1.ContainsNullValuesException(field);
154
148
  }
@@ -1,2 +1,2 @@
1
- import { OracleError } from './types';
1
+ import type { OracleError } from './types';
2
2
  export declare function extractError(error: OracleError): OracleError | Error;
@@ -1,2 +1,2 @@
1
- import { PostgresError } from './types';
1
+ import type { PostgresError } from './types';
2
2
  export declare function extractError(error: PostgresError): PostgresError | Error;
@@ -1,2 +1,2 @@
1
- import { SQLiteError } from './types';
1
+ import type { SQLiteError } from './types';
2
2
  export declare function extractError(error: SQLiteError): SQLiteError | Error;
@@ -1,4 +1,4 @@
1
- import { SQLError } from './dialects/types';
1
+ import type { SQLError } from './dialects/types';
2
2
  /**
3
3
  * Translates an error thrown by any of the databases into a pre-defined Exception. Currently
4
4
  * supports:
@@ -5,7 +5,7 @@ const exceptions_1 = require("@directus/shared/exceptions");
5
5
  class ValueOutOfRangeException extends exceptions_1.BaseException {
6
6
  constructor(field, exceptions) {
7
7
  if (field) {
8
- super(`Numeric value in field "${field !== null && field !== void 0 ? field : ''}" is out of range.`, 400, 'VALUE_OUT_OF_RANGE', exceptions);
8
+ super(`Numeric value in field "${field ?? ''}" is out of range.`, 400, 'VALUE_OUT_OF_RANGE', exceptions);
9
9
  }
10
10
  else {
11
11
  super(`Numeric value is out of range.`, 400, 'VALUE_OUT_OF_RANGE', exceptions);
@@ -4,9 +4,8 @@ exports.RangeNotSatisfiableException = void 0;
4
4
  const exceptions_1 = require("@directus/shared/exceptions");
5
5
  class RangeNotSatisfiableException extends exceptions_1.BaseException {
6
6
  constructor(range) {
7
- var _a, _b;
8
- const rangeString = range && ((range === null || range === void 0 ? void 0 : range.start) !== undefined || (range === null || range === void 0 ? void 0 : range.end) !== undefined)
9
- ? `"${(_a = range.start) !== null && _a !== void 0 ? _a : ''}-${(_b = range.end) !== null && _b !== void 0 ? _b : ''}" `
7
+ const rangeString = range && (range?.start !== undefined || range?.end !== undefined)
8
+ ? `"${range.start ?? ''}-${range.end ?? ''}" `
10
9
  : '';
11
10
  super(`Range ${rangeString}is invalid or the file's size doesn't match the requested range.`, 416, 'RANGE_NOT_SATISFIABLE');
12
11
  }
@@ -1,4 +1,4 @@
1
- import { Extension, ExtensionInfo, ExtensionType } from '@directus/shared/types';
1
+ import type { Extension, ExtensionInfo, ExtensionType } from '@directus/shared/types';
2
2
  import { Router } from 'express';
3
3
  export declare function getExtensionManager(): ExtensionManager;
4
4
  type Options = {
@@ -29,28 +29,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.getExtensionManager = void 0;
30
30
  const constants_1 = require("@directus/shared/constants");
31
31
  const sharedExceptions = __importStar(require("@directus/shared/exceptions"));
32
- const node_1 = require("@directus/shared/utils/node");
33
- const express_1 = __importStar(require("express"));
34
- const fs_extra_1 = __importDefault(require("fs-extra"));
35
- const path_1 = __importDefault(require("path"));
36
- const database_1 = __importDefault(require("./database"));
37
- const emitter_1 = __importStar(require("./emitter"));
38
- const env_1 = __importDefault(require("./env"));
39
- const exceptions = __importStar(require("./exceptions"));
40
- const logger_1 = __importDefault(require("./logger"));
41
- const dynamic_import_1 = require("./utils/dynamic-import");
42
- const get_schema_1 = require("./utils/get-schema");
43
32
  const utils_1 = require("@directus/shared/utils");
33
+ const node_1 = require("@directus/shared/utils/node");
44
34
  const plugin_alias_1 = __importDefault(require("@rollup/plugin-alias"));
45
35
  const plugin_virtual_1 = __importDefault(require("@rollup/plugin-virtual"));
46
36
  const chokidar_1 = __importDefault(require("chokidar"));
37
+ const express_1 = __importStar(require("express"));
38
+ const fs_extra_1 = __importDefault(require("fs-extra"));
47
39
  const globby_1 = __importDefault(require("globby"));
48
40
  const lodash_1 = require("lodash");
49
41
  const node_cron_1 = require("node-cron");
42
+ const path_1 = __importDefault(require("path"));
50
43
  const rollup_1 = require("rollup");
44
+ const database_1 = __importDefault(require("./database"));
45
+ const emitter_1 = __importStar(require("./emitter"));
46
+ const env_1 = __importDefault(require("./env"));
47
+ const exceptions = __importStar(require("./exceptions"));
51
48
  const flows_1 = require("./flows");
49
+ const logger_1 = __importDefault(require("./logger"));
52
50
  const services = __importStar(require("./services"));
51
+ const dynamic_import_1 = require("./utils/dynamic-import");
53
52
  const get_module_default_1 = __importDefault(require("./utils/get-module-default"));
53
+ const get_schema_1 = require("./utils/get-schema");
54
54
  const job_queue_1 = require("./utils/job-queue");
55
55
  const url_1 = require("./utils/url");
56
56
  let extensionManager;
@@ -67,15 +67,19 @@ const defaultOptions = {
67
67
  watch: env_1.default.EXTENSIONS_AUTO_RELOAD && env_1.default.NODE_ENV !== 'development',
68
68
  };
69
69
  class ExtensionManager {
70
+ isLoaded = false;
71
+ options;
72
+ extensions = [];
73
+ appExtensions = null;
74
+ apiExtensions = [];
75
+ apiEmitter;
76
+ hookEvents = [];
77
+ endpointRouter;
78
+ hookEmbedsHead = [];
79
+ hookEmbedsBody = [];
80
+ reloadQueue;
81
+ watcher = null;
70
82
  constructor() {
71
- this.isLoaded = false;
72
- this.extensions = [];
73
- this.appExtensions = null;
74
- this.apiExtensions = [];
75
- this.hookEvents = [];
76
- this.hookEmbedsHead = [];
77
- this.hookEmbedsBody = [];
78
- this.watcher = null;
79
83
  this.options = defaultOptions;
80
84
  this.apiEmitter = new emitter_1.Emitter();
81
85
  this.endpointRouter = (0, express_1.Router)();
@@ -140,17 +144,23 @@ class ExtensionManager {
140
144
  name: extension.name,
141
145
  type: extension.type,
142
146
  local: extension.local,
143
- host: extension.host,
144
- version: extension.version,
147
+ entries: [],
145
148
  };
149
+ if (extension.host)
150
+ extensionInfo.host = extension.host;
151
+ if (extension.version)
152
+ extensionInfo.version = extension.version;
146
153
  if (extension.type === 'bundle') {
147
- return {
148
- ...extensionInfo,
154
+ const bundleExtensionInfo = {
155
+ name: extensionInfo.name,
156
+ type: 'bundle',
157
+ local: extensionInfo.local,
149
158
  entries: extension.entries.map((entry) => ({
150
159
  name: entry.name,
151
160
  type: entry.type,
152
161
  })),
153
162
  };
163
+ return bundleExtensionInfo;
154
164
  }
155
165
  else {
156
166
  return extensionInfo;
@@ -246,7 +256,7 @@ class ExtensionManager {
246
256
  }
247
257
  }
248
258
  async getExtensions() {
249
- const packageExtensions = await (0, node_1.getPackageExtensions)('.');
259
+ const packageExtensions = await (0, node_1.getPackageExtensions)(env_1.default.PACKAGE_FILE_LOCATION);
250
260
  const localPackageExtensions = await (0, node_1.resolvePackageExtensions)(env_1.default.EXTENSIONS_PATH);
251
261
  const localExtensions = await (0, node_1.getLocalExtensions)(env_1.default.EXTENSIONS_PATH);
252
262
  return [...packageExtensions, ...localPackageExtensions, ...localExtensions].filter((extension) => env_1.default.SERVE_APP || constants_1.APP_EXTENSION_TYPES.includes(extension.type) === false);
package/dist/flows.js CHANGED
@@ -47,6 +47,7 @@ const revisions_1 = require("./services/revisions");
47
47
  const construct_flow_tree_1 = require("./utils/construct-flow-tree");
48
48
  const get_schema_1 = require("./utils/get-schema");
49
49
  const job_queue_1 = require("./utils/job-queue");
50
+ const map_values_deep_1 = require("./utils/map-values-deep");
50
51
  let flowManager;
51
52
  const redactLogs = (0, fast_redact_1.default)({
52
53
  censor: '--redacted--',
@@ -66,12 +67,13 @@ const ACCOUNTABILITY_KEY = '$accountability';
66
67
  const LAST_KEY = '$last';
67
68
  const ENV_KEY = '$env';
68
69
  class FlowManager {
70
+ isLoaded = false;
71
+ operations = {};
72
+ triggerHandlers = [];
73
+ operationFlowHandlers = {};
74
+ webhookFlowHandlers = {};
75
+ reloadQueue;
69
76
  constructor() {
70
- this.isLoaded = false;
71
- this.operations = {};
72
- this.triggerHandlers = [];
73
- this.operationFlowHandlers = {};
74
- this.webhookFlowHandlers = {};
75
77
  this.reloadQueue = new job_queue_1.JobQueue();
76
78
  const messenger = (0, messenger_1.getMessenger)();
77
79
  messenger.subscribe('flows', (event) => {
@@ -120,7 +122,6 @@ class FlowManager {
120
122
  return handler(data, context);
121
123
  }
122
124
  async load() {
123
- var _a, _b, _c, _d;
124
125
  const flowsService = new services_1.FlowsService({ knex: (0, database_1.default)(), schema: await (0, get_schema_1.getSchema)() });
125
126
  const flows = await flowsService.readByQuery({
126
127
  filter: { status: { _eq: 'active' } },
@@ -130,23 +131,25 @@ class FlowManager {
130
131
  const flowTrees = flows.map((flow) => (0, construct_flow_tree_1.constructFlowTree)(flow));
131
132
  for (const flow of flowTrees) {
132
133
  if (flow.trigger === 'event') {
133
- const events = ((_a = flow.options) === null || _a === void 0 ? void 0 : _a.scope)
134
- ? (0, utils_1.toArray)(flow.options.scope)
134
+ let events = [];
135
+ if (flow.options?.scope) {
136
+ events = (0, utils_1.toArray)(flow.options.scope)
135
137
  .map((scope) => {
136
- var _a, _b, _c;
137
138
  if (['items.create', 'items.update', 'items.delete'].includes(scope)) {
138
- return ((_c = (_b = (_a = flow.options) === null || _a === void 0 ? void 0 : _a.collections) === null || _b === void 0 ? void 0 : _b.map((collection) => {
139
+ if (!flow.options?.collections)
140
+ return [];
141
+ return (0, utils_1.toArray)(flow.options.collections).map((collection) => {
139
142
  if (collection.startsWith('directus_')) {
140
143
  const action = scope.split('.')[1];
141
144
  return collection.substring(9) + '.' + action;
142
145
  }
143
146
  return `${collection}.${scope}`;
144
- })) !== null && _c !== void 0 ? _c : []);
147
+ });
145
148
  }
146
149
  return scope;
147
150
  })
148
- .flat()
149
- : [];
151
+ .flat();
152
+ }
150
153
  if (flow.options.type === 'filter') {
151
154
  const handler = (payload, meta, context) => this.executeFlow(flow, { payload, ...meta }, {
152
155
  accountability: context.accountability,
@@ -201,16 +204,15 @@ class FlowManager {
201
204
  return this.executeFlow(flow, data, context);
202
205
  }
203
206
  };
204
- const method = (_c = (_b = flow.options) === null || _b === void 0 ? void 0 : _b.method) !== null && _c !== void 0 ? _c : 'GET';
207
+ const method = flow.options?.method ?? 'GET';
205
208
  // Default return to $last for webhooks
206
- flow.options.return = (_d = flow.options.return) !== null && _d !== void 0 ? _d : '$last';
209
+ flow.options.return = flow.options.return ?? '$last';
207
210
  this.webhookFlowHandlers[`${method}-${flow.id}`] = handler;
208
211
  }
209
212
  else if (flow.trigger === 'manual') {
210
213
  const handler = (data, context) => {
211
- var _a, _b;
212
- const enabledCollections = (_b = (_a = flow.options) === null || _a === void 0 ? void 0 : _a.collections) !== null && _b !== void 0 ? _b : [];
213
- const targetCollection = data === null || data === void 0 ? void 0 : data.body.collection;
214
+ const enabledCollections = flow.options?.collections ?? [];
215
+ const targetCollection = data?.body.collection;
214
216
  if (!targetCollection) {
215
217
  logger_1.default.warn(`Manual trigger requires "collection" to be specified in the payload`);
216
218
  throw new exceptions.ForbiddenException();
@@ -259,13 +261,12 @@ class FlowManager {
259
261
  this.isLoaded = false;
260
262
  }
261
263
  async executeFlow(flow, data = null, context = {}) {
262
- var _a, _b, _c, _d, _e, _f, _g;
263
- const database = (_a = context.database) !== null && _a !== void 0 ? _a : (0, database_1.default)();
264
- const schema = (_b = context.schema) !== null && _b !== void 0 ? _b : (await (0, get_schema_1.getSchema)({ database }));
264
+ const database = context.database ?? (0, database_1.default)();
265
+ const schema = context.schema ?? (await (0, get_schema_1.getSchema)({ database }));
265
266
  const keyedData = {
266
267
  [TRIGGER_KEY]: data,
267
268
  [LAST_KEY]: data,
268
- [ACCOUNTABILITY_KEY]: (_c = context === null || context === void 0 ? void 0 : context.accountability) !== null && _c !== void 0 ? _c : null,
269
+ [ACCOUNTABILITY_KEY]: context?.accountability ?? null,
269
270
  [ENV_KEY]: (0, lodash_1.pick)(env_1.default, env_1.default.FLOWS_ENV_ALLOW_LIST ? (0, utils_1.toArray)(env_1.default.FLOWS_ENV_ALLOW_LIST) : []),
270
271
  };
271
272
  let nextOperation = flow.operation;
@@ -284,14 +285,14 @@ class FlowManager {
284
285
  knex: database,
285
286
  schema: schema,
286
287
  });
287
- const accountability = context === null || context === void 0 ? void 0 : context.accountability;
288
+ const accountability = context?.accountability;
288
289
  const activity = await activityService.createOne({
289
290
  action: types_1.Action.RUN,
290
- user: (_d = accountability === null || accountability === void 0 ? void 0 : accountability.user) !== null && _d !== void 0 ? _d : null,
291
+ user: accountability?.user ?? null,
291
292
  collection: 'directus_flows',
292
- ip: (_e = accountability === null || accountability === void 0 ? void 0 : accountability.ip) !== null && _e !== void 0 ? _e : null,
293
- user_agent: (_f = accountability === null || accountability === void 0 ? void 0 : accountability.userAgent) !== null && _f !== void 0 ? _f : null,
294
- origin: (_g = accountability === null || accountability === void 0 ? void 0 : accountability.origin) !== null && _g !== void 0 ? _g : null,
293
+ ip: accountability?.ip ?? null,
294
+ user_agent: accountability?.userAgent ?? null,
295
+ origin: accountability?.origin ?? null,
295
296
  item: flow.id,
296
297
  });
297
298
  if (flow.accountability === 'all') {
@@ -329,7 +330,7 @@ class FlowManager {
329
330
  const handler = this.operations[operation.type];
330
331
  const options = (0, utils_1.applyOptionsData)(operation.options, keyedData);
331
332
  try {
332
- const result = await handler(options, {
333
+ let result = await handler(options, {
333
334
  services,
334
335
  exceptions: { ...exceptions, ...sharedExceptions },
335
336
  env: env_1.default,
@@ -340,10 +341,35 @@ class FlowManager {
340
341
  accountability: null,
341
342
  ...context,
342
343
  });
343
- return { successor: operation.resolve, status: 'resolve', data: result !== null && result !== void 0 ? result : null, options };
344
+ // Validate that the operations result is serializable and thus catching the error inside the flow execution
345
+ JSON.stringify(result ?? null);
346
+ // JSON structures don't allow for undefined values, so we need to replace them with null
347
+ // Otherwise the applyOptionsData function will not work correctly on the next operation
348
+ if (typeof result === 'object' && result !== null) {
349
+ result = (0, map_values_deep_1.mapValuesDeep)(result, (_, value) => (value === undefined ? null : value));
350
+ }
351
+ return { successor: operation.resolve, status: 'resolve', data: result ?? null, options };
344
352
  }
345
353
  catch (error) {
346
- return { successor: operation.reject, status: 'reject', data: error !== null && error !== void 0 ? error : null, options };
354
+ let data;
355
+ if (error instanceof Error) {
356
+ // If the error is instance of Error, use the message of it as the error data
357
+ data = { message: error.message };
358
+ }
359
+ else if (typeof error === 'string') {
360
+ // If the error is a JSON string, parse it and use that as the error data
361
+ data = (0, utils_1.isValidJSON)(error) ? (0, utils_1.parseJSON)(error) : error;
362
+ }
363
+ else {
364
+ // If error is plain object, use this as the error data and otherwise fallback to null
365
+ data = error ?? null;
366
+ }
367
+ return {
368
+ successor: operation.reject,
369
+ status: 'reject',
370
+ data,
371
+ options,
372
+ };
347
373
  }
348
374
  }
349
375
  }
package/dist/logger.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="qs" />
2
- import { RequestHandler } from 'express';
3
2
  import { LoggerOptions } from 'pino';
3
+ import type { RequestHandler } from 'express';
4
4
  declare const logger: import("pino").Logger<LoggerOptions & Record<string, any>>;
5
5
  export declare const expressLogger: RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
6
6
  export default logger;