Skip to content

Commit

Permalink
fix(OpenAPI): Fix some typings
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Sep 27, 2024
1 parent 7e6c26f commit 840d34d
Show file tree
Hide file tree
Showing 21 changed files with 351 additions and 229 deletions.
2 changes: 1 addition & 1 deletion lib/Api/V1Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(ColumnService $columnService, RowService $rowService
* @param int|null $offset
* @param string|null $userId
* @param string|null $nodeType
* @return array
* @return list<list<mixed>>
* @throws DoesNotExistException
* @throws InternalError
* @throws MultipleObjectsReturnedException
Expand Down
10 changes: 9 additions & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ public function __construct(IAppManager $appManager, LoggerInterface $logger, IC

/**
*
* @return array{tables: array{enabled: bool, version: string, apiVersions: string[], features: string[], column_types: string[]}}
* @return array{
* tables: array{
* enabled: bool,
* version: string,
* apiVersions: list<string>,
* features: list<string>,
* column_types: list<string>,
* }
* }
*
* @inheritDoc
*/
Expand Down
24 changes: 12 additions & 12 deletions lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function __construct(
* @CORS
* @NoCSRFRequired
*
* @return DataResponse<Http::STATUS_OK, TablesTable[], array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesTable>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tables returned
*/
Expand Down Expand Up @@ -281,7 +281,7 @@ public function deleteTable(int $tableId): DataResponse {
* @NoCSRFRequired
*
* @param int $tableId Table ID
* @return DataResponse<Http::STATUS_OK, TablesView[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesView>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Views returned
* 403: No permissions
Expand Down Expand Up @@ -376,7 +376,7 @@ public function getView(int $viewId): DataResponse {
* @NoCSRFRequired
*
* @param int $viewId View ID
* @param array{key: 'title'|'emoji'|'description', value: string}|array{key: 'columns', value: int[]}|array{key: 'sort', value: array{columnId: int, mode: 'ASC'|'DESC'}}|array{key: 'filter', value: array{columnId: int, operator: 'begins-with'|'ends-with'|'contains'|'is-equal'|'is-greater-than'|'is-greater-than-or-equal'|'is-lower-than'|'is-lower-than-or-equal'|'is-empty', value: string|int|float}} $data key-value pairs
* @param array{key: 'title'|'emoji'|'description', value: string}|array{key: 'columns', value: list<int>}|array{key: 'sort', value: array{columnId: int, mode: 'ASC'|'DESC'}}|array{key: 'filter', value: array{columnId: int, operator: 'begins-with'|'ends-with'|'contains'|'is-equal'|'is-greater-than'|'is-greater-than-or-equal'|'is-lower-than'|'is-lower-than-or-equal'|'is-empty', value: string|int|float}} $data key-value pairs
* @return DataResponse<Http::STATUS_OK, TablesView, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_BAD_REQUEST|Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: View updated
Expand Down Expand Up @@ -477,7 +477,7 @@ public function getShare(int $shareId): DataResponse {
* @NoCSRFRequired
*
* @param int $viewId View ID
* @return DataResponse<Http::STATUS_OK, TablesShare[], array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesShare>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Shares returned
*/
Expand All @@ -500,7 +500,7 @@ public function indexViewShares(int $viewId): DataResponse {
* @NoCSRFRequired
*
* @param int $tableId Table ID
* @return DataResponse<Http::STATUS_OK, TablesShare[], array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesShare>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Shares returned
*/
Expand Down Expand Up @@ -694,7 +694,7 @@ public function updateShareDisplayMode(int $shareId, int $displayMode, string $t
*
* @param int $tableId Table ID
* @param int|null $viewId View ID
* @return DataResponse<Http::STATUS_OK, TablesColumn[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesColumn>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: View deleted
* 403: No permissions
Expand Down Expand Up @@ -723,7 +723,7 @@ public function indexTableColumns(int $tableId, ?int $viewId): DataResponse {
* @NoCSRFRequired
*
* @param int $viewId View ID
* @return DataResponse<Http::STATUS_OK, TablesColumn[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesColumn>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: View deleted
* 403: No permissions
Expand Down Expand Up @@ -778,7 +778,7 @@ public function indexViewColumns(int $viewId): DataResponse {
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
Expand Down Expand Up @@ -1039,7 +1039,7 @@ public function deleteColumn(int $columnId): DataResponse {
* @param int $tableId Table ID
* @param int|null $limit Limit
* @param int|null $offset Offset
* @return DataResponse<Http::STATUS_OK, string[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<list<mixed>>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Row values returned
* 403: No permissions
Expand Down Expand Up @@ -1069,7 +1069,7 @@ public function indexTableRowsSimple(int $tableId, ?int $limit, ?int $offset): D
* @param int $tableId Table ID
* @param int|null $limit Limit
* @param int|null $offset Offset
* @return DataResponse<Http::STATUS_OK, TablesRow[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesRow>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Rows returned
* 403: No permissions
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public function indexTableRows(int $tableId, ?int $limit, ?int $offset): DataRes
* @param int $viewId View ID
* @param int|null $limit Limit
* @param int|null $offset Offset
* @return DataResponse<Http::STATUS_OK, TablesRow[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesRow>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Rows returned
* 403: No permissions
Expand Down Expand Up @@ -1495,7 +1495,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
Expand Down
12 changes: 6 additions & 6 deletions lib/Controller/ApiColumnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
*
* @param int $nodeId Node ID
* @param 'table'|'view' $nodeType Node type
* @return DataResponse<Http::STATUS_OK, TablesColumn[], array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesColumn>, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: View deleted
* 403: No permissions
Expand Down Expand Up @@ -111,7 +111,7 @@ public function show(int $id): DataResponse {
* @param float|null $numberMax Max
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand Down Expand Up @@ -160,7 +160,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
* @param int|null $textMaxLength Max raw text length
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
Expand Down Expand Up @@ -207,7 +207,7 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
* @param string|null $selectionDefault Json int|int[] for default selected option(s), eg 5 or ["1", "8"]
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
Expand Down Expand Up @@ -252,7 +252,7 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
* @param 'today'|'now'|null $datetimeDefault For a subtype 'date' you can set 'today'. For a main type or subtype 'time' you can set to 'now'.
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
Expand Down Expand Up @@ -297,7 +297,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
* @param boolean $usergroupSelectGroups Whether you can select groups
* @param boolean $showUserStatus Whether to show the user's status
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/ApiTablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
*
* @NoAdminRequired
*
* @return DataResponse<Http::STATUS_OK, TablesTable[], array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesTable>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tables returned
*/
Expand Down Expand Up @@ -127,8 +127,8 @@ public function showScheme(int $id): DataResponse {
* @param string $title title of new table
* @param string $emoji emoji
* @param string $description description
* @param array<TablesColumn > $columns columns
* @param array<TablesView> $views views
* @param list<TablesColumn> $columns columns
* @param list<TablesView> $views views
* @return DataResponse<Http::STATUS_OK, TablesTable, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tables returned
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ContextController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
*
* Return an empty array if no contexts were found
*
* @return DataResponse<Http::STATUS_OK, TablesContext[], array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
* @return DataResponse<Http::STATUS_OK, list<TablesContext>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: reporting in available contexts
*
Expand Down
89 changes: 47 additions & 42 deletions lib/Db/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,63 @@
*
* @psalm-import-type TablesColumn from ResponseDefinitions
*
* @method getTitle(): string
* @method string getTitle()
* @method setTitle(string $title)
* @method getTableId(): int
* @method int getTableId()
* @method setTableId(int $tableId)
* @method getCreatedBy(): string
* @method string getCreatedBy()
* @method setCreatedBy(string $createdBy)
* @method getCreatedByDisplayName(): string
* @method string getCreatedByDisplayName()
* @method setCreatedByDisplayName(string $displayName)
* @method getCreatedAt(): string
* @method string getCreatedAt()
* @method setCreatedAt(string $createdAt)
* @method getLastEditBy(): string
* @method string getLastEditBy()
* @method setLastEditBy(string $lastEditBy)
* @method getLastEditByDisplayName(): string
* @method string getLastEditByDisplayName()
* @method setLastEditByDisplayName(string $displayName)
* @method getLastEditAt(): string
* @method string getLastEditAt()
* @method setLastEditAt(string $lastEditAt)
* @method getType(): string
* @method string getType()
* @method setType(string $type)
* @method getSubtype(): string
* @method string getSubtype()
* @method setSubtype(string $subtype)
* @method getMandatory(): bool
* @method bool getMandatory()
* @method setMandatory(?bool $mandatory)
* @method getDescription(): string
* @method string getDescription()
* @method setDescription(?string $description)
* @method getNumberDefault(): float
* @method float getNumberDefault()
* @method setNumberDefault(?float $numberDefault)
* @method getNumberMin(): float
* @method float getNumberMin()
* @method setNumberMin(?float $numberMin)
* @method getNumberMax(): float
* @method float getNumberMax()
* @method setNumberMax(?float $numberMax)
* @method getNumberDecimals(): int
* @method int getNumberDecimals()
* @method setNumberDecimals(?int $numberDecimals)
* @method getNumberPrefix(): string
* @method string getNumberPrefix()
* @method setNumberPrefix(?string $numberPrefix)
* @method getNumberSuffix(): string
* @method string getNumberSuffix()
* @method setNumberSuffix(?string $numberSuffix)
* @method getTextDefault(): string
* @method string getTextDefault()
* @method setTextDefault(?string $textDefault)
* @method getTextAllowedPattern(): string
* @method string getTextAllowedPattern()
* @method setTextAllowedPattern(?string $textAllowedPattern)
* @method getTextMaxLength(): int
* @method int getTextMaxLength()
* @method setTextMaxLength(?int $textMaxLength)
* @method getSelectionOptions(): string
* @method getSelectionDefault(): string
* @method string getSelectionOptions()
* @method setSelectionOptions(?string $selectionOptionsArray)
* @method string getSelectionDefault()
* @method setSelectionDefault(?string $selectionDefault)
* @method getDatetimeDefault(): string
* @method string getDatetimeDefault()
* @method setDatetimeDefault(?string $datetimeDefault)
* @method getUsergroupDefault(): string
* @method string getUsergroupDefault()
* @method setUsergroupDefault(?string $usergroupDefaultArray)
* @method getUsergroupMultipleItems(): bool
* @method bool getUsergroupMultipleItems()
* @method setUsergroupMultipleItems(?bool $usergroupMultipleItems)
* @method getUsergroupSelectUsers(): bool
* @method bool getUsergroupSelectUsers()
* @method setUsergroupSelectUsers(?bool $usergroupSelectUsers)
* @method getUsergroupSelectGroups(): bool
* @method bool getUsergroupSelectGroups()
* @method setUsergroupSelectGroups(?bool $usergroupSelectGroups)
* @method getShowUserStatus(): bool
* @method bool getShowUserStatus()
* @method setShowUserStatus(?bool $showUserStatus)
*/
class Column extends Entity implements JsonSerializable {
Expand All @@ -91,19 +91,18 @@ class Column extends Entity implements JsonSerializable {
public const TYPE_DATETIME = 'datetime';
public const TYPE_USERGROUP = 'usergroup';

protected ?string $title = null;
protected ?int $tableId = null;
protected ?string $createdBy = null;
protected ?string $createdByDisplayName = null;
protected ?string $createdAt = null;
protected ?string $lastEditBy = null;
protected ?string $lastEditByDisplayName = null;
protected ?string $lastEditAt = null;
protected ?string $type = null;
protected ?string $subtype = null;
protected ?bool $mandatory = null;
protected ?string $description = null;
protected ?int $orderWeight = null; // Deprecated
protected string $title = '';
protected int $tableId = 0;
protected string $createdBy = '';
protected string $createdByDisplayName = '';
protected string $createdAt = '';
protected string $lastEditBy = '';
protected string $lastEditByDisplayName = '';
protected string $lastEditAt = '';
protected string $type = '';
protected string $subtype = '';
protected bool $mandatory = false;
protected string $description = '';

// type number
protected ?float $numberDefault = null;
Expand Down Expand Up @@ -180,6 +179,9 @@ public static function fromDto(ColumnDto $data): self {
return $column;
}

/**
* @return array{id: int, label: string}|list<array{id: int, label: string}>
*/
public function getUsergroupDefaultArray():array {
$default = $this->getUsergroupDefault();
if ($default !== "" && $default !== null) {
Expand All @@ -194,6 +196,9 @@ public function setUsergroupDefaultArray(array $array):void {
$this->setUsergroup($json);
}

/**
* @return list<array{id: int, label: string}>
*/
public function getSelectionOptionsArray():array {
$options = $this->getSelectionOptions();
if ($options !== "" && $options !== null && $options !== 'null') {
Expand Down
Loading

0 comments on commit 840d34d

Please sign in to comment.