airi/apps/component-calling
Younsang Na c66da5bcb2
refactor(component-calling): validate component props (#3511)
## Summary

This PR addresses the `@proj-airi/component-calling` item in #3180.

- Replace four explicit `any` types with `unknown` or schema-derived
types.
- Combine both component-props parsing paths in `loadComponentProps`.
- Validate model-generated props with the registered component's Valibot
schema before assigning them.
- Keep the Valibot runtime schema separate from the JSON Schema sent to
the model.

## Behavior and boundaries

Invalid JSON, unknown component names, and props that fail schema
validation do not reach the widget. Validated schema output is assigned,
so schema transformations apply. The page completes its loading flow
after the response.

| Boundary | Protection | Evidence |
| --- | --- | --- |
| Model-generated widget props | Parse and validate before assignment |
Tests cover valid props, additional props, invalid JSON, invalid values,
and transformed output |
| Component prop types | Derive output types from the registered schema
| Workspace typecheck passes |

## Follow-up

`parseComponentProps` throws when validation fails. The page catches the
error and logs it, but still renders an empty widget. Improve this error
state in a follow-up.

## Visual changes

The same mock response sends `temperature: 29` as a number. The
component schema expects a string.

| Before | After |
| --- | --- |
| ![Before: the widget displays the invalid numeric
temperature](https://github.com/user-attachments/assets/5a5902a5-027d-47c5-bb37-573e47ab3579)
| ![After: the invalid temperature is
rejected](https://github.com/user-attachments/assets/bb837927-9c5e-4387-8b65-194918762000)
|
| `main`, 1440 × 900 | `component-calling`, 1440 × 900 |

## Verification

- `pnpm -F @proj-airi/component-calling typecheck` — passed.
- `pnpm -F @proj-airi/component-calling exec vitest run
src/plugins/plugin-component-calling/index.test.ts` — 6 tests passed.
- Targeted ESLint on the three changed TypeScript and Vue files —
passed.
- `pnpm lint` — 0 errors and 691 warnings.
- `git diff --check` — passed.

The app build was not run.
2026-11-16 16:34:25 +09:00
..
public feat(component-calling): or component use, init 2025-07-29 02:37:29 +08:00
src refactor(component-calling): validate component props (#3511) 2026-11-16 16:34:25 +09:00
index.html feat(component-calling): or component use, init 2025-07-29 02:37:29 +08:00
netlify.toml chore(workspace): now use NODE_VERSION 24 without minor constraints 2025-08-25 03:32:05 +08:00
package.json chore: update package dependencies and remove specific catalog references 2026-06-07 19:45:28 +08:00
tsconfig.json chore(deps): remove deprecated unplugin-vue-router (#1664) 2026-04-15 15:02:10 +08:00
uno.config.ts Revert "style: lint" 2026-08-26 20:13:10 +08:00
vite.config.ts Revert "style: lint" 2026-08-26 20:13:10 +08:00