lxbme opened a new pull request, #3445:
URL: https://github.com/apache/apisix-dashboard/pull/3445
Please answer these questions before submitting a pull request, **or your PR
will get closed**.
**Why submit this pull request?**
- [x] Bugfix
**What changes will this PR take into?**
This addresses the "`apis/` imports types from `components/` (inverted
layering); one detail page re-declares an exported query-options helper" item
of the frontend review in #3417.
The data-access layer (`apis/`) should not depend on the UI layer
(`components/`). Three `apis/` modules imported a type from
`components/form-slice/…`:
- `apis/ssls.ts` imported `SSLPostType` from `FormPartSSL/schema`.
- `apis/stream_routes.ts` imported `StreamRoutePostType` from
`FormPartStreamRoute/schema`.
- `apis/plugins.ts` imported `PluginConfig` from
`FormItemPlugins/PluginEditorDrawer`.
Each is fixed by putting the type where the layer boundary allows the API
module to reach it, with no behaviour change:
- **`SSLPostBody`** — a new request-body type (`SSL.omit({ id, create_time,
update_time })`) added to `types/schema/apisix/ssls.ts`. `apis/ssls.ts` now
types `postSSLReq`'s payload with it. The form keeps its own `SSLPostType`
(which additionally carries the UI-only `__clientEnabled` helper the SSL
client-cert switch binds to); that form type is assignable to `SSLPostBody`, so
the caller is unaffected. This keeps the UI flag out of the API-schema layer
rather than relocating it there.
- **`StreamRoutePostSchema` / `StreamRoutePostType`** — moved into
`types/schema/apisix/stream_routes.ts` (they are purely API-derived, no
form-only fields) and re-exported from `FormPartStreamRoute/schema.ts`, so
component importers are unchanged. `apis/stream_routes.ts` imports from the
schema layer.
- **`PluginConfig`** (`{ name: string; config: object }`) — moved to
`apis/plugins.ts` (it is the shape `putPluginMetadataReq` consumes) and
re-exported from `PluginEditorDrawer.tsx`, so its component importers are
unchanged and the dependency now points component → api.
Separately, `routes/upstreams/detail.$id.tsx` re-declared a local
`getUpstreamQueryOptions` identical to the one already exported from
`apis/hooks.ts`; it now imports the shared helper (same query key `['upstream',
id]`), and the now-unused `queryOptions` / `getUpstreamReq` imports are dropped.
**Related issues**
Part of #3417
**Checklist:**
- [x] Did you explain what problem does this PR solve? Or what new features
have been added?
- [ ] Have you added corresponding test cases?
- [x] Have you modified the corresponding document?
- [x] Is this PR backward compatible? If it is not backward compatible,
please discuss on the mailing list first
These are type-relocation and de-duplication changes with no runtime
behaviour change (the one runtime touch — the upstream detail page using the
shared query-options helper — keeps the identical query key), so no new tests
were added. Verified with `tsc`, ESLint, the unit suite, and the full e2e suite.
--
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]