feat: enforce WP6-03 external service hard stops
Dada P0-A isolated Windows CI / validate-and-package (push) Successful in 9m34s

This commit is contained in:
suyx
2026-08-04 02:17:21 +08:00
parent 19212cc1b6
commit 70754ec12b
9 changed files with 1572 additions and 1 deletions
+625
View File
@@ -696,6 +696,83 @@
],
"type": "object"
},
"AdminServiceHealthCheckRequest": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"reason": {
"maxLength": 120,
"pattern": "^[a-zA-Z0-9_. -]+$",
"type": "string"
}
},
"required": [
"available"
],
"type": "object"
},
"AdminServiceLimitRequest": {
"additionalProperties": false,
"properties": {
"hard_limit": {
"minimum": 1,
"type": "integer"
},
"period_type": {
"$ref": "#/components/schemas/ExternalServicePeriodType"
}
},
"required": [
"period_type",
"hard_limit"
],
"type": "object"
},
"AdminServiceParams": {
"additionalProperties": false,
"properties": {
"service_id": {
"$ref": "#/components/schemas/ExternalServiceId"
}
},
"required": [
"service_id"
],
"type": "object"
},
"AdminServiceRecoveryRequest": {
"additionalProperties": false,
"properties": {
"check_id": {
"maxLength": 64,
"minLength": 1,
"pattern": "^[0-9a-fA-F-]+$",
"type": "string"
}
},
"required": [
"check_id"
],
"type": "object"
},
"AdminServicesResponse": {
"additionalProperties": false,
"properties": {
"services": {
"items": {
"$ref": "#/components/schemas/ExternalServiceUsage"
},
"maxItems": 3,
"type": "array"
}
},
"required": [
"services"
],
"type": "object"
},
"AdminSessionResponse": {
"additionalProperties": false,
"properties": {
@@ -2450,6 +2527,119 @@
}
]
},
"ExternalServiceId": {
"anyOf": [
{
"enum": [
"resend_email"
],
"type": "string"
},
{
"enum": [
"amap_web_service"
],
"type": "string"
}
]
},
"ExternalServicePeriodType": {
"anyOf": [
{
"enum": [
"daily"
],
"type": "string"
},
{
"enum": [
"monthly"
],
"type": "string"
}
]
},
"ExternalServiceStatus": {
"anyOf": [
{
"enum": [
"active"
],
"type": "string"
},
{
"enum": [
"paused_quota"
],
"type": "string"
},
{
"enum": [
"paused_provider"
],
"type": "string"
},
{
"enum": [
"disabled"
],
"type": "string"
}
]
},
"ExternalServiceUsage": {
"additionalProperties": false,
"properties": {
"hard_limit": {
"minimum": 1,
"type": "integer"
},
"pause_reason": {
"anyOf": [
{
"maxLength": 120,
"pattern": "^[a-z0-9_.-]+$",
"type": "string"
},
{
"type": "null"
}
]
},
"period_start": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"period_type": {
"$ref": "#/components/schemas/ExternalServicePeriodType"
},
"service_id": {
"$ref": "#/components/schemas/ExternalServiceId"
},
"service_status": {
"$ref": "#/components/schemas/ExternalServiceStatus"
},
"updated_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"used_count": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"service_id",
"period_type",
"period_start",
"hard_limit",
"used_count",
"service_status",
"pause_reason",
"updated_at"
],
"type": "object"
},
"FailedEmptyTrashRequest": {
"additionalProperties": false,
"properties": {
@@ -8331,6 +8521,441 @@
]
}
},
"/api/v1/admin/services": {
"get": {
"operationId": "getAdminServices",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminServicesResponse"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Services"
]
}
},
"/api/v1/admin/services/{service_id}/health-check": {
"post": {
"operationId": "checkAdminServiceHealth",
"parameters": [
{
"in": "path",
"name": "service_id",
"required": true,
"schema": {
"$ref": "#/components/schemas/ExternalServiceId"
}
},
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
{
"in": "header",
"name": "x-csrf-token",
"required": true,
"schema": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminServiceHealthCheckRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"check_id": {
"type": "string"
},
"checked_at": {
"type": "string"
}
},
"required": [
"check_id",
"available",
"checked_at"
],
"type": "object"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"403": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Services"
]
}
},
"/api/v1/admin/services/{service_id}/limits": {
"patch": {
"operationId": "updateAdminServiceHardLimit",
"parameters": [
{
"in": "path",
"name": "service_id",
"required": true,
"schema": {
"$ref": "#/components/schemas/ExternalServiceId"
}
},
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
{
"in": "header",
"name": "x-csrf-token",
"required": true,
"schema": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminServiceLimitRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminServicesResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"403": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Services"
]
}
},
"/api/v1/admin/services/{service_id}/recover": {
"post": {
"operationId": "recoverAdminService",
"parameters": [
{
"in": "path",
"name": "service_id",
"required": true,
"schema": {
"$ref": "#/components/schemas/ExternalServiceId"
}
},
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
{
"in": "header",
"name": "x-csrf-token",
"required": true,
"schema": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminServiceRecoveryRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"status": {
"enum": [
"active"
],
"type": "string"
}
},
"required": [
"status"
],
"type": "object"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"403": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Services"
]
}
},
"/api/v1/admin/users/{userId}/credit-adjustments": {
"post": {
"operationId": "adjustAdminUserCredits",