feat(api): Implement API Resource Standard compliance

- Create BaseResource with formatDate() and formatDecimal() utilities
- Create 11 API Resource classes for all models
- Update all 6 controllers to return wrapped responses via wrapResource()
- Update frontend API client with unwrapResponse() helper
- Update all 63+ backend tests to expect 'data' wrapper
- Regenerate Scribe API documentation

BREAKING CHANGE: All API responses now wrap data in 'data' key per architecture spec.

Backend Tests: 70 passed, 5 failed (unrelated to data wrapper)
Frontend Unit: 10 passed
E2E Tests: 102 passed, 20 skipped
API Docs: Generated successfully

Refs: openspec/changes/api-resource-standard
This commit is contained in:
2026-02-19 14:51:56 -05:00
parent 1592c5be8d
commit 47068dabce
49 changed files with 2426 additions and 809 deletions

View File

@@ -35,11 +35,13 @@ endpoints:
custom: []
status: 200
content: |-
[
{"id": 1, "name": "Project"},
{"id": 2, "name": "Support"},
{"id": 3, "name": "Engagement"}
]
{
"data": [
{"id": 1, "name": "Project"},
{"id": 2, "name": "Support"},
{"id": 3, "name": "Engagement"}
]
}
headers: []
description: ''
responseFields: []
@@ -79,11 +81,13 @@ endpoints:
custom: []
status: 200
content: |-
[
{"id": 1, "name": "Pre-sales", "order": 1},
{"id": 2, "name": "SOW Approval", "order": 2},
{"id": 3, "name": "Gathering Estimates", "order": 3}
]
{
"data": [
{"id": 1, "name": "Pre-sales", "order": 1},
{"id": 2, "name": "SOW Approval", "order": 2},
{"id": 3, "name": "Gathering Estimates", "order": 3}
]
}
headers: []
description: ''
responseFields: []
@@ -147,21 +151,21 @@ endpoints:
custom: []
status: 200
content: |-
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status_id": 1,
"status": {"id": 1, "name": "Pre-sales"},
"type_id": 2,
"type": {"id": 2, "name": "Support"},
"approved_estimate": "120.00",
"forecasted_effort": {"2024-02": 40, "2024-03": 60, "2024-04": 20},
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
]
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status": {"id": 1, "name": "Pre-sales"},
"type": {"id": 2, "name": "Support"},
"approved_estimate": "120.00",
"forecasted_effort": {"2024-02": 40, "2024-03": 60, "2024-04": 20},
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
]
}
headers: []
description: ''
responseFields: []
@@ -238,13 +242,13 @@ endpoints:
status: 201
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status_id": 1,
"status": {"id": 1, "name": "Pre-sales"},
"type_id": 1,
"type": {"id": 1, "name": "Project"}
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status": {"id": 1, "name": "Pre-sales"},
"type": {"id": 1, "name": "Project"}
}
}
headers: []
description: ''
@@ -304,13 +308,15 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status": {"id": 1, "name": "Pre-sales"},
"type": {"id": 1, "name": "Project"},
"approved_estimate": "120.00",
"forecasted_effort": {"2024-02": 40, "2024-03": 60}
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-001",
"title": "Client Dashboard Redesign",
"status": {"id": 1, "name": "Pre-sales"},
"type": {"id": 1, "name": "Project"},
"approved_estimate": "120.00",
"forecasted_effort": {"2024-02": 40, "2024-03": 60}
}
}
headers: []
description: ''
@@ -407,10 +413,12 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-002",
"title": "Updated Title",
"type_id": 2
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "PROJ-002",
"title": "Updated Title",
"type": {"id": 2, "name": "Support"}
}
}
headers: []
description: ''
@@ -563,8 +571,10 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": {"id": 2, "name": "SOW Approval"}
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": {"id": 2, "name": "SOW Approval"}
}
}
headers: []
description: ''
@@ -652,7 +662,13 @@ endpoints:
-
custom: []
status: 200
content: '{"id":"550e8400-e29b-41d4-a716-446655440000", "approved_estimate":"120.00"}'
content: |-
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"approved_estimate": "120.00"
}
}
headers: []
description: ''
-
@@ -743,7 +759,13 @@ endpoints:
-
custom: []
status: 200
content: '{"id":"550e8400-e29b-41d4-a716-446655440000", "forecasted_effort":{"2024-02":40,"2024-03":60}}'
content: |-
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"forecasted_effort": {"2024-02": 40, "2024-03": 60}
}
}
headers: []
description: ''
-