KB-131D rev 7

Custom Code Registry

6 min read Revision 7
ssotgovernance

Custom Code Registry

CUSTOM CODE REGISTRY

Cập nhật: 2026-03-04 (S102 — Phase 2A/Polish entries added) Danh sách TẤT CẢ file custom (không có trong Agency OS / Nuxt gốc). Mục đích: Khi upgrade Nuxt/Directus/Agency OS, review từng file này. Cập nhật: BẮT BUỘC mỗi khi thêm/sửa custom code.


Server Middleware

strip-knowledge-cookie.ts

  • File: web/server/middleware/strip-knowledge-cookie.ts
  • Loại: new
  • Mục đích: Xóa Directus session cookie + Vary:cookie header khỏi /knowledge routes. Cho phép mọi user nhận cùng response (không phân biệt session).
  • Phụ thuộc API: Nitro defineEventHandler, getRequestURL, event.node.res.writeHead
  • Cách verify: curl -sI localhost:3000/knowledge | grep set-cookie (kỳ vọng: trống)
  • Ngày tạo: 2026-02-12, cập nhật 2026-02-16 (P37B xóa cache-control override, để Nuxt ISR tự quản)
  • Tạo bởi: WEB-70F, cập nhật WEB-71-P37B

routeRules (nuxt.config.ts)

Nuxt ISR tiêu chuẩn — Content luôn mới

  • File: web/nuxt.config.ts (section routeRules)
  • Loại: modified
  • Mục đích: Dynamic pages dùng Nuxt ISR tiêu chuẩn (swr:true) — Nuxt tự cache nội bộ + revalidate từ Directus mỗi request. KHÔNG dùng s-maxage, KHÔNG CDN cache dynamic content. Static assets (/_nuxt/**) cache immutable.
  • Phụ thuộc API: Nuxt routeRules.swr (core feature)
  • Cách verify: curl -sI localhost:3000/knowledge | grep cache-control (kỳ vọng: không có s-maxage)
  • Nguyên tắc: Content luôn mới, không cần purge mechanism. Khi traffic lớn → migrate Cloudflare (có purge API tiêu chuẩn).
  • Ngày tạo: 2026-02-12, cập nhật 2026-02-16 (P37B đơn giản hóa)
  • Tạo bởi: WEB-70B, cập nhật WEB-71-P37B

Directus Flows

Cache Invalidation — Knowledge Update

  • Loại: Directus config (không phải code)
  • Trạng thái: ACTIVE nhưng KHÔNG CÓ webhook operation (chỉ trigger)
  • Ghi chú: Không cần thiết nữa sau P37B (không CDN cache → không cần purge). Có thể disable hoặc giữ cho tương lai khi migrate Cloudflare.
  • Ngày tạo: 2026-02-12
  • Tạo bởi: WEB-70F

Sitemap Dynamic Source

urls.ts

  • File: web/server/routes/__sitemap__/urls.ts
  • Loai: new
  • Muc dich: Cung cap danh sach URL dong cho @nuxtjs/sitemap
  • Config kem: nuxt.config.ts -> sitemap.sources: ['/__sitemap__/urls']
  • Cach verify: curl -s .../sitemap.xml | grep -c '<loc>' (>100)
  • Ngay tao: 2026-02-24, WEB-80d

Workflow Supervisor UI (M002-WCR-UI)

Workflow schema DOT extensions

  • Files: dot/bin/dot-schema-workflows-ensure, dot/bin/dot-schema-workflow-governance-ensure
  • Loai: modified
  • Muc dich: Mo rong workflows voi process_code/sort/parent_workflow_id/level va mo rong workflow_steps voi trigger_in_text/trigger_out_text bang DOT 100%.
  • Cach verify: Chay ./dot/bin/dot-schema-workflows-ensure --cloud va ./dot/bin/dot-schema-workflow-governance-ensure --cloud, kiem tra fields moi xuat hien trong Directus.
  • Ngay cap nhat: 2026-03-03, M002-WCR-UI

Workflow registry/detail APIs

  • Files: web/server/api/workflows/registry.get.ts, web/server/api/workflows/[id]/matrix.get.ts, web/server/api/workflows/[id]/change-requests.get.ts, web/server/utils/directusService.ts
  • Loai: new + modified
  • Muc dich: Bo sung API server-side cho danh sach quy trinh co pagination/search/filter, ma tran buoc, va danh sach WCR; dung service token de UI supervisor khong phu thuoc public Directus permissions.
  • Cach verify: pnpm typecheck, pnpm build, sau do hit cac route /api/workflows/registry, /api/workflows/:id/matrix, /api/workflows/:id/change-requests trong moi truong co service token.
  • Ngay tao: 2026-03-03, M002-WCR-UI

Workflow supervisor pages + partials

  • Files: web/pages/knowledge/workflows/index.vue, web/pages/knowledge/workflows/[id].vue, web/components/modules/workflow-module/partials/ProcessRegistryView.vue, web/components/modules/workflow-module/partials/WorkflowMatrixView.vue, web/components/modules/workflow-module/partials/WcrIntakePanel.vue, web/components/navigation/TheHeader.vue, web/composables/useWorkflows.ts, web/types/workflows.ts, web/types/workflow-dsl.ts
  • Loại: new + modified
  • Mục đích: Thêm menu Workflows, trang registry supervisor, trang detail với 4 tab (Mô tả / Trình tự / Sơ đồ BPMN / Đề xuất thay đổi), data contract cho schema/trigger text.
  • Cập nhật S102: Tab "Bảng bước" → "Trình tự"; bpmn-auto-layout dagre (rankdir TB in progress); Tab active CSS fix; WCR permissions added.
  • Ngày tạo: 2026-03-03, M002-WCR-UI; cập nhật 2026-03-04 PR #430/431/432

DirectusDataTable Module (Table Module — S101)

DirectusDataTable component

  • File: web/components/modules/table-module/DirectusDataTable.vue (và các sub-components)
  • Loại: new — module tái sử dụng
  • Mục đích: Schema-driven table — chỉ cần khai báo collection + fields config → render bảng đầy đủ (pagination/sort/search/filter). KHÔNG code mới cho từng bảng.
  • SSOT: knowledge/dev/ssot/table-module/index.md
  • Cách verify: Dùng trong WorkflowMatrixView — khai báo collection workflow_steps → render 10 rows, pagination OK.
  • Ngày tạo: 2026-03-03/04, PR #427-430

DSL → BPMN Generator

workflows diagram API + bpmn-auto-layout

  • File: web/server/api/workflows/[id]/diagram.get.ts
  • Loại: new
  • Mục đích: Load workflow_steps + relations từ Directus → generate BPMN XML → return. Dùng bpmn-auto-layout (dagre) cho layout tự động.
  • Status: TB layout in progress (Mission M002-BPMN-V2)
  • Ngày tạo: 2026-03-03, Phase 2A; cập nhật 2026-03-04 PR #432