PR review changes

This commit is contained in:
Matej Bačo
2022-08-24 15:07:18 +00:00
parent 5e9acf59e4
commit cb6a186c5d
8 changed files with 44 additions and 35 deletions
+9 -2
View File
@@ -1965,7 +1965,7 @@ $collections = [
'$id' => ID::custom('vars'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 1000000,
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
@@ -3114,7 +3114,7 @@ $collections = [
'required' => true,
'default' => null,
'array' => false,
'filters' => []
'filters' => [ 'encrypt' ]
]
],
'indexes' => [
@@ -3132,6 +3132,13 @@ $collections = [
'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC, Database::ORDER_ASC],
],
[
'$id' => '_key_key',
'type' => Database::INDEX_KEY,
'attributes' => ['key'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
],
],
];
+6 -6
View File
@@ -529,6 +529,11 @@ return [
'description' => 'Domain with the requested ID could not be found.',
'code' => 404,
],
Exception::DOMAIN_ALREADY_EXISTS => [
'name' => Exception::DOMAIN_ALREADY_EXISTS,
'description' => 'A Domain with the requested ID already exists.',
'code' => 409,
],
Exception::VARIABLE_NOT_FOUND => [
'name' => Exception::VARIABLE_NOT_FOUND,
'description' => 'Variable with the requested ID could not be found.',
@@ -539,14 +544,9 @@ return [
'description' => 'Variable with the same ID already exists in your project.',
'code' => 409,
],
Exception::DOCUMENT_MISSING_PAYLOAD => [
'name' => Exception::DOCUMENT_MISSING_PAYLOAD,
'description' => 'The document payload is missing.',
'code' => 400,
],
Exception::VARIABLE_MISSING_PAYLOAD => [
'name' => Exception::VARIABLE_MISSING_PAYLOAD,
'description' => 'You didn\'t specify either variable key nor value.',
'description' => 'The variable key or value is missing.',
'code' => 400,
],
Exception::DOMAIN_VERIFICATION_FAILED => [
+10 -8
View File
@@ -82,7 +82,7 @@ App::post('/v1/functions')
'scheduleNext' => null,
'timeout' => $timeout,
'search' => implode(' ', [$functionId, $name, $runtime]),
'vars' => []
'vars' => null
]));
$eventsInstance->setParam('functionId', $function->getId());
@@ -1209,20 +1209,22 @@ App::post('/v1/functions/:functionId/variables')
}
$variable = new Document([
'$id' => $dbForProject->getId(),
'$read' => ['role:all'],
'$write' => ['role:all'],
'$id' => ID::unique(),
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
'functionInternalId' => $function->getInternalId(),
'functionId' => $function->getId(),
'key' => $key,
'value' => $value,
'vars' => null
'value' => $value
]);
try {
$variable = $dbForProject->createDocument('variables', $variable);
} catch (DuplicateException $th) {
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
throw new Exception('Variable key already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
}
$dbForProject->deleteCachedDocument('functions', $function->getId());
@@ -1340,7 +1342,7 @@ App::put('/v1/functions/:functionId/variables/:variableId')
try {
$dbForProject->updateDocument('variables', $variable->getId(), $variable);
} catch (DuplicateException $th) {
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
throw new Exception('Variable key already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
}
$dbForProject->deleteCachedDocument('functions', $function->getId());
+1 -1
View File
@@ -1 +1 @@
Create a new function variable. These variables can be accessed within functions using the `env` object received through the payload of an execution.
Create a new function variable. These variables can be accessed within function in the `env` object under the request variable.
+1 -1
View File
@@ -1 +1 @@
Get a list of all variables that are currently active on your function.
Get a list of all variables of a specific function.
@@ -23,16 +23,16 @@ class Database extends Model
'example' => 'My Database',
])
->addRule('$createdAt', [
'type' => self::TYPE_INTEGER,
'description' => 'Collection creation date in Unix timestamp.',
'default' => 0,
'example' => 1592981250,
'type' => self::TYPE_DATETIME,
'description' => 'Database creation date in Datetime',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('$updatedAt', [
'type' => self::TYPE_INTEGER,
'description' => 'Collection update date in Unix timestamp.',
'default' => 0,
'example' => 1592981250,
'type' => self::TYPE_DATETIME,
'description' => 'Database update date in Datetime',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
;
}
+1 -1
View File
@@ -36,7 +36,7 @@ class Token extends Model
])
->addRule('expire', [
'type' => self::TYPE_DATETIME,
'description' => 'Token expiration date in Unix timestamp.',
'description' => 'Token expiration date in Datetime.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
@@ -17,16 +17,16 @@ class Variable extends Model
'example' => '5e5ea5c16897e',
])
->addRule('$createdAt', [
'type' => self::TYPE_INTEGER,
'description' => 'Variable creation date in Unix timestamp.',
'default' => 0,
'example' => 1592981250,
'type' => self::TYPE_DATETIME,
'description' => 'Variable creation date in Datetime',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('$updatedAt', [
'type' => self::TYPE_INTEGER,
'description' => 'Variable update date in Unix timestamp.',
'default' => 0,
'example' => 1592981250,
'type' => self::TYPE_DATETIME,
'description' => 'Variable creation date in Datetime',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('key', [
'type' => self::TYPE_STRING,