SpecialX
0beeff6329
feat(portal-shell): restore codegen typescript-operations for data-ana domain (P1-7)
...
ARCHITECTURE.md §10 P1-7: dashboard domain's 6 operations strictly
match the schema, so disable skipDocumentsValidation for that output
and restore per-operation type generation.
Changes:
- codegen.yml: add dashboard-types.ts output (typescript +
typescript-operations plugins, skipDocumentsValidation: false);
move documents config into each generates entry
- dashboard.ts: remove 14 handwritten interfaces and 6 internal query
type aliases; derive types via NonNullable<GetXxxQuery['xxx']> so
the public hook API shape stays unchanged
- admin/student/teacher page.tsx: add ?? "--" / ?? 0 null guards on
StatCard value props to match schema nullable semantics (parent page
already uses toFixed chain, no change needed)
Acceptance (ARCHITECTURE.md §10 P1-7):
- codegen 3 outputs all SUCCESS
- tsc 0 errors / eslint 0 errors / vitest 231 passed / next build ok
- 6 operations strictly match schema with 0 errors
Refs: ARCHITECTURE.md §5.3 data layer / §10 P1-7
2026-07-22 15:37:06 +08:00
SpecialX
9358372657
feat(portal-shell): add MSW mock layer with production bundle exclusion (P1-5)
...
MSW v2.7.0 fallback layer covering dashboard/users/exams/grades domains.
NEXT_PUBLIC_MSW=1 enables browser Service Worker + SSR route handler mock
responses without backend. Production build excludes all mock data via
Turbopack resolveAlias redirecting @/mocks to empty stub.
Acceptance: build bundle (client+server) verified clean of mock strings;
typecheck/lint/vitest (231 tests) all pass.
2026-07-22 14:48:30 +08:00
SpecialX
98058eb16b
feat(portal-shell): wire dashboards to real data-ana queries (P1-2)
...
- add dashboard.graphql.ts with 6 real aggregate queries
(teacherDashboard / studentDashboard / parentDashboard /
adminDashboard / warnings / errorBookStats), snake_case aligned
- add dashboard.ts with 6 hooks + full domain model types
- add 4 role dashboard pages (teacher/student/parent/admin)
using DashboardShell + StatCard + DashboardSection with
loading / error / success tri-state
- update [[...route]]/page.tsx to redirect /shell -> /shell/{role}
- retire 6 fake contract queries and hooks (grades/homeworks/
schedule/attendance/exams/announcements) and mark widget
placeholders as migrated
- update universal.test.ts to drop retired hook tests
- mark ARCHITECTURE.md P1-2 as completed with acceptance evidence
2026-07-22 12:33:22 +08:00
SpecialX
cfb7b005fd
feat(portal-shell): v2.1 P0 auth + middleware + login + graphql proxy
...
- 新增 ARCHITECTURE.md v3.0:portal-shell 架构权威文档
涵盖 §3.4 V3-A2/A3 认证链、§4 GraphQL 联邦、§5 安全、
§6 部署、§10 P0-P3 验收清单
- 新增 middleware.ts:认证 + 路由门禁
httpOnly cookie edu_session(JWT)读取
DEV_MODE 合成 dev-user/teacher 身份(NODE_ENV!=production &&
NEXT_PUBLIC_DEV_MODE=true)
生产模式 jose JWKS RS256 验签(iss/aud 校验)
路由权限位图注入 x-user-id/x-user-role/x-user-permissions 头
/shell/** 强制 checkRoutePermission,拒绝跳 /shell/forbidden
- 新增 instrumentation.ts:生产环境 DEV_MODE 强制 false
防止生产环境误开 DEV_MODE 合成身份
- 新增 app/api/auth/login/route.ts + logout/route.ts
登录走 api-gateway /v1/iam/login
设置 httpOnly + Secure + SameSite=Strict cookie
- 新增 app/api/graphql/route.ts:同域 GraphQL 代理
转发到 apollo-router,注入 router-authorization 头
- 新增 app/login/page.tsx + login-form.tsx
zod 表单校验,next 参数支持
- 新增 app/shell/forbidden/page.tsx:403 页面
- 更新 route-permissions.ts:补全 P0 路由权限映射
- 更新 permission-bitmap.ts(shared-ts):位图编码/解码
- 更新 apollo-client.ts:DEV_MODE APQ 关闭,错误处理
- 更新 config-fetcher.ts:config-service 直连降级
- 更新 ApolloProvider.tsx:SSR/RSC 兼容
- 更新 eslint.config.js:design-tokens/no-hardcoded-fonts
白名单调整
2026-07-22 11:35:36 +08:00
SpecialX
9cedf0c437
feat(portal-shell): v2.0 P0 shadcn standardization + security + streaming + error handling
...
- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等
- Tailwind v4 + @theme inline,移除 tailwind.config.js
- React 19 use() + Suspense 流式渲染,首屏骨架秒出
- 三级错误边界:Route → Section → Widget 层层兜底
- 错误上报:useErrorReport → sendBeacon → /api/log mock 端点
- 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围
- 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99%
- notify 统一 Toast 封装,禁止业务直接 import sonner
- PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套)
验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
2026-07-17 16:10:05 +08:00
SpecialX
9bee920e4d
test(portal-shell): add security stack tests for PQ manifest and APQ
...
Covers v2.1 M3 安全加固验证:
- PQ Manifest 完整性(6 cases):DocumentNode 校验、sha256 稳定性、确定性、唯一性、manifest 文件有效性、hash 一致性
- Query depth limit(2 cases):11 层嵌套构造、合法查询构造(实际拒绝由 apollo-router limits.max_depth=10 执行)
- APQ behavior(2 cases):默认启用、NEXT_PUBLIC_APOLLO_APQ=false 关闭
测试结果:95/95 passed (85 原有 + 10 新增)
2026-07-17 13:35:37 +08:00
SpecialX
b30d43f983
feat(portal-shell): enable Apollo Client APQ + PQ manifest generator
...
Task 12-13 of portal-shell data abstraction plan (M3 security).
APQ (Automatic Persisted Queries):
- Add createPersistedQueryLink with sha256 to apollo-client.ts
- Production: client sends only query hash, not plaintext query
- Dev: NEXT_PUBLIC_APOLLO_APQ=false to disable for debugging
- Prevents attackers from crafting arbitrary queries via DevTools
PQ Manifest generator:
- New scripts/generate-pq-manifest.ts iterates operations barrel
- Outputs public/pq-manifest.json (sha256 -> query text whitelist)
- prebuild hook: codegen + generate-pq-manifest before next build
- 51 queries currently registered
- crypto-hash dependency added
- typecheck + lint (0 errors) + test (85/85) verified
2026-07-17 13:31:11 +08:00
SpecialX
2910a90271
feat(portal-shell): extract domain API layer and migrate 31 widgets
...
Task 4-10 of portal-shell data abstraction plan (M1-M2).
Add 7 domain API modules under src/lib/api/ (parent/admin/teacher/
student/universal/sidebar/topbar), each exposing semantic hooks that
wrap useWidgetQuery/useWidgetMutation and return flattened domain
models. Widget code now imports from @/lib/api instead of inlining
gql literals.
- 31 widgets migrated (gql literal count in widgets: 0)
- 7 test files (85 cases, all passing)
- topbar.useNotifications renamed to useNotificationBell to avoid
barrel export collision with universal.useNotifications
- typecheck + lint (0 errors) + test (85/85) verified
2026-07-17 13:07:24 +08:00
SpecialX
f623dcf4a7
feat(portal-shell): extract gql documents to operations layer
...
M1 Task 3: 从 31 widget 抽取 51 个 gql 文档到 7 个 operations 文件
- universal(7) + sidebar(3) + topbar(3) + teacher(6) + student(8) + parent(4) + admin(20) = 51 DOC
- operations/index.ts barrel 统一出口
- codegen.yml 启用 documents + skipDocumentsValidation(services 子图字段待补齐)
- 生成 types.ts (28KB) + operations.ts (10KB)
2026-07-17 12:37:36 +08:00
SpecialX
7c234947e1
feat(portal-shell): add graphql-codegen configuration
...
M1 Task 2: 配置 graphql-codegen 与 federation schema 预处理
- codegen.yml: schema 从 combined-schema.graphql 读取(federation 已剥离)
- scripts/normalize-schema.ts: 把 7 个子图的 extend type Query 合并为 type Query
- package.json: 新增 codegen/codegen:watch scripts + 4 个 codegen deps + tsx
- .gitignore: 忽略 src/lib/api/__generated__/
- documents 配置暂注释,Task 3 创建 operations 文件后启用
2026-07-17 12:12:37 +08:00
SpecialX
989603e318
feat(portal-shell): add lib/api skeleton with errors and types
...
M1 Task 1: 创建 4 层数据抽象层的骨架文件
- errors.ts: ApiError + GraphQLErrorCode 枚举
- types.ts: Pagination / PaginatedResult / UseQueryResult / UseMutationResult
- internal.ts: normalizeError 把 ApolloError 转为 ApiError
- index.ts: barrel 出口
2026-07-17 12:06:01 +08:00
SpecialX
514e26ebb4
feat(portal-shell): implement portal-shell with apollo-router integration
...
M8: portal-shell unified frontend shell (Modular Monolith + micro-kernel).
- Apollo Client -> apollo-router (port 4010, RSC prefetch)
- 5 layouts: classic/focus/split/triple/canvas
- Registry + PluginLoader (dynamic import ssr:false)
- 3-layer props merge, Zustand PluginStore
- 4 widgets: grades/notification-bell/user-menu/class-selector
- config-service: new pluginConfig GraphQL resolver
- apollo-router: CORS + header propagation for portal-shell
- docker-compose.yml: portal-shell service block
2026-07-15 08:06:09 +08:00