Commit Graph

5015 Commits

Author SHA1 Message Date
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
Addison Elliott
39a812b4f3 Fix bug with v-checkbox-tree where leaf nodes are treated like branch (#17323)
nodes with no children

Bug introduced here in #15094

Co-authored-by: Addison Elliott <addisone@becs.com>
2023-01-27 15:53:17 -05:00
Andrii Trubai
ef12487f7f Fix an incorrect rendering of m2a items templates (#16478)
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-01-24 12:20:00 +01:00
Jay Bharadia
b13efb61ef Fix field configuration view not updating when navigating between different fields in New Field drawer (#17254)
* Fix field configuration view not updating when navigating between different fields in New Field drawer

* Used Vue toRef instead of computed as per the feedback

* Make type reactive too

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2023-01-23 13:05:25 -05:00
Jay Bharadia
bb176c44fb Fix/issue 16692 and issue 16437 (#17186)
* Issue 16437 solved

* Cleanup optional check

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2023-01-19 11:34:27 -05:00
Nitwel
276cc479ce Revert "Disable field selection for alias fields in the system-filter component when functions are used (#14314)" (#17182) 2023-01-19 08:18:35 -05:00
Nitwel
f36ebb1a0b Flows improvements (#16773) 2023-01-19 08:15:12 -05:00
ian
025bb7c053 Fix insights filtering (#16139)
* Parse string filter as JSON

* Parse content as JSON when toggling raw editor

* Refactor missing Dashboard type

* Convert filter to gql format

* Disable alias field filter selection in insights

* Use parseJSON util

* Refactor to allow selectivity of relational field for GraphQL filters

* Emit variables

* Skip emitting invalid JSON

* Add unit tests
2023-01-18 14:31:59 -05:00
Jay Bharadia
d42de82bcd Fixes Issue #17072 Image is displayed to small in the Editing Image panel #17072 (#17216) 2023-01-18 14:16:40 +00:00
ian
af2afd0d4e Fix fetching from related collection in drawer item (#17210) 2023-01-18 15:21:41 +08:00
Brainslug
66f4e89978 added frontend sorting for flows (#17202) 2023-01-17 11:07:38 +01:00
Azri Kahar
07269b9b86 update locale name for zh-TW (#17199) 2023-01-17 16:25:37 +08:00
ian
25e3c16b3f Use countDistinct for item and total counts (#17184)
* Use countDistinct for item and total counts

* Propagate changes to export sidebar detail

* Try to trigger GH actions

* fix use-collection mock

* cover countDistinct in use-items test

* simplify primaryKeyField usage

* Revert typing

* Update mock values for differentiation

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2023-01-17 16:18:34 +08:00
ian
3bd2c1cfd3 Catch logout error (#17139) 2023-01-13 13:01:38 -05:00
rijkvanzanten
5e27e8c928 v9.22.4 2023-01-11 17:47:39 -05:00
rijkvanzanten
065c77dc1d v9.22.4 2023-01-11 17:05:16 -05:00
rijkvanzanten
fa8821309e Fix app docs build 2023-01-11 12:14:44 -05:00
rijkvanzanten
b9a5005859 v9.22.2 2023-01-11 11:27:56 -05:00
Rijk van Zanten
73783d002d New Crowdin updates (#16911)
* New translations en-US.yaml (Thai)

* New translations en-US.yaml (Thai)

* New translations en-US.yaml (Greek)

* New translations en-US.yaml (Greek)

* New translations en-US.yaml (Thai)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Ukrainian)

* New translations en-US.yaml (Ukrainian)

* New translations en-US.yaml (Hindi)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Chinese Simplified)

* New translations en-US.yaml (Turkish)

* New translations en-US.yaml (Khmer)

* New translations en-US.yaml (English, United Kingdom)

* New translations en-US.yaml (English, United Kingdom)

* New translations en-US.yaml (Spanish)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (German)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Chinese Simplified)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Slovak)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Arabic)
2023-01-11 11:26:45 -05:00
rijkvanzanten
390b55354e Update in-app docs 2023-01-11 11:25:08 -05:00
Azri Kahar
4b89566496 Wrap mime-type display in span node (#17084) 2023-01-11 11:09:05 -05:00
Azri Kahar
bc41307f00 Fix page tracking debounced timeout (#16552)
* fix trackPage timeout resets

* tweak test
2023-01-10 16:56:52 -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
Azri Kahar
986984e113 Simplify calendar layout's first day options (#16617)
* Simplify calendar layout's first day options

* use type that is more technically accurate
2023-01-09 17:19:49 -05:00
Pascal Jufer
c16be6f644 Type fixes in app (part 1) (#16545)
* Fix paths of imports

* Process not-found.vue as ts

To prevent the following error from 'vue-tsc':
  error TS6504: File '/Users/pascal/Development/directus/app/src/modules/insights/routes/not-found.vue.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?

Note: We could also enable 'allowJS' but since this is the only js file
this seems to be a more fitting fix

* Drop hljs language definition for GraphQL (now in core)

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2023-01-09 18:29:03 +00:00
Azri Kahar
bc82c7bb8c Throttle idle event listeners (#16555)
* throttle idle event listeners

* export timeout duration to use it in test directly
2023-01-09 12:13:49 -05:00
Andrii Trubai
216930ee92 Render-template layout fix (#16476) 2023-01-09 11:58:32 -05:00
ian
daf931a442 Add Khmer (Cambodia) language for i18n (#17007)
* Add Khmer (Cambodia) language for i18n

* Add translation file

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-01-05 15:06:17 -05:00
Azri Kahar
0122c4da4b Add bottom margin to Slider interface to account for field note (#17024)
* add margin when thumb label is always visible

* add z-index to thumb label for field note

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-01-05 08:31:15 -05:00
Brainslug
9f60b0f31d Remove auto-increment primary key when saving as copy (#16966)
* check for auto increment when saving as copy

* updated check to cover uuid generated IDs

* attempt to test use-item composable

* updated test objects

* do not rely on is_generated

* fix readonly regression

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2023-01-05 19:07:11 +08:00
Azri Kahar
446dbb87c7 fix removal of item in local storage (#16581) 2023-01-05 11:17:00 +01:00
Brainslug
cbd2af050b Implements server sort in o2m table interface (#16897)
* implements server sort when dealing with multple relational pages

* always use server sort

* fixed unsetting sort

* removed frontend sorting

* make loading total count more accurate

* remove removed prop

Co-authored-by: Nitwel <mail@nitwel.de>
2023-01-04 16:32:05 +01:00
Nitwel
2ac022d286 Extension Improvements (#16822)
* add link command and small improvements

* put local bundles into own folder on link

* get rid of packs and add bundle support for local extensions

* make bundle type extensions work locally and remove traces of pack

* fix hot reloading of bundles

* fix app.js not refreshing

* fixed linter errors

* add endpoint to install extensions

* update package.json validation and support top level extensions

* update endpoints

* added some URL escapes and ran linter

* remove installation part

* readd endpoint

* update dependencies

* fix types and validation in extension-sdk

* run linter

* fix linter

* add defaults to manifest

* Added missing constant export

* ensure all the extension folders

* ignore unneeded vite error

* update linking process

* run parser separate

* add await

* fixed linter errors

Co-authored-by: Brainslug <tim@brainslug.nl>
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-01-04 15:20:33 +01:00
Gerard Lamusse
9f06c36e0d Disable field selection for alias fields in the system-filter component when functions are used (#14314)
* Disable selecting alias fields to filter on

* Only disable alias fields when in condition mode
2023-01-04 13:27:13 +01:00
Andrii Trubai
04497ccbd7 Fix translations display width (#16525) 2023-01-04 12:21:58 +01:00
ian
d01c4cbedf Allow env access in Flows Run Script operation (#16111)
* Allow env access in Flows Run Script operation

* Add env variable

* Expose env for consistency

* Remove global variable from run script operation

* Rename env to FLOWS_ENV_ALLOW_LIST

* Use env within data for consistency

* Remove env notice in run script operation

* Remove translation and tests

* Fix unit test

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2023-01-04 10:39:52 +01:00
Azri Kahar
6bf5de1f9d Re-use getEndpoint utility function (#16700)
* re-use getEndpoint util

* rename endpoint var to route in calendar layout

* move loading below early return statements
2022-12-23 11:50:21 -05:00
Azri Kahar
8080e87d46 Minor codestyle tweaks to datetime display & interface (#16678)
* Minor codestyle tweaks to datetime display

* tweak datetime interface

* use all instead of each
2022-12-23 11:49:18 -05:00
Rijk van Zanten
40f94e6907 Patch Tuesday 🐸 (#16875)
* Update versions

* Fix usage of fullcalendar

* Patch Tuesday Additions 🐸🐸 (#16878)

* Interop default in vitest

* Update exif-reader

* remove deprecated @types/pino

* remove old "grant" package type shim

* Small clean-up of dependencies (#16576)

* Remove outdated type deps & update concurrently

* fix lock file

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

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2022-12-23 10:45:15 -05:00
Azri Kahar
fdeddf0118 Fix use-items loading state when an existing request gets canceled (#16881)
* prevent canceled requests from clearing loadingTimeout

* rename CancelTokenSource variable

* don't set loading to false if there's still loadingTimeout

* updated request cancellation to use the abort controller

* azri's getItemCount fix

* prevent cancelled requests from throwing errors

* prevent count request from firing twice

* Remove fetchOnInit option

Co-authored-by: Brainslug <tim@brainslug.nl>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-12-22 21:31:43 +00:00
rijkvanzanten
602f5db4f7 v9.22.1 2022-12-21 17:12:11 -05:00
rijkvanzanten
8f0fb8b40f v9.22.0 2022-12-21 14:33:04 -05:00
Rijk van Zanten
0402629131 New Crowdin updates (#16660)
* New translations en-US.yaml (German)

* New translations en-US.yaml (Dutch)

* New translations en-US.yaml (Italian)

* New translations en-US.yaml (Chinese Simplified)

* New translations en-US.yaml (French, Canada)

* Update source file en-US.yaml

* New translations en-US.yaml (Persian)

* New translations en-US.yaml (French)

* New translations en-US.yaml (Hungarian)

* New translations en-US.yaml (Persian)

* New translations en-US.yaml (Persian)

* New translations en-US.yaml (German)

* New translations en-US.yaml (Italian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Arabic)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (Serbian (Latin))

* New translations en-US.yaml (Serbian (Latin))

* New translations en-US.yaml (Russian)

* New translations en-US.yaml (German)
2022-12-21 14:23:00 -05:00
rijkvanzanten
ad8dccd6da Update docs 2022-12-21 14:19:50 -05:00
Rijk van Zanten
519ad3562c Fetch item/total counts separate (#16870)
* Fetch item/total counts separate

* try to add test

* use relative path when importing types

* Async reload counts on batch operations

* Refresh total/item count nicer

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2022-12-21 12:41:14 -05:00
ian
f1a8e0446f Fix duplicated results and functions in nested filters (#14798)
* Speed query up by reusing existing aliases which reduces table joins

* Use subquery in top level m2o to remove duplicates

* Fix linting

* Apply distinct on primary key field in subqueries

* Use distinct instead as there are only primary keys

* Apply subquery on top level

* Try remove sub sub query

* Test if working for all vendors

* Add support for _none and _some

* Use subquery only when field depth > 1

* Add tests

* Use original table names for columns with functions (#14690)

* Use original table names for columns with functions

* Extract filter function path parsing as shared util

* Fix filter function path when adding node

* Pass the originalCollectionName into filter functions

* Update unit test

* Replace functions within deep GraphQL

* Fix invalid operator error for _none and _some

* Add filter function tests

* Revert triggering for all vendors

* Simplify aliasMap

* Replace functions in filter within GraphQL aggregate query

* Add API support for filtering of alias field

* Mark schema as optional

* Shift logical operators upwards

* Separate recursive parseFilter

* Rework shifting of logical operators

* Error on invalid usage of _none and _some

* Use inner join to preserve sort order

* Run tests for all vendors

* Reuse aliasMap for sort and filter

* Sort on top level query

* Remove unnecessary limit on wrapper query

* Refactor applyQuery options

* Remove duplicates from nested multi relational sort

* Fix offset in MSSQL requiring OrderBy

* Disable schema cache

* Use inner query only for nested sort or multi relational filter

* Fix MSSQL duplicate order column

* Use inner query only for multi relational

* Additional integration tests

* Order within partition for multi relational sorts

* Rename to directus_row_number

* Fix unit test

* Add base sort and filter tests

* Fix Oracle uppercased rowNumber column

* Fix unit test

* Fix top level query sort with function

* Parse functions in inner query

* Increase clarity with knex.ref()

* Remove sort filter for top level primary key

* Fix unit test

* Bypass queries with groupBy

* Add collection to aliasMap to fix functions in nested sort

* Fix multi relational sort with functions

* Add tests for filter and sort with functions

* Fix accidental deletion of brackets

* Fix top level alias filter node interface

* Update M2M sort tests

* Add M2A tests

* Cast m2a primary key as varchar2 for oracle

* Enable filtering tests for M2A

* Fix prototype polluting assignment in aliasMap

* Remove unnecessary currentKey

* Simplify code to increase readability

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>

* Fix linting and missing 'this' error

* Revert optional chaining

* Add mysql5 to tests

* Fix mysql5 missing rowNumber()

* Overcome indexing delays in MySQL5

* Verify MySQL5 sorting is in order as the result count varies between runs

* Skip joining when sorting field already exists

* Simplify variable assignment

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

* Fix linting

* Reduce duplicate logic with vars

* Transform _func fields in GraphQL only for valid functions

* Fix unit test

* Fix unsupported date_part() in CrDB

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
Co-authored-by: Roger Stringer <roger@directus.io>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2022-12-21 11:56:18 -05:00
Pascal Jufer
8f5a072352 Enhance loading logic in image component (#16538)
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
2022-12-19 11:06:07 +01:00
Brainslug
7ae8441214 fixed comma separated input for filters (#16618) 2022-12-19 10:21:20 +01:00
Brainslug
ca93f5cb1d Add support for custom JS embeds in the App (#16650)
* add embed hook definitions

* inject embeds in the App html

* fixed typo

* removed unnecessary env parameter

* Added comment marking the custom embeds

* attempt to add test for createApp

* mock db in app test

* temporarily set log style to raw in test

* one more round

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2022-12-17 20:14:30 -05:00
Brainslug
511c8d368b Fix json serialization (#16558)
* fix copying json fields

* fixed preset filter type

* handling fallback in copyToClipboard function

* add test

* try parsing json content on paste

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2022-12-15 10:40:43 +01:00