Anuragp22 commented on code in PR #67725:
URL: https://github.com/apache/airflow/pull/67725#discussion_r3384655252
##########
airflow-core/src/airflow/ui/src/components/AssetExpression/types.ts:
##########
@@ -16,31 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
+import type {
+ AssetExpressionAlias,
+ AssetExpressionAll,
+ AssetExpressionAny,
+ AssetExpressionAsset,
+ AssetExpressionRef,
+} from "openapi/requests/types.gen";
-type Asset = {
- asset: {
- group: string;
- id: number;
- name: string;
- uri: string;
- };
-};
+// `asset_expression` is now typed on the API side (see the AssetExpression*
models in the Python
+// `datamodels/common.py`), so these aliases are derived from the generated
client instead of being
+// hand-maintained here. The previous local union could drift from the server
shape with no runtime check.
-type Alias = {
- alias: {
- group: string;
- name: string;
- };
-};
+export type NextRunEvent = { id: number; lastUpdate?: string | null; name:
string | null; uri: string };
-export type NextRunEvent = { id: number; lastUpdate: string | null; name:
string | null; uri: string };
-
-export type AssetSummary = Alias | Asset;
+export type AssetSummary = AssetExpressionAlias | AssetExpressionAsset;
export type ExpressionType =
- | Alias
- | Asset
- | {
- all?: Array<AssetSummary | ExpressionType>;
- any?: Array<AssetSummary | ExpressionType>;
- };
+ | AssetExpressionAlias
+ | AssetExpressionAll
+ | AssetExpressionAny
+ | AssetExpressionAsset
+ | AssetExpressionRef;
Review Comment:
Good point. The generated client does not expose a single named union for
`asset_expression` though; it inlines the member types on each response model,
so there is nothing to import directly.
I have derived it from the generated response instead:
```ts
export type ExpressionType =
NonNullable<DAGDetailsResponse["asset_expression"]>;
```
That drops the hand-maintained union and keeps it in sync with the server
shape. Let me know if you would prefer to inline it at each call site and
remove the alias entirely.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]