Files
wordpress-theme-aksrt/tools/admin-contract-map.md
T
kate522 52e9e2353f chore(admin): add contract audit baseline and incomplete build notice
Introduce tools/audit-admin-contracts.php to fail on missing schemaPage
sections, missing REST $this callbacks, and incomplete admin build chunks.
Document menu/schema deploy rules and surface a wp-admin error when
assets/admin/build is missing modules instead of failing silently.
2026-07-11 13:26:19 +08:00

52 lines
2.0 KiB
Markdown

# Admin contract map
Generated by process, not a migration guide. Source of truth for menu ↔ schema wiring.
## Rules
1. Every `schemaPage` must have matching PHP section under the same domain.
2. Enum field values must be identical in PHP schema and JS schema.
3. REST `'callback' => [$this, 'method']` methods must exist (class or trait).
4. Deploy `assets/admin/build/` as one atomic unit after `npm run build`.
5. No compat aliases, dual-read, or silent frontend catch for missing APIs.
## Audit
```bash
php tools/audit-admin-contracts.php
```
Exit code `1` means hard contract errors.
## Domain builders
| Domain | PHP builder map key | Menu constants file |
|--------|---------------------|---------------------|
| global | `AKSRT_Admin_Schema_Global` | `assets/admin/src/constants/sections/global.js` |
| page_display | `AKSRT_Admin_Schema_Page_Display` | `page-display.js` |
| post_list | `AKSRT_Admin_Schema_Post_List` | `post-list.js` |
| permissions | `AKSRT_Admin_Schema_Permissions` | `permissions.js` |
| users | `AKSRT_Admin_Schema_Users` | `users.js` |
| payment | `AKSRT_Admin_Schema_Payment` | `payment.js` |
| extensions | `AKSRT_Admin_Schema_Extensions` | `extensions.js` |
| tools | `AKSRT_Admin_Schema_Tools` | `tools.js` |
| shop | `AKSRT_Admin_Schema_Shop` | `shop.js` |
| forum | `AKSRT_Admin_Schema_Forum` | `forum.js` |
## Known custom pages (not schema REST)
These use dedicated Vue pages + dedicated REST modules:
- Homepage: `HomepageSettings` + `/settings/homepage`
- Footer: `FooterSettings` + footer settings API
- Permissions capabilities matrix: `PermissionsCapabilities` + `/permissions/capabilities`
- Shop products/orders and other operational tables
## Deploy checklist
1. `cd assets/admin && npm ci && npm run build`
2. Confirm `build/index.js` and every dynamically imported `./Chunk.hash.js` exist
3. Replace the entire remote `assets/admin/build/` directory
4. Hard-refresh wp-admin (or purge CDN)
5. Re-run `php tools/audit-admin-contracts.php`