Commit Graph

2445 Commits

Author SHA1 Message Date
Pascal Jufer
7b89a11ebe Include schema components in OAS (#17712)
* Add missing schema components to required list

* Update expected schema & switch to inline snapshot

---------

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-03-06 15:33:53 +01:00
Azri Kahar
d466204732 Add ability to limit requests from using the Cache-Control header to skip cache (#17642)
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
2023-03-02 13:19:30 +01:00
Brainslug
ee7fca3e31 Global rate limiter (#17296)
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2023-03-02 13:04:22 +01:00
Azri Kahar
512ca48680 Allow null for related_collection in applyJoiSchema (#17665)
* allow null for related_collection

* Add M2A to schema tests

* Trigger testing for all vendors

* Standardize naming convention

* Update deleted collections assertion

* Fix typo

* Revert testing for all vendors

---------

Co-authored-by: ian <licitdev@gmail.com>
2023-03-02 08:23:13 +01:00
rijkvanzanten
e468f58eec v9.23.1 2023-03-01 09:51:57 -05:00
rijkvanzanten
47b9824954 v9.23.0 2023-02-28 12:51:36 -05:00
Azri Kahar
1f6a8e57ad Additionally check for varchar when casting UUID in apply diff (#17615)
* check for varchar when casting UUID in apply diff

* add test

---------

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-02-28 11:33:25 +01:00
ian
fb41eee1ed Catch IPTC and XMP extraction errors (#17633)
* Catch IPTC and XMP extraction errors

* Add autoPurgeCache option to uploadOne

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>

---------

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2023-02-27 11:05:00 +00:00
Thierry Kühni
9856019c3a Catch ICC parse errors to avoid server crash (#17622)
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
2023-02-27 08:21:20 +01:00
Pascal Jufer
1cceeaf637 Update request unit test (#17624) 2023-02-25 21:32:43 -05:00
rijkvanzanten
6dce1a2f8a Update request
Squashed commit of the following:

commit 5afeab357b73494d690c33952efd41b29367fab5
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Fri Feb 24 15:39:15 2023 -0500

    Add dns pre-resolve

commit 68e0e8c8099b5463297185f220e80b2b6d5b980a
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Fri Feb 24 12:28:18 2023 -0500

    Start on request interceptor
2023-02-24 15:40:25 -05:00
Rijk van Zanten
ee59646b8c Use example.com instead of directus.io (#17600) 2023-02-22 15:19:55 -05:00
Rijk van Zanten
6cb92ea06a Add support for ASSET_TRANSFORM_TIMEOUT env var (#17596)
* Add support for ASSET_TRANSFORM_TIMEOUT env var

* Use string based config

* Timeout on overall promise
2023-02-22 14:39:02 -05:00
Norbert Fodor
3e80260a49 Remove hardcoded package extension path (#17525)
* Remove hardcoded package extension path

* Rename PACKAGE_EXTENSIONS_PATH env variable to PACKAGE_FILE_LOCATION

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-02-21 17:22:18 +01:00
ian
9c36d7d8ef Throw validation error after authorization (#17499)
* Throw validation error after authorization

* Improve tests

* Refactor for deleteMany
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>

* Refactor other usages in users service that errors before ForbiddenException

* Update tests

* Adjust test for 'deleteByQuery'

---------

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-02-20 11:57:10 +01:00
Pascal Jufer
e3c755dcf0 Add getMilliseconds util for safer value interpretation (#17498)
* Add `getMilliseconds` util for safer value interpretation

* Test more data types

* Remove remnant

* Customizable fallback with default of undefined

* Clean-up

* Transform getMilliseconds to named export

---------

Co-authored-by: ian <licitdev@gmail.com>
2023-02-17 11:06:26 -05:00
Pascal Jufer
37faf3bd5d Patch Tuesday 🐸 (#17530)
* Update root deps

* Reformat files with new prettier version

* Update `directus` deps

* Update `@directus/app` deps

* Update `@directus/shared` deps

* Update components snapshots after updates

prop order has changed

* Update `extensions-sdk` deps

* pin version of zod in shared

* Update `@directus/storage` deps

* Update `@directus/storage-driver-azure` deps

* Update `storage-driver-cloudinary` deps

* Update `@directus/storage-driver-cloudinary` deps

* Update `@directus/storage-driver-local` deps

* Update `@directus/storage-driver-s3` deps

* Update `@directus/utils` deps

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-02-16 17:47:39 +08:00
Pascal Jufer
89fbac36ce Catch errors from exif-reader (#17527) 2023-02-15 21:37:51 +00:00
Pascal Jufer
45c4bc89f1 EXTENSIONS_CACHE_TTL: Add to allow list & decouple from other cache envs (#17464)
* EXTENSIONS_CACHE_TTL: Add to allow list & decouple from other cache envs

* Remove unnecessary import

* Broaden getCacheControlHeader function, use it for assets & extensions

* Add unit tests

* Apply suggestions from code review

Consistent lowercase "cache-control" in test description

---------

Co-authored-by: ian <licitdev@gmail.com>
2023-02-14 10:28:40 -05:00
rijkvanzanten
ff53d3e69a Cleanup request handler
Squashed commit of the following:

commit 90368698c8
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Mon Feb 13 15:49:12 2023 -0500

    Cleanup

commit 61514f4509
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Mon Feb 13 15:44:15 2023 -0500

    Rename to index

commit 38fe6b84fa
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Mon Feb 13 15:41:23 2023 -0500

    Test coverage 100%

commit f2e36db95e
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Mon Feb 13 15:22:45 2023 -0500

    Split up handler from validator

commit 800ac1968a
Author: Pascal Jufer <pascal-jufer@bluewin.ch>
Date:   Mon Feb 13 20:44:48 2023 +0100

    Use shared axios instance with URL check for outgoing requests
2023-02-13 15:49:24 -05:00
ian
ea91c40733 Fix sort added by offset not removed for MSSQL (#17343) 2023-02-13 10:39:11 +01:00
ian
d7f16cd8ac Allow offset and page args for GraphQL aggregated queries (#17481) 2023-02-10 19:09:32 +08:00
Nitwel
acd4078239 Fix using strings for flow trigger collections (#17441) 2023-02-08 12:59:23 -05:00
Nitwel
3866b138ad Allow for custom robots.txt (#17448)
* Allow for custom robots.txt

* fix test
2023-02-08 11:19:16 -05:00
Pascal Jufer
26318dbe62 Patch Tuesday 🐸 (#17353) 2023-01-31 23:15:49 -05:00
Azri Kahar
89fcb19a16 Expose schema endpoints (#14713)
* Expose schema endpoints

* respond with 204

* fix payload for export flag

* allow export as YAML

* use SchemaService

* move getStringFromStream to utils

* clearer exceptions with logs

* check empty request body

* specs

* add bypassCache flag and remove flushCaches calls

* Identify integer typed fields in Oracle

* Fix uuid foreign keys type for Oracle

* Detect autoincrement for CockroachDB

* Bypass cache for fields and relations services

* Add same DB tests

* Test if working for all vendors

* Add schema snapshot testing into sequential flow

* Fix schema re-apply attempts when it's a different database vendor (#14816)

* prevent diffing on certain properties

* fix apply-snapshot test

* prevent updates to autoincrement fields' schema

* sanitize relations

* remove `colleciton.schema.sql` parsing in test

It is now being sanitized by `sanitizeCollection()` function in get-snapshot-diff.ts

* Change concurrency group to not cancel test running on main

* remove multipart for apply & add hash checking

* check incoming version & add force query param

* refine error message & stub for nested hash

* add `vendor` top-level property

as an additional safety net for cross db vendor applies

* sanitize generated schema snapshots

* snapshot joi validation

* diff joi validation

* minor cleanup

* extract applyDiff & use deep-diff applyChange

* use applyDiff in schema service

* Mark vendor as optional

* Update tests to apply diffs

* move force flag check into service

* Patch mssql vendor typo

* Set relation no action in cyclic relations

* Update mysql timestamp default value

* Oracle cannot define no action

* Update oracle timestamp type default values

* add hash checking for outdated diffs

* fix diff service & endpoint

* Add hashes when returning after

* Fix self referencing relations for Oracle

* Add temp fix for CURRENT_TIMESTAMP defaults in Oracle

* clean up driver and database client types

* only require diff hash if not kind N

* update hash comparison logic for create/delete

* Set no action constraint for self referencing M2M in MSSQL

* Add basic hash check tests

* omit default value when hashing auto increments

Specifically for CockroachDB with differing sequences

* add vendor check

* update specs

* Validate vendors with type definition

* Spread the vendors input array

* re-add Export component

* re-add js-yaml to root

* Propagate mutation options for schema apply

* Verify that snapshots differ and clear cache before hash tests

* Fix unit test

* Revert temp fix for CURRENT_TIMESTAMP defaults in Oracle

* Define and reuse type for export format

* Define and reuse list of database clients

* change `were` to `was`

* change `where` to `were`

* add some empty lines for readability

* tweak exception message

* fix test

* use object-hash

* use boolean to check whether file is included

* simplify request content type check

* throw error when multiple files were uploaded

* use nullish coalesce instead of short circuit

* Update api/src/services/schema.ts

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>

* Remove unnecessary `Omit` on `SnapshotWithHash` type

* Revert "Remove unnecessary `Omit` on `SnapshotWithHash` type"

This reverts commit d22ac771ec.

* check empty snapshot earlier

* use allow-list logic via pick instead of omit

* Update api/src/services/schema.ts

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>

* Move to own /schema endpoint controller

* Fix refs to schema endpoint

* move streamToString to utils package

* move get-versioned-hash and add test

* extract kind into an enum

* Fix mysql5 timestamp value

* Fix test collection existing on rerun

* resolve TODO comment in blackbox test

* Drop deep level hashes in diff

These hashes are used only for more accurate error reporting
but are otherwise superfluous, since changes are already
detected by the top level hash.
Therefore we remove them in favor of a simpler diff format and
implementation.

* Revert schema "fix" for createItem, add comment

* Strict diff schema validation

* Revert CrDB auto-increment detection patch in 816c998

* Clear systemCache to expose newly added fields

* Use DiffKind constants

* Extract diff & snapshot validation into own tested utils

* Apply suggestions from @azrikahar

* Update knex-schema-inspector to 3.0.1

Includes the fix for CrDB auto-increment detection (knex/knex-schema-inspector#135)

* Update knex-schema-inspector in packages

* Update lock file

* add test for schema service

* add test for export service

* add relevant tests to modified util functions

* fix csv test to account for os end of line

* fix files controller test

* dedupe test data for schema service

* Align schema specs with docs

* Update api/src/controllers/schema.ts

* Revert testing for all vendors

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
Co-authored-by: ian <licitdev@gmail.com>
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
2023-01-31 17:36:49 +00:00
Rijk van Zanten
e3e1f21573 Update axios (#17350) 2023-01-31 09:56:34 +01:00
Sara Tavares
1bfd460449 chore(typo): fix typo (#17334)
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-01-30 12:12:05 +01:00
Julius Berger
8cbaabd8cd Add return to complete promise rejection (#17335) 2023-01-29 17:10:45 -05:00
ian
91a4a7fca1 Fix CreateMany action hooks (#17066)
* queue action events, emit after transaction

* also queue nested action events

* renamed vars for consistency

* fix import csv/json hooks triggering

* Add unit tests

* Add action verify create tests

* Flip check to improve legibility

---------

Co-authored-by: Ewout Stortenbeker <me@appy.one>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2023-01-27 16:38:52 +00:00
Brainslug
dc135f776d Check for null on _empty and _nempty filters (#17284)
* check for null on `_empty` and `_nempty` filters

* include falsy values for _empty filter tests
2023-01-24 13:04:58 -05:00
Benoît Burgener
61cbb0b7f8 GraphQL return original error (#17168) (#17268) 2023-01-23 11:55:32 -05:00
Azri Kahar
6c108a9582 update knex version (#17240) 2023-01-19 10:16:56 -05:00
Nitwel
f36ebb1a0b Flows improvements (#16773) 2023-01-19 08:15:12 -05:00
Nitwel
7e43b08e53 Fix operations output being undefined (#17181)
* fix operation output being undefined

* run linter

* map arrays deep too

* run linter

* rename to mapValuesDeep
2023-01-18 15:00:35 -05:00
John Flow
6793d9fd40 Added https:// (#17171) 2023-01-15 11:45:45 -05:00
José Varela
5e555f7756 Graphql: Prevent store response with errors in cache (#16926)
* Prevent cache response with errors

* Fix failing test

* mock env in notifications service test

* Use res.locals.cache = false instead

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-01-12 17:06:24 -05:00
Francisco Marques
0f9f0d8fc4 Fix url encoding query parameters and added tests (#17120)
* fix(utils): query parameters encoding for Url

* improvement(utils): added tests to Url

Also, made trailing slash behaviour consistent

* fix: updated nvmrc to the recommended node version
2023-01-12 12:31:51 -05:00
Brainslug
d312bd172d Fix GraphQL server health output (#17113)
* fix graphql server health

* Add tests

Co-authored-by: ian <licitdev@gmail.com>
2023-01-12 13:12:06 +01:00
rijkvanzanten
065c77dc1d v9.22.4 2023-01-11 17:05:16 -05:00
Azri Kahar
d2a6621153 Add tests for Flows operations (#16580)
* Add tests for Flows operations

* fix notifications test env

* tweaks

* fix env mock
2023-01-11 16:12:16 -05:00
Roger Stringer
102b965abe offset should be 0 not 1 by default (#17101) 2023-01-11 20:57:18 +00:00
rijkvanzanten
9f708d67bc v9.22.3 2023-01-11 12:16:11 -05:00
rijkvanzanten
b9a5005859 v9.22.2 2023-01-11 11:27:56 -05:00
Azri Kahar
32603cbf2f use setCacheValue in get-permissions util (#17044) 2023-01-10 16:45:59 -05:00
Brainslug
dda1afcf16 Collection export limit 0 leads to 500 error (#16722)
* prevent 500 error when limit=0

* short circuit parser instead

* removed unneeded comment

* setting a sensible minimum and step for export limit

* fixed notif message when exporting limit=-1

* re-added !exportSettings.limit fallback behavior

* guard against negative limit values lower than -1

* add unit test for sanitizeQuery

* remove unnecessary test cases

because offset and page are validated in validateQuery

* delegate validation to validateQuery instead

* use sanitizeQuery util for export

* Added check for integers

Co-authored-by: ian <licitdev@gmail.com>

* validate instead of sanitize

* removed obsolete test

* added integer checks for limit, offset, page and sensible minimums

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: ian <licitdev@gmail.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-01-10 09:35:31 +01:00
Rijk van Zanten
c249d58a8c Revert "Speed-up api dev scripts by using swc (#16609)" (#17064)
This reverts commit e9a2ce5a9e.
2023-01-09 16:57:03 -05:00
Azri Kahar
7616b25988 Pass emitEvents to query methods in item-read & item-delete operations (#16579)
* fix item-read's readByQuery emitEvents

* fix item-delete's deleteByQuery emitEvents

* tests
2023-01-09 15:50:55 -05:00
Pascal Jufer
e9a2ce5a9e Speed-up api dev scripts by using swc (#16609) 2023-01-09 15:47:41 -05:00
ian
1d6e77d5ab Fix last admin check for alterations type inputs (#16595)
* Fix last admin check for alterations type inputs

* Add unit tests

* fix mocks causing side-effects

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2023-01-09 20:33:13 +08:00