Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Graphql (#938)
Browse files Browse the repository at this point in the history
* Return object in delete after hook instead of onli ID (#882)

* Add fix for big file sizes

Closes #750

* Add migrations for hash and single-file

* Show correct fields in roles.users

For some reason the database column for options was empty

Closes https://github.com/directus/app/issues/1471

* Delete ISSUE_TEMPLATE.md

* security notice

* Add check for mod_php before setting php_value for upload size

This will prevent errors on systems that don't allow overriding the php
values from within the .htaccess files. This will only check for php 7+
though, as the mod_php directive is version specific. This is okay for
now, as we officially only support PHP 7.1+

* Change field width from integer to string

This will allow the app to render the fields in the correct widths
starting with v7.2.

* Issue fix #854 (#896)

* Add migrations for setting field notes and widths

Lays out the settings a bit nicer and adds setting descriptions.

Fixes https://github.com/directus/app/issues/1379

* Fix sort order of fields on install

* Increase specificity of migrations so it doesn't target non-settings

* Move collection notes to the DB

I'm aware that this makes them english only for the time being.
Once we implement the using the translation column in the app, we
can make them properly translatable.

* Fix abstraction name

* Add migrations for misc fields

Sorting of files, making a couple interfaces required, etc

* Bump version

* Fix: Wrong MIME for extentions in uppercase (#895)

* FEAT more events that invalidate the cache (#892)

* Allowing string relations (#800)

* emoji support for comments and bookmark names

* Use JSON interface for system collections

* Fixing custom primary key primary key column name (#881)

Swapping this variable seems to resolve the issue.

* Bump version

* Issue #885 (#898)

* Test cases : AUthentication - Auth, Forgot Password, Collections - Create, Delete

* Issue#885 - Done

* #885 Removed Test cases

* Issue #886 (#899)

* Test cases : AUthentication - Auth, Forgot Password, Collections - Create, Delete

* Issue#885 - Done

* Issue#886 - Done

* #886 Reverted unwanted code

* Issue #884 (#901)

* Test cases : AUthentication - Auth, Forgot Password, Collections - Create, Delete

* #884 Done

* #884 Removed Test cases

* Issue #884 - Change (#907)

* Test cases : AUthentication - Auth, Forgot Password, Collections - Create, Delete

* #884 Done

* #884 Removed Test cases

* #884 change

* Fix#810 (#908)

* Test cases : AUthentication - Auth, Forgot Password, Collections - Create, Delete

* #810 done

* #810 Reverting Test Cases

* Issue Fix #902 (#909)

* Issue fix #902

* Add migration for allow value nullable in settings table

* Set texttype for value field

* Doc issue fix #84 (#910)

* Issue fix #841 (#911)

* Increase expiry time of tokens from 5 to 20 minutes (#913)

It should still be pretty secure. This allows the app to go easier on
the refreshing, and it makes sure that you can upload large files
without having the token expire halfway through.

* Fix missing ref to 5 min exp

* Issue Fix #863 (#916)

* Issue fix #853 (#918)

* Issue Fix #920 (#922)

* Issue Fix #920

* Issue Fix #920

* Issue fix #879 (#924)

* [thumbnailer] Support for files in subdirectories (#856)

Many websites store images in a complex directory structure. This PR
makes it possible to use thumbnailer in such cases.

For instance :
`/thumbnail/_/100/100/crop/good/complex/path/to/some-image.jpg

* defaults cors.max-age to 600 (#921)

* Bump version

* Generate GraphQL schema file which support primary-key, text-input and numeric interfaces.

* Implement graphql-php server.

* GraphQL type for DirectUs files

* Code cleanup.

* Adding custom scalar support for Date, Datetime, JSON

* Adding support for the m2o type in schema generation.

* Adding support for m2o type.

* Support for O2M.
GraphQL type for Directus Role.
Rename GraphQL types for Directus user, files.

* Adding pagination support.

* Code cleanup.

* Adding time scalar type.

* Adding meta support.

* Search filter approach 1.

* Search result.

* Adding support for AND and OR logical filter.

* Rebase with master.

* Adding support for Activity, Collection Preset, Collection, Field type. Change the naming convention. Adding pascal case function in string utils.

* Adding support for setting collection.

* Adding support for Folder, Permission, Relation, Revision collection.

* Adding README.md

* Update README.md

* Change naming convention to snake_case.

* Change in naming convention. Merge list and single query into list query by adding additional arg `id`.
  • Loading branch information
hemratna committed May 7, 2019
1 parent 8c21e1f commit 962f515
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 263 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "@directus/api",
"private": true,
"version": "2.0.22",
"version": "2.0.23",
"description": "Directus API",
"main": "index.js",
"repository": "directus/api",
Expand Down
2 changes: 1 addition & 1 deletion src/core/Directus/Application/Application.php
Expand Up @@ -13,7 +13,7 @@ class Application extends App
*
* @var string
*/
const DIRECTUS_VERSION = '2.0.22';
const DIRECTUS_VERSION = '2.0.23';

/**
* NOT USED
Expand Down
Expand Up @@ -1407,7 +1407,23 @@ protected function doFilter(Builder $query, $column, $condition, $table)
}

// TODO: Move this into QueryBuilder if possible
if (in_array($operator, ['like']) && $field->isManyToOne()) {
if($field->isOneToMany()){
$relationship = $field->getRelationship();
$relatedTable = $relationship->getCollectionMany();
$relatedRightColumn = $relationship->getFieldMany();
$tableSchema = SchemaService::getCollection($relatedTable);
$relatedTableColumns = $tableSchema->getFields();

$query->orWhereRelational($this->primaryKeyFieldName, $relatedTable, null, $relatedRightColumn, function(Builder $query) use ($column, $relatedTable, $relatedTableColumns, $value) {
foreach ($relatedTableColumns as $column) {
$isNumeric = $this->getSchemaManager()->isNumericType($column->getType());
$isString = $this->getSchemaManager()->isStringType($column->getType());
if (!$column->isAlias() && ($isNumeric || $isString)) {
$query->orWhereLike($column->getName(), $value);
}
}
});
} else if(in_array($operator, ['like']) && $field->isManyToOne()) {
$relatedTable = $field->getRelationship()->getCollectionOne();
$tableSchema = SchemaService::getCollection($relatedTable);
$relatedTableColumns = $tableSchema->getFields();
Expand Down
110 changes: 38 additions & 72 deletions src/core/Directus/Filesystem/Thumbnailer.php
Expand Up @@ -45,7 +45,7 @@ class Thumbnailer {
* @param Filesystem $main
* @param Filesystem $thumb
* @param array $config
* @param string $path in the form '_/100/100/crop/good/some-image.jpg'
* @param string $path in the form '_/100/100/crop/good/path/to/some-image.jpg'
*
* @throws Exception
*/
Expand Down Expand Up @@ -217,84 +217,50 @@ public function crop()
*/
public function extractThumbnailParams($thumbnailUrlPath)
{
try {
if ($this->thumbnailParams) {
return $this->thumbnailParams;
}

$urlSegments = explode('/', $thumbnailUrlPath);

// pull the env out of the segments
array_shift($urlSegments);

if (! $urlSegments) {
throw new Exception('Invalid thumbnailUrlPath.');
}

// pop off the filename
$fileName = ArrayUtils::pop($urlSegments);

// make sure filename is valid
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$name = pathinfo($fileName, PATHINFO_FILENAME);
if (! $this->isSupportedFileExtension($ext)) {
throw new Exception('Invalid file extension.');
}

$thumbnailParams = [
'fileName' => filename_put_ext($name, $ext),
'fileExt' => $ext
];

foreach ($urlSegments as $segment) {

if (! $segment) continue;

$hasWidth = ArrayUtils::get($thumbnailParams, 'width');
$hasHeight = ArrayUtils::get($thumbnailParams, 'height');
// extract width and height
if ((!$hasWidth || !$hasHeight) && is_numeric($segment)) {
if (!$hasWidth) {
ArrayUtils::set($thumbnailParams, 'width', $segment);
} else if (!$hasHeight) {
ArrayUtils::set($thumbnailParams, 'height', $segment);
}
}

// extract action and quality
else {
if (!ArrayUtils::get($thumbnailParams, 'action')) {
ArrayUtils::set($thumbnailParams, 'action', $segment);
} else if (!ArrayUtils::get($thumbnailParams, 'quality')) {
ArrayUtils::set($thumbnailParams, 'quality', $segment);
}
}
}
// cache
if ($this->thumbnailParams) {
return $this->thumbnailParams;
}

// validate
if (! ArrayUtils::contains($thumbnailParams, [
'width',
'height'
])) {
throw new Exception('No height or width provided.');
}
// get URL parts
// https://docs.directus.io/guides/thumbnailer.html#url-syntax
$urlSegments = explode('/', $thumbnailUrlPath);
if (count($urlSegments) < 6) {
throw new Exception('Invalid URL syntax.');
}

// set default action, if needed
if (! ArrayUtils::exists($thumbnailParams, 'action')) {
ArrayUtils::set($thumbnailParams, 'action', null);
}
// pull the env out of the segments
array_shift($urlSegments);

// set quality to null, if needed
if (! ArrayUtils::exists($thumbnailParams, 'quality')) {
ArrayUtils::set($thumbnailParams, 'quality', null);
}
// set thumbnail parameters
$thumbnailParams = [
'action' => filter_var($urlSegments[2], FILTER_SANITIZE_STRING),
'height' => filter_var($urlSegments[1], FILTER_SANITIZE_NUMBER_INT),
'quality' => filter_var($urlSegments[3], FILTER_SANITIZE_STRING),
'width' => filter_var($urlSegments[0], FILTER_SANITIZE_NUMBER_INT),
];

return $thumbnailParams;
// validate parameters
if (! ArrayUtils::contains($thumbnailParams, [
'width',
'height'
])) {
throw new Exception('No height or width provided.');
}

catch (Exception $e) {
throw $e;
// make sure filename is valid
$filename = implode('/', array_slice($urlSegments, 4));
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$name = pathinfo($filename, PATHINFO_FILENAME);
if (! $this->isSupportedFileExtension($ext)) {
throw new Exception('Invalid file extension.');
}

// Set thumbnail filename parameters
$thumbnailParams['fileName'] = $filename;
$thumbnailParams['fileExt'] = $ext;

return $thumbnailParams;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/core/Directus/GraphQL/Collection/CollectionList.php
Expand Up @@ -16,6 +16,7 @@ class CollectionList
public function __construct()
{
$this->param = ['fields' => '*.*.*.*.*.*', 'meta' => '*'];
$this->id = ['id' => Types::int()];
$this->limit = ['limit' => Types::int()];
$this->offset = ['offset' => Types::int()];
$this->container = Application::getInstance()->getContainer();
Expand All @@ -28,8 +29,8 @@ protected function convertArgsToFilter($args)
$filters = [];
foreach ($this->param['filter'] as $filter => $value) {
/**
* TODO :: Need to rewrite the code for better readiablity.
*/
* TODO :: Need to rewrite the code for better readiablity.
*/
if ($filter == 'or' || $filter == 'and') {
$c = 0;
foreach ($value as $innerFilters) {
Expand Down

0 comments on commit 962f515

Please sign in to comment.