MC/website/docs/CP-V2-API-INTEGRATION.md
2026-11-27 23:43:05 +00:00

7.2 KiB
Raw Permalink Blame History

CP V2 API integration

V2 is a new Alpha interface. Existing API contracts are reused; V1 browser modules are functional references and are not imported into V2. A feature without a verified API remains a visible placeholder. Do not add speculative endpoints or backend behavior to make a page appear complete.

Available company contracts

The control-panel router maps /api/companies/manage to website/node/company-admin.mjs. Every request requires a website session. All operations require the existing web.accounts.assign permission; mutations also require the exact control-panel Origin. These contracts are present in the repository. Live availability still depends on deployment of the matching server revision.

Operation Request Response and behavior V2 integration
Account search GET ?account=<username prefix> accounts with id and username; 3–32 valid username characters; up to 12 results Explicit founder and CEO search and selection
Company registry GET ?view=registry&page=<positive integer> companies, page, hasMore, verified access; 50 records per page Registry, founder and CEO tables; company selection
Corporate audit GET ?view=events&page=<positive integer> events, page, hasMore; company, action, actor and timestamp; raw event details excluded Audit register and CEO appointment history
Register company POST JSON with action: register, slug, name, description, founderId Returns new id and pending status; transaction checks founder and writes company plus audit event New Alpha registration form; explicit submission only
Appoint CEO POST JSON with action: appoint-ceo, companyId, ceoId Returns matching company and CEO IDs and changed; locks company and records event; unchanged appointment is idempotent New Alpha CEO appointment form; explicit submission only

Registration does not issue shares or move funds. CEO appointment does not grant website staff permissions. Handle 401 and 403 as an access failure, 400 as rejected input, 409 as a conflict and 503 as unavailable. Never retry an uncertain mutation automatically; refresh and verify the recorded state first.

Company Directorate gaps

The existing company schema records founder and CEO only. It has no verified company-specific role, member grant or access-boundary API. Keep the Company permissions expansion as a placeholder and display the current operator's actual management permission separately. Do not synthesize corporate roles from website rank names.

Future integration needs scoped company membership and grants, explicit authorization rules, bounded reads, versioned mutations, an audit trail and tests for access denial and concurrent changes. Endpoint paths and permission names remain unassigned until the service is designed and approved.

Corporate Administration gaps

Company registry and founder/CEO assignments use the available contracts above. Corporate settings have no verified read or update contract. Keep that tab as an Alpha placeholder.

Future integration needs a settings schema, company-scoped access checks, optimistic version checks, validation and audit events. Other officers must remain unavailable until an actual officer-assignment service exists. Do not present founder or CEO records as a complete officer hierarchy.

Corporate Audit gaps

Registration and CEO changes can be read through the corporate event contract. Compliance reports, reporting exports and compliance verdicts have no verified service. Keep those modules as placeholders; an audit event alone is not a compliance result.

Future integration needs an authorized report schema, report scope and date bounds, provenance, safe export rules and tests. Choose endpoint paths only when that service exists. No page should claim that a report was generated or a company was approved without a confirmed backend result.

Integration checks

  • Keep new page modules independent of the legacy V1 DOM and global events.
  • Use explicit API projections and text rendering; reject malformed response shapes.
  • Clear stale data on failed refresh or permission loss.
  • Check empty, loading, error, conflict and mobile states.
  • Test writes against isolated fixtures; do not create companies or change CEOs in production as a UI test.
  • Publish tested commits through CI and the existing autodeploy, then verify the active revision.

Imperial Revenue

The existing /api/bank/staff GET contract supplies the shared treasury, its exact decimal-string balance, account number, canManage access flag and bounded ledger records. The new Alpha component displays the account, copies its number and provides statement search, incoming/outgoing filters and display sorting. Amounts are never converted to floating-point values. Records expose only the operator and counterparties supplied by the service; missing parties remain “Not recorded.”

No player/account override or query parameters are sent. Authentication, staff treasury permission and upstream access checks remain in the existing backend. The current service bounds its returned ledger; V2 does not claim to show all historical records.

Treasury allocations and staff-treasury transfers have no verified action on this contract. The V1 treasury transfer control was also unavailable. Keep the allocation tab as a documented placeholder, even when canManage is true. The separate managed-official-account transfer route is not a substitute for an authorized staff-treasury allocation service.

Future integration needs explicit source/beneficiary authorization, precise amount validation, a durable idempotent receipt, ledger/audit provenance, concurrency protection and authoritative backend confirmation. Define a route only when that service exists. Full-history paging or exports also require a scoped history contract; do not manufacture extra rows or totals.

Claim Registry — unavailable staff service

The existing /api/kits/orders is personal and may include private redemption data. It is not a staff-wide claims API and must not be used as a substitute. The V2 Claim Registry deliberately performs no claim, code-redemption or fulfilment requests. Its three design tabs now support explicitly labelled in-memory sample records and workflow previews. They never submit claims, codes or delivery requests.

A later backend integration needs a separately authorised staff claim register with bounded pagination, explicit case scope, recipient references, original receipt and delivery references, statuses and timestamps. Read projections must omit reusable private redeem codes. Delivery checks and retry actions require their own permission checks, original idempotency keys and audit entries, and must confirm the upstream result before the UI claims success. Select concrete endpoints only when the service exists and can be tested. No claims or paid receipts were altered during this rebuild.

Current rendering convention

New V2 page modules pass shellHost: host to createCPV2Page. This uses the single shell artwork banner and removes only that page's wrapper title/description duplicates. Older modules keep their current presentation until the owner-requested final style batch. Do not globally hide headings or restyle old pages during the functional rebuild.