mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
fix(core): Fix TeamsApiController typing
Signed-off-by: provokateurin <kate@provokateurin.de> Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
831a7c75d1
commit
c5b04713c4
7 changed files with 201 additions and 51 deletions
|
|
@ -17,10 +17,12 @@ use OCP\AppFramework\OCSController;
|
|||
use OCP\IRequest;
|
||||
use OCP\Teams\ITeamManager;
|
||||
use OCP\Teams\Team;
|
||||
use OCP\Teams\TeamResource;
|
||||
|
||||
/**
|
||||
* @psalm-import-type CoreTeamResource from ResponseDefinitions
|
||||
* @psalm-import-type CoreTeam from ResponseDefinitions
|
||||
* @psalm-import-type CoreTeamWithResources from ResponseDefinitions
|
||||
* @property $userId string
|
||||
*/
|
||||
class TeamsApiController extends OCSController {
|
||||
|
|
@ -44,13 +46,10 @@ class TeamsApiController extends OCSController {
|
|||
#[NoAdminRequired]
|
||||
#[ApiRoute(verb: 'GET', url: '/{teamId}/resources', root: '/teams')]
|
||||
public function resolveOne(string $teamId): DataResponse {
|
||||
/**
|
||||
* @var list<CoreTeamResource> $resolvedResources
|
||||
* @psalm-suppress PossiblyNullArgument The route is limited to logged-in users
|
||||
*/
|
||||
/** @psalm-suppress PossiblyNullArgument The route is limited to logged-in users */
|
||||
$resolvedResources = $this->teamManager->getSharedWith($teamId, $this->userId);
|
||||
|
||||
return new DataResponse(['resources' => $resolvedResources]);
|
||||
return new DataResponse(['resources' => array_map(static fn (TeamResource $resource) => $resource->jsonSerialize(), $resolvedResources)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +57,7 @@ class TeamsApiController extends OCSController {
|
|||
*
|
||||
* @param string $providerId Identifier of the provider (e.g. deck, talk, collectives)
|
||||
* @param string $resourceId Unique id of the resource to list teams for (e.g. deck board id)
|
||||
* @return DataResponse<Http::STATUS_OK, array{teams: list<CoreTeam>}, array{}>
|
||||
* @return DataResponse<Http::STATUS_OK, array{teams: list<CoreTeamWithResources>}, array{}>
|
||||
*
|
||||
* 200: Teams returned
|
||||
*/
|
||||
|
|
@ -67,11 +66,10 @@ class TeamsApiController extends OCSController {
|
|||
public function listTeams(string $providerId, string $resourceId): DataResponse {
|
||||
/** @psalm-suppress PossiblyNullArgument The route is limited to logged-in users */
|
||||
$teams = $this->teamManager->getTeamsForResource($providerId, $resourceId, $this->userId);
|
||||
/** @var list<CoreTeam> $teams */
|
||||
$teams = array_values(array_map(function (Team $team) {
|
||||
$response = $team->jsonSerialize();
|
||||
/** @psalm-suppress PossiblyNullArgument The route is limited to logged in users */
|
||||
$response['resources'] = $this->teamManager->getSharedWith($team->getId(), $this->userId);
|
||||
$response['resources'] = array_map(static fn (TeamResource $resource) => $resource->jsonSerialize(), $this->teamManager->getSharedWith($team->getId(), $this->userId));
|
||||
return $response;
|
||||
}, $teams));
|
||||
|
||||
|
|
|
|||
|
|
@ -149,19 +149,28 @@ namespace OC\Core;
|
|||
* }
|
||||
*
|
||||
* @psalm-type CoreTeam = array{
|
||||
* id: string,
|
||||
* name: string,
|
||||
* icon: string,
|
||||
* teamId: string,
|
||||
* displayName: string,
|
||||
* link: ?string,
|
||||
* }
|
||||
*
|
||||
* @psalm-type CoreTeamResource = array{
|
||||
* id: int,
|
||||
* label: string,
|
||||
* url: string,
|
||||
* iconSvg: ?string,
|
||||
* iconURL: ?string,
|
||||
* iconEmoji: ?string,
|
||||
* }
|
||||
* id: string,
|
||||
* label: string,
|
||||
* url: string,
|
||||
* iconSvg: ?string,
|
||||
* iconURL: ?string,
|
||||
* iconEmoji: ?string,
|
||||
* provider: array{
|
||||
* id: string,
|
||||
* name: string,
|
||||
* icon: string,
|
||||
* },
|
||||
* }
|
||||
*
|
||||
* @psalm-type CoreTeamWithResources = CoreTeam&array{
|
||||
* resources: list<CoreTeamResource>,
|
||||
* }
|
||||
*
|
||||
* @psalm-type CoreTaskProcessingShape = array{
|
||||
* name: string,
|
||||
|
|
|
|||
|
|
@ -898,19 +898,20 @@
|
|||
"Team": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
"teamId",
|
||||
"displayName",
|
||||
"link"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"teamId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
"link": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -922,12 +923,12 @@
|
|||
"url",
|
||||
"iconSvg",
|
||||
"iconURL",
|
||||
"iconEmoji"
|
||||
"iconEmoji",
|
||||
"provider"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "string"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
|
|
@ -946,9 +947,49 @@
|
|||
"iconEmoji": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"provider": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"TeamWithResources": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Team"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"resources"
|
||||
],
|
||||
"properties": {
|
||||
"resources": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/TeamResource"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"TextProcessingTask": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -6306,7 +6347,7 @@
|
|||
"teams": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Team"
|
||||
"$ref": "#/components/schemas/TeamWithResources"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -898,19 +898,20 @@
|
|||
"Team": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
"teamId",
|
||||
"displayName",
|
||||
"link"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"teamId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
"link": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -922,12 +923,12 @@
|
|||
"url",
|
||||
"iconSvg",
|
||||
"iconURL",
|
||||
"iconEmoji"
|
||||
"iconEmoji",
|
||||
"provider"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "string"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
|
|
@ -946,9 +947,49 @@
|
|||
"iconEmoji": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"provider": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"TeamWithResources": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Team"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"resources"
|
||||
],
|
||||
"properties": {
|
||||
"resources": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/TeamResource"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"TextProcessingTask": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -6306,7 +6347,7 @@
|
|||
"teams": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Team"
|
||||
"$ref": "#/components/schemas/TeamWithResources"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ class Team implements \JsonSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* teamId: string,
|
||||
* displayName: string,
|
||||
* link: ?string,
|
||||
* }
|
||||
*
|
||||
* @since 29.0.0
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,20 @@ class TeamResource implements \JsonSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* id: string,
|
||||
* label: string,
|
||||
* url: string,
|
||||
* iconSvg: ?string,
|
||||
* iconURL: ?string,
|
||||
* iconEmoji: ?string,
|
||||
* provider: array{
|
||||
* id: string,
|
||||
* name: string,
|
||||
* icon: string,
|
||||
* },
|
||||
* }
|
||||
*
|
||||
* @since 29.0.0
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
|
|
|
|||
63
openapi.json
63
openapi.json
|
|
@ -936,19 +936,20 @@
|
|||
"CoreTeam": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
"teamId",
|
||||
"displayName",
|
||||
"link"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"teamId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
"link": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -960,12 +961,12 @@
|
|||
"url",
|
||||
"iconSvg",
|
||||
"iconURL",
|
||||
"iconEmoji"
|
||||
"iconEmoji",
|
||||
"provider"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "string"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
|
|
@ -984,9 +985,49 @@
|
|||
"iconEmoji": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"provider": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"icon"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"CoreTeamWithResources": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/CoreTeam"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"resources"
|
||||
],
|
||||
"properties": {
|
||||
"resources": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CoreTeamResource"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"CoreTextProcessingTask": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -9815,7 +9856,7 @@
|
|||
"teams": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CoreTeam"
|
||||
"$ref": "#/components/schemas/CoreTeamWithResources"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue