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

@@ -60,16 +60,19 @@ endpoints:
status: 200
content: |-
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh_token": "abc123def456",
"token_type": "bearer",
"expires_in": 3600,
"user": {
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Alice Johnson",
"email": "user@example.com",
"role": "manager"
}
"role": "manager",
"active": true,
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z"
},
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh_token": "abc123def456",
"token_type": "bearer",
"expires_in": 3600
}
headers: []
description: ''
@@ -141,6 +144,15 @@ endpoints:
status: 200
content: |-
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Alice Johnson",
"email": "user@example.com",
"role": "manager",
"active": true,
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z"
},
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh_token": "newtoken123",
"token_type": "bearer",

View File

@@ -47,21 +47,22 @@ endpoints:
custom: []
status: 200
content: |-
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role_id": 1,
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
]
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
]
}
headers: []
description: ''
responseFields: []
@@ -150,17 +151,18 @@ endpoints:
status: 201
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role_id": 1,
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
}
headers: []
description: ''
@@ -220,17 +222,18 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role_id": 1,
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "150.00",
"active": true,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T10:00:00.000000Z"
}
}
headers: []
description: ''
@@ -339,17 +342,18 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role_id": 1,
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "175.00",
"active": false,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T11:00:00.000000Z"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"role": {
"id": 1,
"name": "Backend Developer"
},
"hourly_rate": "175.00",
"active": false,
"created_at": "2024-01-15T10:00:00.000000Z",
"updated_at": "2024-01-15T11:00:00.000000Z"
}
}
headers: []
description: ''

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: ''
-

View File

@@ -80,15 +80,20 @@ endpoints:
status: 200
content: |-
{
"person_days": 18.5,
"hours": 148,
"details": [
{
"date": "2026-02-02",
"availability": 1,
"is_pto": false
}
]
"data": {
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"month": "2026-02",
"working_days": 20,
"person_days": 18.5,
"hours": 148,
"details": [
{
"date": "2026-02-02",
"availability": 1,
"is_pto": false
}
]
}
}
headers: []
description: ''
@@ -152,17 +157,19 @@ endpoints:
status: 200
content: |-
{
"month": "2026-02",
"person_days": 180.5,
"hours": 1444,
"members": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Ada Lovelace",
"person_days": 18.5,
"hours": 148
}
]
"data": {
"month": "2026-02",
"total_person_days": 180.5,
"total_hours": 1444,
"members": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Ada Lovelace",
"person_days": 18.5,
"hours": 148
}
]
}
}
headers: []
description: ''
@@ -226,8 +233,19 @@ endpoints:
status: 200
content: |-
{
"month": "2026-02",
"possible_revenue": 21500.25
"data": {
"month": "2026-02",
"possible_revenue": 21500.25,
"member_revenues": [
{
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"team_member_name": "Ada Lovelace",
"hours": 148,
"hourly_rate": 150.0,
"revenue": 22200.0
}
]
}
}
headers: []
description: ''
@@ -290,14 +308,16 @@ endpoints:
custom: []
status: 200
content: |-
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"date": "2026-02-14",
"name": "Company Holiday",
"description": "Office closed"
}
]
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"date": "2026-02-14",
"name": "Company Holiday",
"description": "Office closed"
}
]
}
headers: []
description: ''
responseFields: []
@@ -372,10 +392,12 @@ endpoints:
status: 201
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"date": "2026-02-14",
"name": "Presidents' Day",
"description": "Office closed"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"date": "2026-02-14",
"name": "Presidents' Day",
"description": "Office closed"
}
}
headers: []
description: ''
@@ -514,16 +536,18 @@ endpoints:
custom: []
status: 200
content: |-
[
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"start_date": "2026-02-10",
"end_date": "2026-02-12",
"status": "pending",
"reason": "Family travel"
}
]
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"start_date": "2026-02-10",
"end_date": "2026-02-12",
"status": "pending",
"reason": "Family travel"
}
]
}
headers: []
description: ''
responseFields: []
@@ -610,12 +634,14 @@ endpoints:
status: 201
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"start_date": "2026-02-10",
"end_date": "2026-02-12",
"status": "pending",
"reason": "Family travel"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"team_member_id": "550e8400-e29b-41d4-a716-446655440000",
"start_date": "2026-02-10",
"end_date": "2026-02-12",
"status": "pending",
"reason": "Family travel"
}
}
headers: []
description: ''
@@ -667,8 +693,10 @@ endpoints:
status: 200
content: |-
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"status": "approved"
"data": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"status": "approved"
}
}
headers: []
description: ''