From d07cbe5b750d645bd9aeec1721871d35b830c925 Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Tue, 2 Jul 2024 22:26:05 +0100 Subject: [PATCH] enh: modify usergroup column backend Signed-off-by: Cleopatra Enjeck M --- lib/Db/Column.php | 4 +- lib/Db/LegacyRowMapper.php | 5 - lib/Db/Row2Mapper.php | 16 +- lib/Db/RowCellMapperSuper.php | 15 - lib/Service/ColumnTypes/UsergroupBusiness.php | 1 - openapi.json | 1483 +++++++---------- src/types/openapi/openapi.ts | 255 +-- 7 files changed, 661 insertions(+), 1118 deletions(-) diff --git a/lib/Db/Column.php b/lib/Db/Column.php index 5a408dc46..ddaae5b15 100644 --- a/lib/Db/Column.php +++ b/lib/Db/Column.php @@ -149,8 +149,8 @@ public function __construct() { public function getUsergroupDefaultArray():array { $default = $this->getUsergroupDefault(); - if ($default !== "" && $default !== null && $default !== 'null') { - return \json_decode($default, true); + if ($default !== "" && $default !== null) { + return \json_decode($default, true) ?? []; } else { return []; } diff --git a/lib/Db/LegacyRowMapper.php b/lib/Db/LegacyRowMapper.php index 2738cfd21..ae7b3996b 100644 --- a/lib/Db/LegacyRowMapper.php +++ b/lib/Db/LegacyRowMapper.php @@ -8,7 +8,6 @@ use OCA\Tables\Db\ColumnTypes\SelectionColumnQB; use OCA\Tables\Db\ColumnTypes\SuperColumnQB; use OCA\Tables\Db\ColumnTypes\TextColumnQB; -use OCA\Tables\Db\ColumnTypes\UsergroupColumnQB; use OCA\Tables\Errors\InternalError; use OCA\Tables\Helper\UserHelper; use OCP\AppFramework\Db\DoesNotExistException; @@ -30,7 +29,6 @@ class LegacyRowMapper extends QBMapper { protected SelectionColumnQB $selectionColumnQB; protected NumberColumnQB $numberColumnQB; protected DatetimeColumnQB $datetimeColumnQB; - protected UsergroupColumnQB $usergroupColumnQB; protected SuperColumnQB $genericColumnQB; protected ColumnMapper $columnMapper; protected LoggerInterface $logger; @@ -46,7 +44,6 @@ public function __construct( SelectionColumnQB $selectionColumnQB, NumberColumnQB $numberColumnQB, DatetimeColumnQB $datetimeColumnQB, - UsergroupColumnQB $usergroupColumnQB, SuperColumnQB $columnQB, ColumnMapper $columnMapper, UserHelper $userHelper, @@ -57,7 +54,6 @@ public function __construct( $this->numberColumnQB = $numberColumnQB; $this->selectionColumnQB = $selectionColumnQB; $this->datetimeColumnQB = $datetimeColumnQB; - $this->usergroupColumnQB = $usergroupColumnQB; $this->genericColumnQB = $columnQB; $this->columnMapper = $columnMapper; $this->userHelper = $userHelper; @@ -78,7 +74,6 @@ private function setPlatform() { $this->numberColumnQB->setPlatform($this->platform); $this->selectionColumnQB->setPlatform($this->platform); $this->datetimeColumnQB->setPlatform($this->platform); - $this->usergroupColumnQB->setPlatform($this->platform); } /** diff --git a/lib/Db/Row2Mapper.php b/lib/Db/Row2Mapper.php index 3f964682f..a0c5ab1fc 100644 --- a/lib/Db/Row2Mapper.php +++ b/lib/Db/Row2Mapper.php @@ -10,6 +10,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\AppFramework\Db\QBMapper; +use OCP\AppFramework\Db\TTransactional; use OCP\DB\Exception; use OCP\DB\IResult; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -21,6 +22,8 @@ use Throwable; class Row2Mapper { + use TTransactional; + private RowSleeveMapper $rowSleeveMapper; private ?string $userId = null; private IDBConnection $db; @@ -524,7 +527,7 @@ private function parseEntities(IResult $result, array $sleeves, array $columnTyp $value = $this->formatValue($this->columns[$rowData['column_id']], $rowData['value'], 'out', $rowData['value_type']); $compositeKey = (string)$rowData['row_id'] . ',' . (string)$rowData['column_id']; - if ($columnTypes[$rowData['column_id']] == 'usergroup') { + if ($columnTypes[$rowData['column_id']] === Column::TYPE_USERGROUP) { if (array_key_exists($compositeKey, $rowValues)) { $rowValues[$compositeKey][] = $value; } else { @@ -688,7 +691,7 @@ private function insertCell(int $rowId, int $columnId, $value, ?string $lastEdit $v = $this->formatValue($this->columns[$columnId], $value, 'in'); - if ($this->columns[$columnId]->getType() == 'usergroup') { + if ($this->columns[$columnId]->getType() === Column::TYPE_USERGROUP) { foreach ($v as $val) { /** @var RowCellSuper $cell */ $cell = new $cellClassName(); @@ -748,11 +751,12 @@ private function insertOrUpdateCell(int $rowId, int $columnId, $value): void { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } - if ($columnType == 'usergroup') { + if ($columnType === Column::TYPE_USERGROUP) { try { - // TODO Maybe these should be a transaction? - $cellMapper->deleteAllForRow($rowId); - $this->insertCell($rowId, $columnId, $value); + $this->atomic(function () use ($cellMapper, $rowId, $columnId, $value) { + $cellMapper->deleteAllForRow($rowId); + $this->insertCell($rowId, $columnId, $value); + }, $this->db); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); diff --git a/lib/Db/RowCellMapperSuper.php b/lib/Db/RowCellMapperSuper.php index 35f557a36..86f76509e 100644 --- a/lib/Db/RowCellMapperSuper.php +++ b/lib/Db/RowCellMapperSuper.php @@ -86,21 +86,6 @@ public function findByRowAndColumn(int $rowId, int $columnId): RowCellSuper { return $this->findEntity($qb); } - // /** - // * @throws MultipleObjectsReturnedException - // * @throws DoesNotExistException - // * @throws Exception - // */ - // public function findMultByRowAndColumn(int $rowId, int $columnId): array{ - // $qb = $this->db->getQueryBuilder(); - // $qb->select('*') - // ->from($this->tableName) - // ->where($qb->expr()->eq('row_id', $qb->createNamedParameter($rowId, IQueryBuilder::PARAM_INT))) - // ->andWhere($qb->expr()->eq('column_id', $qb->createNamedParameter($columnId, IQueryBuilder::PARAM_INT))); - // return $this->findEntities($qb); - // } - - /** * @throws MultipleObjectsReturnedException * @throws DoesNotExistException diff --git a/lib/Service/ColumnTypes/UsergroupBusiness.php b/lib/Service/ColumnTypes/UsergroupBusiness.php index bd390f9e1..5536077c4 100644 --- a/lib/Service/ColumnTypes/UsergroupBusiness.php +++ b/lib/Service/ColumnTypes/UsergroupBusiness.php @@ -40,7 +40,6 @@ public function canBeParsed($value, ?Column $column = null): bool { } foreach ($value as $v) { - // TODO: maybe check if key exists first if((array_key_exists('id', $v) && !is_string($v['id'])) && (array_key_exists('type', $v) && !is_int($v['type']))) { return false; } diff --git a/openapi.json b/openapi.json index 2f7da1097..90d212cda 100644 --- a/openapi.json +++ b/openapi.json @@ -2757,255 +2757,157 @@ "basic_auth": [] } ], - "parameters": [ - { - "name": "title", - "in": "query", - "description": "Title", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "type", - "in": "query", - "description": "Column main type", - "required": true, - "schema": { - "type": "string", - "enum": [ - "text", - "number", - "datetime", - "select", - "usergroup" - ] - } - }, - { - "name": "subtype", - "in": "query", - "description": "Column sub type", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "mandatory", - "in": "query", - "description": "Is the column mandatory", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "description", - "in": "query", - "description": "Description", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberPrefix", - "in": "query", - "description": "Prefix if the column is a number field", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberSuffix", - "in": "query", - "description": "Suffix if the column is a number field", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberDefault", - "in": "query", - "description": "Default number, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberMin", - "in": "query", - "description": "Min value, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberMax", - "in": "query", - "description": "Max number, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberDecimals", - "in": "query", - "description": "Number of decimals, if column is a number", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "textDefault", - "in": "query", - "description": "Default text, if column is a text", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "textAllowedPattern", - "in": "query", - "description": "Allowed pattern (regex) for text columns (not yet implemented)", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "textMaxLength", - "in": "query", - "description": "Max length, if column is a text", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "selectionOptions", - "in": "query", - "description": "Options for a selection (json array{id: int, label: string})", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "selectionDefault", - "in": "query", - "description": "Default option IDs for a selection (json int[])", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "datetimeDefault", - "in": "query", - "description": "Default value, if column is datetime", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "usergroupDefault", - "in": "query", - "description": "Default value, if column is usergroup", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "usergroupMultipleItems", - "in": "query", - "description": "Can select multiple users or/and groups, if column is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectUsers", - "in": "query", - "description": "Can select users, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectGroups", - "in": "query", - "description": "Can select groups, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "showUserStatus", - "in": "query", - "description": "Whether to show the user's status, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "selectedViewIds[]", - "in": "query", - "description": "View IDs where this column should be added to be presented", - "schema": { - "type": "array", - "nullable": true, - "default": [], - "items": { - "type": "integer", - "format": "int64" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "title", + "type", + "mandatory" + ], + "properties": { + "title": { + "type": "string", + "description": "Title" + }, + "type": { + "type": "string", + "enum": [ + "text", + "number", + "datetime", + "select", + "usergroup" + ], + "description": "Column main type" + }, + "subtype": { + "type": "string", + "nullable": true, + "description": "Column sub type" + }, + "mandatory": { + "type": "boolean", + "description": "Is the column mandatory" + }, + "description": { + "type": "string", + "nullable": true, + "description": "Description" + }, + "numberPrefix": { + "type": "string", + "nullable": true, + "description": "Prefix if the column is a number field" + }, + "numberSuffix": { + "type": "string", + "nullable": true, + "description": "Suffix if the column is a number field" + }, + "numberDefault": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Default number, if column is a number" + }, + "numberMin": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Min value, if column is a number" + }, + "numberMax": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Max number, if column is a number" + }, + "numberDecimals": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "Number of decimals, if column is a number" + }, + "textDefault": { + "type": "string", + "nullable": true, + "description": "Default text, if column is a text" + }, + "textAllowedPattern": { + "type": "string", + "nullable": true, + "description": "Allowed pattern (regex) for text columns (not yet implemented)" + }, + "textMaxLength": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "Max length, if column is a text" + }, + "selectionOptions": { + "type": "string", + "nullable": true, + "default": "", + "description": "Options for a selection (json array{id: int, label: string})" + }, + "selectionDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default option IDs for a selection (json int[])" + }, + "datetimeDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default value, if column is datetime" + }, + "usergroupDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default value, if column is usergroup" + }, + "usergroupMultipleItems": { + "type": "boolean", + "nullable": true, + "description": "Can select multiple users or/and groups, if column is usergroup" + }, + "usergroupSelectUsers": { + "type": "boolean", + "nullable": true, + "description": "Can select users, if column type is usergroup" + }, + "usergroupSelectGroups": { + "type": "boolean", + "nullable": true, + "description": "Can select groups, if column type is usergroup" + }, + "showUserStatus": { + "type": "boolean", + "nullable": true, + "description": "Whether to show the user's status, if column type is usergroup" + }, + "selectedViewIds": { + "type": "array", + "nullable": true, + "default": [], + "description": "View IDs where this column should be added to be presented", + "items": { + "type": "integer", + "format": "int64" + } + } + } } } - }, + } + }, + "parameters": [ { "name": "tableId", "in": "path", @@ -3192,276 +3094,168 @@ "basic_auth": [] } ], - "parameters": [ - { - "name": "tableId", - "in": "query", - "description": "Table ID", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "viewId", - "in": "query", - "description": "View ID", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "title", - "in": "query", - "description": "Title", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "type", - "in": "query", - "description": "Column main type", - "required": true, - "schema": { - "type": "string", - "enum": [ - "text", - "number", - "datetime", - "select", - "usergroup" - ] - } - }, - { - "name": "subtype", - "in": "query", - "description": "Column sub type", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "mandatory", - "in": "query", - "description": "Is the column mandatory", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "description", - "in": "query", - "description": "Description", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberPrefix", - "in": "query", - "description": "Prefix if the column is a number field", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberSuffix", - "in": "query", - "description": "Suffix if the column is a number field", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "numberDefault", - "in": "query", - "description": "Default number, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberMin", - "in": "query", - "description": "Min value, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberMax", - "in": "query", - "description": "Max number, if column is a number", - "schema": { - "type": "number", - "format": "float", - "nullable": true - } - }, - { - "name": "numberDecimals", - "in": "query", - "description": "Number of decimals, if column is a number", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "textDefault", - "in": "query", - "description": "Default text, if column is a text", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "textAllowedPattern", - "in": "query", - "description": "Allowed pattern (regex) for text columns (not yet implemented)", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "textMaxLength", - "in": "query", - "description": "Max length, if column is a text", - "schema": { - "type": "integer", - "format": "int64", - "nullable": true - } - }, - { - "name": "selectionOptions", - "in": "query", - "description": "Options for a selection (json array{id: int, label: string})", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "selectionDefault", - "in": "query", - "description": "Default option IDs for a selection (json int[])", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "datetimeDefault", - "in": "query", - "description": "Default value, if column is datetime", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "usergroupDefault", - "in": "query", - "description": "Default value, if column is usergroup (json array{id: string, type: int})", - "schema": { - "type": "string", - "nullable": true, - "default": "" - } - }, - { - "name": "usergroupMultipleItems", - "in": "query", - "description": "Can select multiple users or/and groups, if column is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectUsers", - "in": "query", - "description": "Can select users, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectGroups", - "in": "query", - "description": "Can select groups, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "showUserStatus", - "in": "query", - "description": "Whether to show the user's status, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "selectedViewIds[]", - "in": "query", - "description": "View IDs where this column should be added to be presented", - "schema": { - "type": "array", - "nullable": true, - "default": [], - "items": { - "type": "integer", - "format": "int64" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "title", + "type", + "mandatory" + ], + "properties": { + "tableId": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "Table ID" + }, + "viewId": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "View ID" + }, + "title": { + "type": "string", + "description": "Title" + }, + "type": { + "type": "string", + "enum": [ + "text", + "number", + "datetime", + "select", + "usergroup" + ], + "description": "Column main type" + }, + "subtype": { + "type": "string", + "nullable": true, + "description": "Column sub type" + }, + "mandatory": { + "type": "boolean", + "description": "Is the column mandatory" + }, + "description": { + "type": "string", + "nullable": true, + "description": "Description" + }, + "numberPrefix": { + "type": "string", + "nullable": true, + "description": "Prefix if the column is a number field" + }, + "numberSuffix": { + "type": "string", + "nullable": true, + "description": "Suffix if the column is a number field" + }, + "numberDefault": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Default number, if column is a number" + }, + "numberMin": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Min value, if column is a number" + }, + "numberMax": { + "type": "number", + "format": "double", + "nullable": true, + "description": "Max number, if column is a number" + }, + "numberDecimals": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "Number of decimals, if column is a number" + }, + "textDefault": { + "type": "string", + "nullable": true, + "description": "Default text, if column is a text" + }, + "textAllowedPattern": { + "type": "string", + "nullable": true, + "description": "Allowed pattern (regex) for text columns (not yet implemented)" + }, + "textMaxLength": { + "type": "integer", + "format": "int64", + "nullable": true, + "description": "Max length, if column is a text" + }, + "selectionOptions": { + "type": "string", + "nullable": true, + "default": "", + "description": "Options for a selection (json array{id: int, label: string})" + }, + "selectionDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default option IDs for a selection (json int[])" + }, + "datetimeDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default value, if column is datetime" + }, + "usergroupDefault": { + "type": "string", + "nullable": true, + "default": "", + "description": "Default value, if column is usergroup (json array{id: string, type: int})" + }, + "usergroupMultipleItems": { + "type": "boolean", + "nullable": true, + "description": "Can select multiple users or/and groups, if column is usergroup" + }, + "usergroupSelectUsers": { + "type": "boolean", + "nullable": true, + "description": "Can select users, if column type is usergroup" + }, + "usergroupSelectGroups": { + "type": "boolean", + "nullable": true, + "description": "Can select groups, if column type is usergroup" + }, + "showUserStatus": { + "type": "boolean", + "nullable": true, + "description": "Whether to show the user's status, if column type is usergroup" + }, + "selectedViewIds": { + "type": "array", + "nullable": true, + "default": [], + "description": "View IDs where this column should be added to be presented", + "items": { + "type": "integer", + "format": "int64" + } + } + } } } } - ], + }, "responses": { "200": { "description": "Column created", @@ -3635,72 +3429,38 @@ "type": "string", "nullable": true, "description": "Default value, if column is datetime" + }, + "usergroupDefault": { + "type": "string", + "nullable": true, + "description": "Default value, if column is usergroup" + }, + "usergroupMultipleItems": { + "type": "boolean", + "nullable": true, + "description": "Can select multiple users or/and groups, if column is usergroup" + }, + "usergroupSelectUsers": { + "type": "boolean", + "nullable": true, + "description": "Can select users, if column type is usergroup" + }, + "usergroupSelectGroups": { + "type": "boolean", + "nullable": true, + "description": "Can select groups, if column type is usergroup" + }, + "showUserStatus": { + "type": "boolean", + "nullable": true, + "description": "Whether to show the user's status, if column type is usergroup" } } } } - }, - { - "name": "usergroupDefault", - "in": "query", - "description": "Default value, if column is usergroup", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "usergroupMultipleItems", - "in": "query", - "description": "Can select multiple users or/and groups, if column is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectUsers", - "in": "query", - "description": "Can select users, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectGroups", - "in": "query", - "description": "Can select groups, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "showUserStatus", - "in": "query", - "description": "Whether to show the user's status, if column type is usergroup", - "schema": { - "type": "integer", - "nullable": true, - "enum": [ - 0, - 1 - ] - } - }, + } + }, + "parameters": [ { "name": "columnId", "in": "path", @@ -7210,105 +6970,77 @@ "basic_auth": [] } ], - "parameters": [ - { - "name": "baseNodeId", - "in": "query", - "description": "Context of the column creation", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "title", - "in": "query", - "description": "Title", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "selectionOptions", - "in": "query", - "description": "Json array{id: int, label: string} with options that can be selected, eg [{\"id\": 1, \"label\": \"first\"},{\"id\": 2, \"label\": \"second\"}]", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "selectionDefault", - "in": "query", - "description": "Json int|int[] for default selected option(s), eg 5 or [\"1\", \"8\"]", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "subtype", - "in": "query", - "description": "Subtype for the new column", - "schema": { - "type": "string", - "nullable": true, - "enum": [ - "progress", - "stars" - ] - } - }, - { - "name": "description", - "in": "query", - "description": "Description", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "selectedViewIds[]", - "in": "query", - "description": "View IDs where this columns should be added", - "schema": { - "type": "array", - "nullable": true, - "default": [], - "items": { - "type": "integer", - "format": "int64" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "baseNodeId", + "title", + "selectionOptions" + ], + "properties": { + "baseNodeId": { + "type": "integer", + "format": "int64", + "description": "Context of the column creation" + }, + "title": { + "type": "string", + "description": "Title" + }, + "selectionOptions": { + "type": "string", + "description": "Json array{id: int, label: string} with options that can be selected, eg [{\"id\": 1, \"label\": \"first\"},{\"id\": 2, \"label\": \"second\"}]" + }, + "selectionDefault": { + "type": "string", + "nullable": true, + "description": "Json int|int[] for default selected option(s), eg 5 or [\"1\", \"8\"]" + }, + "subtype": { + "type": "string", + "nullable": true, + "enum": [ + "progress", + "stars" + ], + "description": "Subtype for the new column" + }, + "description": { + "type": "string", + "nullable": true, + "description": "Description" + }, + "selectedViewIds": { + "type": "array", + "nullable": true, + "default": [], + "description": "View IDs where this columns should be added", + "items": { + "type": "integer", + "format": "int64" + } + }, + "mandatory": { + "type": "boolean", + "default": false, + "description": "Is mandatory" + }, + "baseNodeType": { + "type": "string", + "default": "table", + "enum": [ + "table", + "view" + ], + "description": "Context type of the column creation" + } + } } } - }, - { - "name": "mandatory", - "in": "query", - "description": "Is mandatory", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "baseNodeType", - "in": "query", - "description": "Context type of the column creation", - "schema": { - "type": "string", - "default": "table", - "enum": [ - "table", - "view" - ] - } } }, "parameters": [ @@ -7473,119 +7205,98 @@ } } } - } - } - }, - "/ocs/v2.php/apps/tables/api/2/columns/usergroup": { - "post": { - "operationId": "api_columns-create-usergroup-column", - "summary": "[api v2] Create new usergroup column", - "tags": [ - "api_columns" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], + } + } + }, + "/ocs/v2.php/apps/tables/api/2/columns/datetime": { + "post": { + "operationId": "api_columns-create-datetime-column", + "summary": "[api v2] Create new datetime column", + "description": "Specify a subtype to use any special datetime column", + "tags": [ + "api_columns" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "baseNodeId", + "title" + ], + "properties": { + "baseNodeId": { + "type": "integer", + "format": "int64", + "description": "Context of the column creation" + }, + "title": { + "type": "string", + "description": "Title" + }, + "datetimeDefault": { + "type": "string", + "nullable": true, + "enum": [ + "today", + "now" + ], + "description": "For a subtype 'date' you can set 'today'. For a main type or subtype 'time' you can set to 'now'." + }, + "subtype": { + "type": "string", + "nullable": true, + "enum": [ + "progress", + "stars" + ], + "description": "Subtype for the new column" + }, + "description": { + "type": "string", + "nullable": true, + "description": "Description" + }, + "selectedViewIds": { + "type": "array", + "nullable": true, + "default": [], + "description": "View IDs where this columns should be added", + "items": { + "type": "integer", + "format": "int64" + } + }, + "mandatory": { + "type": "boolean", + "default": false, + "description": "Is mandatory" + }, + "baseNodeType": { + "type": "string", + "default": "table", + "enum": [ + "table", + "view" + ], + "description": "Context type of the column creation" + } + } + } + } + } + }, "parameters": [ - { - "name": "baseNodeId", - "in": "query", - "description": "Context of the column creation", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "title", - "in": "query", - "description": "Title", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "datetimeDefault", - "in": "query", - "description": "For a subtype 'date' you can set 'today'. For a main type or subtype 'time' you can set to 'now'.", - "schema": { - "type": "string", - "nullable": true, - "enum": [ - "today", - "now" - ] - } - }, - { - "name": "subtype", - "in": "query", - "description": "Subtype for the new column", - "schema": { - "type": "string", - "nullable": true, - "enum": [ - "progress", - "stars" - ] - } - }, - { - "name": "description", - "in": "query", - "description": "Description", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "selectedViewIds[]", - "in": "query", - "description": "View IDs where this columns should be added", - "schema": { - "type": "array", - "nullable": true, - "default": [], - "items": { - "type": "integer", - "format": "int64" - } - } - }, - { - "name": "mandatory", - "in": "query", - "description": "Is mandatory", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "baseNodeType", - "in": "query", - "description": "Context type of the column creation", - "schema": { - "type": "string", - "default": "table", - "enum": [ - "table", - "view" - ] - } - }, { "name": "OCS-APIRequest", "in": "header", @@ -7765,136 +7476,82 @@ "basic_auth": [] } ], - "parameters": [ - { - "name": "baseNodeId", - "in": "query", - "description": "Context of the column creation", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "title", - "in": "query", - "description": "Title", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "usergroupDefault", - "in": "query", - "description": "Json array{id: string, type: int}, eg [{\"id\": \"admin\", \"type\": 0}, {\"id\": \"user1\", \"type\": 0}]", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "usergroupMultipleItems", - "in": "query", - "description": "Whether you can select multiple users or/and groups", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectUsers", - "in": "query", - "description": "Whether you can select users", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "usergroupSelectGroups", - "in": "query", - "description": "Whether you can select groups", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "showUserStatus", - "in": "query", - "description": "Whether to show the user's status", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "description", - "in": "query", - "description": "Description", - "schema": { - "type": "string", - "nullable": true - } - }, - { - "name": "selectedViewIds[]", - "in": "query", - "description": "View IDs where this columns should be added", - "schema": { - "type": "array", - "nullable": true, - "default": [], - "items": { - "type": "integer", - "format": "int64" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "baseNodeId", + "title" + ], + "properties": { + "baseNodeId": { + "type": "integer", + "format": "int64", + "description": "Context of the column creation" + }, + "title": { + "type": "string", + "description": "Title" + }, + "usergroupDefault": { + "type": "string", + "nullable": true, + "description": "Json array{id: string, type: int}, eg [{\"id\": \"admin\", \"type\": 0}, {\"id\": \"user1\", \"type\": 0}]" + }, + "usergroupMultipleItems": { + "type": "boolean", + "description": "Whether you can select multiple users or/and groups" + }, + "usergroupSelectUsers": { + "type": "boolean", + "description": "Whether you can select users" + }, + "usergroupSelectGroups": { + "type": "boolean", + "description": "Whether you can select groups" + }, + "showUserStatus": { + "type": "boolean", + "description": "Whether to show the user's status" + }, + "description": { + "type": "string", + "nullable": true, + "description": "Description" + }, + "selectedViewIds": { + "type": "array", + "nullable": true, + "default": [], + "description": "View IDs where this columns should be added", + "items": { + "type": "integer", + "format": "int64" + } + }, + "mandatory": { + "type": "boolean", + "default": false, + "description": "Is mandatory" + }, + "baseNodeType": { + "type": "string", + "default": "table", + "enum": [ + "table", + "view" + ], + "description": "Context type of the column creation" + } + } } } - }, - { - "name": "mandatory", - "in": "query", - "description": "Is mandatory", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "baseNodeType", - "in": "query", - "description": "Context type of the column creation", - "schema": { - "type": "string", - "default": "table", - "enum": [ - "table", - "view" - ] - } - }, + } + }, + "parameters": [ { "name": "OCS-APIRequest", "in": "header", diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index f40ab776e..5e633c5da 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1327,7 +1327,7 @@ export type operations = { * @description Column main type * @enum {string} */ - type: "text" | "number" | "datetime" | "select"; + type: "text" | "number" | "datetime" | "select" | "usergroup"; /** @description Column sub type */ subtype?: string | null; /** @description Is the column mandatory */ @@ -1382,63 +1382,25 @@ export type operations = { * @default */ datetimeDefault?: string | null; + /** + * @description Default value, if column is usergroup + * @default + */ + usergroupDefault?: string | null; + /** @description Can select multiple users or/and groups, if column is usergroup */ + usergroupMultipleItems?: boolean | null; + /** @description Can select users, if column type is usergroup */ + usergroupSelectUsers?: boolean | null; + /** @description Can select groups, if column type is usergroup */ + usergroupSelectGroups?: boolean | null; + /** @description Whether to show the user's status, if column type is usergroup */ + showUserStatus?: boolean | null; /** * @description View IDs where this column should be added to be presented * @default [] */ selectedViewIds?: number[] | null; }; - query: { - /** @description Title */ - title: string; - /** @description Column main type */ - type: "text" | "number" | "datetime" | "select" | "usergroup"; - /** @description Column sub type */ - subtype?: string | null; - /** @description Is the column mandatory */ - mandatory: 0 | 1; - /** @description Description */ - description?: string | null; - /** @description Prefix if the column is a number field */ - numberPrefix?: string | null; - /** @description Suffix if the column is a number field */ - numberSuffix?: string | null; - /** @description Default number, if column is a number */ - numberDefault?: number | null; - /** @description Min value, if column is a number */ - numberMin?: number | null; - /** @description Max number, if column is a number */ - numberMax?: number | null; - /** @description Number of decimals, if column is a number */ - numberDecimals?: number | null; - /** @description Default text, if column is a text */ - textDefault?: string | null; - /** @description Allowed pattern (regex) for text columns (not yet implemented) */ - textAllowedPattern?: string | null; - /** @description Max length, if column is a text */ - textMaxLength?: number | null; - /** @description Options for a selection (json array{id: int, label: string}) */ - selectionOptions?: string | null; - /** @description Default option IDs for a selection (json int[]) */ - selectionDefault?: string | null; - /** @description Default value, if column is datetime */ - datetimeDefault?: string | null; - /** @description Default value, if column is usergroup */ - usergroupDefault?: string | null; - /** @description Can select multiple users or/and groups, if column is usergroup */ - usergroupMultipleItems?: 0 | 1 | null; - /** @description Can select users, if column type is usergroup */ - usergroupSelectUsers?: 0 | 1 | null; - /** @description Can select groups, if column type is usergroup */ - usergroupSelectGroups?: 0 | 1 | null; - /** @description Whether to show the user's status, if column type is usergroup */ - showUserStatus?: 0 | 1 | null; - /** @description View IDs where this column should be added to be presented */ - "selectedViewIds[]"?: number[] | null; - }; - path: { - /** @description Table ID */ - tableId: number; }; }; responses: { @@ -1534,7 +1496,7 @@ export type operations = { * @description Column main type * @enum {string} */ - type: "text" | "number" | "datetime" | "select"; + type: "text" | "number" | "datetime" | "select" | "usergroup"; /** @description Column sub type */ subtype?: string | null; /** @description Is the column mandatory */ @@ -1589,64 +1551,25 @@ export type operations = { * @default */ datetimeDefault?: string | null; + /** + * @description Default value, if column is usergroup (json array{id: string, type: int}) + * @default + */ + usergroupDefault?: string | null; + /** @description Can select multiple users or/and groups, if column is usergroup */ + usergroupMultipleItems?: boolean | null; + /** @description Can select users, if column type is usergroup */ + usergroupSelectUsers?: boolean | null; + /** @description Can select groups, if column type is usergroup */ + usergroupSelectGroups?: boolean | null; + /** @description Whether to show the user's status, if column type is usergroup */ + showUserStatus?: boolean | null; /** * @description View IDs where this column should be added to be presented * @default [] */ selectedViewIds?: number[] | null; }; - parameters: { - query: { - /** @description Table ID */ - tableId?: number | null; - /** @description View ID */ - viewId?: number | null; - /** @description Title */ - title: string; - /** @description Column main type */ - type: "text" | "number" | "datetime" | "select" | "usergroup"; - /** @description Column sub type */ - subtype?: string | null; - /** @description Is the column mandatory */ - mandatory: 0 | 1; - /** @description Description */ - description?: string | null; - /** @description Prefix if the column is a number field */ - numberPrefix?: string | null; - /** @description Suffix if the column is a number field */ - numberSuffix?: string | null; - /** @description Default number, if column is a number */ - numberDefault?: number | null; - /** @description Min value, if column is a number */ - numberMin?: number | null; - /** @description Max number, if column is a number */ - numberMax?: number | null; - /** @description Number of decimals, if column is a number */ - numberDecimals?: number | null; - /** @description Default text, if column is a text */ - textDefault?: string | null; - /** @description Allowed pattern (regex) for text columns (not yet implemented) */ - textAllowedPattern?: string | null; - /** @description Max length, if column is a text */ - textMaxLength?: number | null; - /** @description Options for a selection (json array{id: int, label: string}) */ - selectionOptions?: string | null; - /** @description Default option IDs for a selection (json int[]) */ - selectionDefault?: string | null; - /** @description Default value, if column is datetime */ - datetimeDefault?: string | null; - /** @description Default value, if column is usergroup (json array{id: string, type: int}) */ - usergroupDefault?: string | null; - /** @description Can select multiple users or/and groups, if column is usergroup */ - usergroupMultipleItems?: 0 | 1 | null; - /** @description Can select users, if column type is usergroup */ - usergroupSelectUsers?: 0 | 1 | null; - /** @description Can select groups, if column type is usergroup */ - usergroupSelectGroups?: 0 | 1 | null; - /** @description Whether to show the user's status, if column type is usergroup */ - showUserStatus?: 0 | 1 | null; - /** @description View IDs where this column should be added to be presented */ - "selectedViewIds[]"?: number[] | null; }; }; responses: { @@ -1779,54 +1702,17 @@ export type operations = { selectionDefault?: string | null; /** @description Default value, if column is datetime */ datetimeDefault?: string | null; + /** @description Default value, if column is usergroup */ + usergroupDefault?: string | null; + /** @description Can select multiple users or/and groups, if column is usergroup */ + usergroupMultipleItems?: boolean | null; + /** @description Can select users, if column type is usergroup */ + usergroupSelectUsers?: boolean | null; + /** @description Can select groups, if column type is usergroup */ + usergroupSelectGroups?: boolean | null; + /** @description Whether to show the user's status, if column type is usergroup */ + showUserStatus?: boolean | null; }; - query: { - /** @description Title */ - title?: string | null; - /** @description Column sub type */ - subtype?: string | null; - /** @description Is the column mandatory */ - mandatory: 0 | 1; - /** @description Description */ - description?: string | null; - /** @description Prefix if the column is a number field */ - numberPrefix?: string | null; - /** @description Suffix if the column is a number field */ - numberSuffix?: string | null; - /** @description Default number, if column is a number */ - numberDefault?: number | null; - /** @description Min value, if column is a number */ - numberMin?: number | null; - /** @description Max number, if column is a number */ - numberMax?: number | null; - /** @description Number of decimals, if column is a number */ - numberDecimals?: number | null; - /** @description Default text, if column is a text */ - textDefault?: string | null; - /** @description Allowed pattern (regex) for text columns (not yet implemented) */ - textAllowedPattern?: string | null; - /** @description Max length, if column is a text */ - textMaxLength?: number | null; - /** @description Options for a selection (json array{id: int, label: string}) */ - selectionOptions?: string | null; - /** @description Default option IDs for a selection (json int[]) */ - selectionDefault?: string | null; - /** @description Default value, if column is datetime */ - datetimeDefault?: string | null; - /** @description Default value, if column is usergroup */ - usergroupDefault?: string | null; - /** @description Can select multiple users or/and groups, if column is usergroup */ - usergroupMultipleItems?: 0 | 1 | null; - /** @description Can select users, if column type is usergroup */ - usergroupSelectUsers?: 0 | 1 | null; - /** @description Can select groups, if column type is usergroup */ - usergroupSelectGroups?: 0 | 1 | null; - /** @description Whether to show the user's status, if column type is usergroup */ - showUserStatus?: 0 | 1 | null; - }; - path: { - /** @description Column ID that will be updated */ - columnId: number; }; }; responses: { @@ -3405,35 +3291,52 @@ export type operations = { /** [api v2] Create new usergroup column */ "api_columns-create-usergroup-column": { parameters: { - query: { - /** @description Context of the column creation */ - baseNodeId: number; - /** @description Title */ - title: string; - /** @description Json array{id: string, type: int}, eg [{"id": "admin", "type": 0}, {"id": "user1", "type": 0}] */ - usergroupDefault?: string | null; - /** @description Whether you can select multiple users or/and groups */ - usergroupMultipleItems?: 0 | 1; - /** @description Whether you can select users */ - usergroupSelectUsers?: 0 | 1; - /** @description Whether you can select groups */ - usergroupSelectGroups?: 0 | 1; - /** @description Whether to show the user's status */ - showUserStatus?: 0 | 1; - /** @description Description */ - description?: string | null; - /** @description View IDs where this columns should be added */ - "selectedViewIds[]"?: number[] | null; - /** @description Is mandatory */ - mandatory?: 0 | 1; - /** @description Context type of the column creation */ - baseNodeType?: "table" | "view"; - }; header: { /** @description Required to be true for the API request to pass */ "OCS-APIRequest": boolean; }; }; + requestBody: { + content: { + "application/json": { + /** + * Format: int64 + * @description Context of the column creation + */ + baseNodeId: number; + /** @description Title */ + title: string; + /** @description Json array{id: string, type: int}, eg [{"id": "admin", "type": 0}, {"id": "user1", "type": 0}] */ + usergroupDefault?: string | null; + /** @description Whether you can select multiple users or/and groups */ + usergroupMultipleItems?: boolean; + /** @description Whether you can select users */ + usergroupSelectUsers?: boolean; + /** @description Whether you can select groups */ + usergroupSelectGroups?: boolean; + /** @description Whether to show the user's status */ + showUserStatus?: boolean; + /** @description Description */ + description?: string | null; + /** + * @description View IDs where this columns should be added + * @default [] + */ + selectedViewIds?: number[] | null; + /** + * @description Is mandatory + * @default false + */ + mandatory?: boolean; + /** + * @description Context type of the column creation + * @default table + * @enum {string} + */ + baseNodeType?: "table" | "view"; + }; + }; + }; responses: { /** @description Column created */ 200: {