|
39 | 39 | use OCP\TaskProcessing\ShapeEnumValue;
|
40 | 40 | use OCP\TaskProcessing\Task;
|
41 | 41 | use RuntimeException;
|
| 42 | +use stdClass; |
42 | 43 |
|
43 | 44 | /**
|
44 | 45 | * @psalm-import-type CoreTaskProcessingTask from ResponseDefinitions
|
@@ -67,31 +68,70 @@ public function __construct(
|
67 | 68 | #[PublicPage]
|
68 | 69 | #[ApiRoute(verb: 'GET', url: '/tasktypes', root: '/taskprocessing')]
|
69 | 70 | public function taskTypes(): DataResponse {
|
| 71 | + /** @var array<string, CoreTaskProcessingTaskType> $taskTypes */ |
70 | 72 | $taskTypes = array_map(function (array $tt) {
|
71 |
| - $tt['inputShape'] = array_values(array_map(function ($descriptor) { |
| 73 | + $tt['inputShape'] = array_map(function ($descriptor) { |
72 | 74 | return $descriptor->jsonSerialize();
|
73 |
| - }, $tt['inputShape'])); |
74 |
| - $tt['outputShape'] = array_values(array_map(function ($descriptor) { |
| 75 | + }, $tt['inputShape']); |
| 76 | + if (empty($tt['inputShape'])) { |
| 77 | + $tt['inputShape'] = new stdClass; |
| 78 | + } |
| 79 | + |
| 80 | + $tt['outputShape'] = array_map(function ($descriptor) { |
75 | 81 | return $descriptor->jsonSerialize();
|
76 |
| - }, $tt['outputShape'])); |
77 |
| - $tt['optionalInputShape'] = array_values(array_map(function ($descriptor) { |
| 82 | + }, $tt['outputShape']); |
| 83 | + if (empty($tt['outputShape'])) { |
| 84 | + $tt['outputShape'] = new stdClass; |
| 85 | + } |
| 86 | + |
| 87 | + $tt['optionalInputShape'] = array_map(function ($descriptor) { |
78 | 88 | return $descriptor->jsonSerialize();
|
79 |
| - }, $tt['optionalInputShape'])); |
80 |
| - $tt['optionalOutputShape'] = array_values(array_map(function ($descriptor) { |
| 89 | + }, $tt['optionalInputShape']); |
| 90 | + if (empty($tt['optionalInputShape'])) { |
| 91 | + $tt['optionalInputShape'] = new stdClass; |
| 92 | + } |
| 93 | + |
| 94 | + $tt['optionalOutputShape'] = array_map(function ($descriptor) { |
81 | 95 | return $descriptor->jsonSerialize();
|
82 |
| - }, $tt['optionalOutputShape'])); |
83 |
| - $tt['inputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { |
84 |
| - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); |
85 |
| - }, $tt['inputShapeEnumValues'])); |
86 |
| - $tt['optionalInputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { |
87 |
| - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); |
88 |
| - }, $tt['optionalInputShapeEnumValues'])); |
89 |
| - $tt['outputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { |
90 |
| - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); |
91 |
| - }, $tt['outputShapeEnumValues'])); |
92 |
| - $tt['optionalOutputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { |
93 |
| - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); |
94 |
| - }, $tt['optionalOutputShapeEnumValues'])); |
| 96 | + }, $tt['optionalOutputShape']); |
| 97 | + if (empty($tt['optionalOutputShape'])) { |
| 98 | + $tt['optionalOutputShape'] = new stdClass; |
| 99 | + } |
| 100 | + |
| 101 | + $tt['inputShapeEnumValues'] = array_map(function (array $enumValues) { |
| 102 | + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 103 | + }, $tt['inputShapeEnumValues']); |
| 104 | + if (empty($tt['inputShapeEnumValues'])) { |
| 105 | + $tt['inputShapeEnumValues'] = new stdClass; |
| 106 | + } |
| 107 | + |
| 108 | + $tt['optionalInputShapeEnumValues'] = array_map(function (array $enumValues) { |
| 109 | + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 110 | + }, $tt['optionalInputShapeEnumValues']); |
| 111 | + if (empty($tt['optionalInputShapeEnumValues'])) { |
| 112 | + $tt['optionalInputShapeEnumValues'] = new stdClass; |
| 113 | + } |
| 114 | + |
| 115 | + $tt['outputShapeEnumValues'] = array_map(function (array $enumValues) { |
| 116 | + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 117 | + }, $tt['outputShapeEnumValues']); |
| 118 | + if (empty($tt['outputShapeEnumValues'])) { |
| 119 | + $tt['outputShapeEnumValues'] = new stdClass; |
| 120 | + } |
| 121 | + |
| 122 | + $tt['optionalOutputShapeEnumValues'] = array_map(function (array $enumValues) { |
| 123 | + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 124 | + }, $tt['optionalOutputShapeEnumValues']); |
| 125 | + if (empty($tt['optionalOutputShapeEnumValues'])) { |
| 126 | + $tt['optionalOutputShapeEnumValues'] = new stdClass; |
| 127 | + } |
| 128 | + |
| 129 | + if (empty($tt['inputShapeDefaults'])) { |
| 130 | + $tt['inputShapeDefaults'] = new stdClass; |
| 131 | + } |
| 132 | + if (empty($tt['optionalInputShapeDefaults'])) { |
| 133 | + $tt['optionalInputShapeDefaults'] = new stdClass; |
| 134 | + } |
95 | 135 | return $tt;
|
96 | 136 | }, $this->taskProcessingManager->getAvailableTaskTypes());
|
97 | 137 | return new DataResponse([
|
|
0 commit comments