fix: address review comments

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
pull/45094/head
Marcel Klehr 3 weeks ago
parent f5a8bda1ba
commit cac812dc58

@ -180,7 +180,7 @@ namespace OCA\Core;
* @psalm-type CoreTaskProcessingShape = array{
* name: string,
* description: string,
* type: int,
* type: "Number"|"Text"|"Audio"|"Image"|"Video"|"File"|"ListOfNumbers"|"ListOfTexts"|"ListOfImages"|"ListOfAudios"|"ListOfVideos"|"ListOfFiles",
* mandatory: bool,
* }
*
@ -191,14 +191,16 @@ namespace OCA\Core;
* outputShape: CoreTaskProcessingShape[],
* }
*
* @psalm-type CoreTaskProcessingIO = array<string, numeric|list<numeric>|string|list<string>>
*
* @psalm-type CoreTaskProcessingTask = array{
* id: int,
* type: string,
* status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN',
* userId: ?string,
* appId: string,
* input: array<string, numeric|list<numeric>|string|list<string>>,
* output: null|array<string, numeric|list<numeric>|string|list<string>>,
* input: CoreTaskProcessingIO,
* output: null|CoreTaskProcessingIO,
* customId: ?string,
* completionExpectedAt: ?int,
* progress: ?float

@ -466,6 +466,31 @@
}
}
},
"TaskProcessingIO": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"TaskProcessingShape": {
"type": "object",
"required": [
@ -482,8 +507,21 @@
"type": "string"
},
"type": {
"type": "integer",
"format": "int64"
"type": "string",
"enum": [
"Number",
"Text",
"Audio",
"Image",
"Video",
"File",
"ListOfNumbers",
"ListOfTexts",
"ListOfImages",
"ListOfAudios",
"ListOfVideos",
"ListOfFiles"
]
},
"mandatory": {
"type": "boolean"
@ -531,55 +569,11 @@
"type": "string"
},
"input": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
"$ref": "#/components/schemas/TaskProcessingIO"
},
"output": {
"type": "object",
"nullable": true,
"additionalProperties": {
"anyOf": [
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
"$ref": "#/components/schemas/TaskProcessingIO",
"nullable": true
},
"customId": {
"type": "string",

@ -45,7 +45,6 @@ use OCP\L10N\IFactory;
use OCP\Lock\LockedException;
use OCP\SpeechToText\ISpeechToTextProvider;
use OCP\SpeechToText\ISpeechToTextProviderWithId;
use OCP\SpeechToText\ISpeechToTextProviderWithUserId;
use OCP\TaskProcessing\EShapeType;
use OCP\TaskProcessing\Events\TaskFailedEvent;
use OCP\TaskProcessing\Events\TaskSuccessfulEvent;

@ -42,8 +42,8 @@ enum EShapeType: int {
case ListOfNumbers = 10;
case ListOfTexts = 11;
case ListOfImages = 12;
case ListOfAudio = 13;
case ListOfVideo = 14;
case ListOfAudios = 13;
case ListOfVideos = 14;
case ListOfFiles = 15;
/**
@ -84,13 +84,13 @@ enum EShapeType: int {
if ($this === EShapeType::Audio && !is_numeric($value)) {
throw new ValidationException('Non-audio item provided for Audio slot');
}
if ($this === EShapeType::ListOfAudio && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
if ($this === EShapeType::ListOfAudios && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
throw new ValidationException('Non-audio list item provided for ListOfAudio slot');
}
if ($this === EShapeType::Video && !is_numeric($value)) {
throw new ValidationException('Non-video item provided for Video slot');
}
if ($this === EShapeType::ListOfVideo && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
if ($this === EShapeType::ListOfVideos && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
throw new ValidationException('Non-video list item provided for ListOfTexts slot');
}
if ($this === EShapeType::File && !is_numeric($value)) {
@ -116,13 +116,13 @@ enum EShapeType: int {
if ($this === EShapeType::Audio && !is_string($value)) {
throw new ValidationException('Non-audio item provided for Audio slot');
}
if ($this === EShapeType::ListOfAudio && (!is_array($value) || count(array_filter($value, fn ($item) => !is_string($item))) > 0)) {
if ($this === EShapeType::ListOfAudios && (!is_array($value) || count(array_filter($value, fn ($item) => !is_string($item))) > 0)) {
throw new ValidationException('Non-audio list item provided for ListOfAudio slot');
}
if ($this === EShapeType::Video && !is_string($value)) {
throw new ValidationException('Non-video item provided for Video slot');
}
if ($this === EShapeType::ListOfVideo && (!is_array($value) || count(array_filter($value, fn ($item) => !is_string($item))) > 0)) {
if ($this === EShapeType::ListOfVideos && (!is_array($value) || count(array_filter($value, fn ($item) => !is_string($item))) > 0)) {
throw new ValidationException('Non-video list item provided for ListOfTexts slot');
}
if ($this === EShapeType::File && !is_string($value)) {

@ -45,14 +45,16 @@ class ShapeDescriptor implements \JsonSerializable {
}
/**
* @return array{name: string, description: string, type: int}
* @return array{name: string, description: string, type: "Number"|"Text"|"Audio"|"Image"|"Video"|"File"|"ListOfNumbers"|"ListOfTexts"|"ListOfImages"|"ListOfAudios"|"ListOfVideos"|"ListOfFiles"}
* @since 30.0.0
*/
public function jsonSerialize(): array {
/** @var "Number"|"Text"|"Audio"|"Image"|"Video"|"File"|"ListOfNumbers"|"ListOfTexts"|"ListOfImages"|"ListOfAudios"|"ListOfVideos"|"ListOfFiles" $type */
$type = $this->getShapeType()->name;
return [
'name' => $this->getName(),
'description' => $this->getDescription(),
'type' => $this->getShapeType()->value,
'type' => $type,
];
}
}

Loading…
Cancel
Save