nxtgauge-backend-rust/docs/openapi.wallet-holds.json

103 lines
4.3 KiB
JSON
Raw Permalink Normal View History

feat(db,ci): fix missing ai_credits tables, wire integration tests to CI Re-enables and corrects 20260703210000_ai_credits_wallet, which had been disabled (.up.sql.skip) in commit 0163349 because 'relation already exists' aborted the original CREATE TABLE script on its very first table (ai_plans) - silently leaving ai_credit_ledger and ai_reservation_holds never created, despite the wallet system being actively wired into apps/users/handlers/ai_credits.rs, apps/payments, apps/cron with real subscription rows already in prod. Rewrote the migration to be idempotent: ADD COLUMN IF NOT EXISTS to bring ai_plans/user_ai_subscriptions/ai_feature_costs/ai_usage_logs up to the full column set crates/db/src/models/ai_credits.rs expects (safe zero/default backfills, no data loss - verified against the 3 existing subscription rows), and CREATE TABLE IF NOT EXISTS for the 2 genuinely-missing tables. down.sql updated to only reverse what this corrected version actually adds, not drop tables that predate it. Applied directly to the live database (verified schema + existing rows intact afterward). Also wires crates/db/tests/ai_credits.rs + ai_credits_reaper.rs to Forgejo Actions CI (docs/LIVE_SERVER_RUNBOOK.md step 6): - New TEST_DATABASE_URL repo secret, pointing at a dedicated nxtgauge_test database (created fresh, schema mirrored from live prod via pg_dump --schema-only - never runs against the real nxtgauge DB). - .forgejo/workflows/test.yaml: runs on push to main/high-performance, skips when crates/db/ isn't touched, cargo test -p db --test ai_credits --test ai_credits_reaper -- --test-threads=1. Also commits docs/openapi.wallet-holds.json (hand-written minimal OpenAPI spec used for schemathesis fuzzing in step 4) and gitignores the local .schemathesis/ cache directory from that run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 17:31:22 +05:30
{
"openapi": "3.0.3",
"info": {
"title": "Nxtgauge — Wallet Holds (minimal, hand-maintained)",
"version": "1.0.0",
"description": "Covers only the routes deployed by the wallet-holds/printpdf release (see docs/LIVE_SERVER_RUNBOOK.md). This is deliberately narrow — the full backend has 341 routes across 19 services and none have utoipa annotations yet (tracked as a separate follow-up). Generated by hand from crates/contracts/src/profession_shared.rs (wallet_holds, wallet_release_hold) to give schemathesis something real to fuzz against today's change without taking on full OpenAPI generation."
},
"servers": [
{ "url": "https://api.nxtgauge.com" }
],
"security": [{ "bearerAuth": [] }],
"paths": {
"/api/photographers/wallet/me/holds": {
"get": {
"operationId": "listWalletHolds",
"summary": "List the authenticated professional's tracecoin holds",
"parameters": [
{ "name": "page", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1 } },
{ "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1, "maximum": 200 } }
],
"responses": {
"200": {
"description": "Paginated list of holds",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["data", "pagination"],
"properties": {
"data": { "type": "array", "items": { "$ref": "#/components/schemas/Hold" } },
"pagination": { "$ref": "#/components/schemas/Pagination" }
}
}
}
}
},
"401": { "description": "Missing/invalid JWT" },
"500": { "description": "Server error" }
}
}
},
"/api/photographers/wallet/me/holds/{id}/release": {
"post": {
"operationId": "releaseWalletHold",
"summary": "Release an ACTIVE hold owned by the authenticated professional",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "Hold released, tracecoins returned to available balance",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": { "message": { "type": "string" } }
}
}
}
},
"401": { "description": "Missing/invalid JWT" },
"404": { "description": "Hold not found or not owned by caller" },
"409": { "description": "Hold exists but is not ACTIVE (already SETTLED/RELEASED/EXPIRED)" },
"500": { "description": "Server error" }
}
}
}
},
"components": {
"securitySchemes": {
"bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" }
},
"schemas": {
"Hold": {
"type": "object",
"required": ["id", "wallet_id", "user_id", "amount", "reason", "status", "created_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"wallet_id": { "type": "string", "format": "uuid" },
"user_id": { "type": "string", "format": "uuid" },
"amount": { "type": "integer" },
"reason": { "type": "string" },
"reference_id": { "type": "string", "format": "uuid", "nullable": true },
"status": { "type": "string", "enum": ["ACTIVE", "SETTLED", "RELEASED", "EXPIRED"] },
"expires_at": { "type": "string", "format": "date-time", "nullable": true },
"settled_at": { "type": "string", "format": "date-time", "nullable": true },
"settled_ledger_id": { "type": "string", "format": "uuid", "nullable": true },
"released_at": { "type": "string", "format": "date-time", "nullable": true },
"created_at": { "type": "string", "format": "date-time" }
}
},
"Pagination": {
"type": "object",
"required": ["page", "limit"],
"properties": {
"page": { "type": "integer" },
"limit": { "type": "integer" }
}
}
}
}
}