Built: SQLite (node:sqlite) via server/db.js with checksummed migrations, injectable clock, persistent event scheduler with catch-up, tiny REST router (error envelope, idempotency keys, rate limits, bearer tokens with scrypt passwords), lazy-resource economy in public/js/rules.js + data.js, build/cancel/rename commands, seeded map + spawn ring, generated docs/openapi.json. NETWALL net.js/static.js reused. Tested: manual smoke run only (signup, town view, build, map). No unit tests or e2e yet. NOT done: military, expansion, social, client, push, deploy docs, bots/admin. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
1929 lines
46 KiB
JSON
1929 lines
46 KiB
JSON
{
|
|
"openapi": "3.0.3",
|
|
"info": {
|
|
"title": "UPSTREAM API",
|
|
"version": "1.0.0",
|
|
"description": "Generated by tools/gen-openapi.js from server/routes. Every response carries serverTime; errors use the { error: { code, message, details } } envelope. Codes: bad_request, validation_failed, unauthorized, invalid_credentials, forbidden, not_found, method_not_allowed, conflict, request_in_progress, idempotency_key_reuse, payload_too_large, rate_limited, internal_error, signup_closed, username_taken, world_full, unknown_building, not_buildable, max_level, requirements_not_met, already_queued, queue_full, not_enough_resources"
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "/api/v1"
|
|
}
|
|
],
|
|
"paths": {
|
|
"/auth/login": {
|
|
"post": {
|
|
"summary": "Log in on a device and get a bearer token",
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"operationId": "postAuthLogin",
|
|
"parameters": [],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"username",
|
|
"password"
|
|
],
|
|
"properties": {
|
|
"username": {
|
|
"type": "string",
|
|
"minLength": 3,
|
|
"maxLength": 20,
|
|
"pattern": "^[A-Za-z0-9_-]+$"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"minLength": 8,
|
|
"maxLength": 128
|
|
},
|
|
"device": {
|
|
"type": "string",
|
|
"maxLength": 40
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/AuthResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: invalid_credentials",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "Error codes: forbidden",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: idempotency_key_reuse, validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"429": {
|
|
"description": "Error codes: rate_limited",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/logout": {
|
|
"post": {
|
|
"summary": "Revoke the token used for this request",
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"operationId": "postAuthLogout",
|
|
"parameters": [],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Ok"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: idempotency_key_reuse",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/signup": {
|
|
"post": {
|
|
"summary": "Create an account, join the world and get a bearer token",
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"operationId": "postAuthSignup",
|
|
"parameters": [],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"username",
|
|
"password"
|
|
],
|
|
"properties": {
|
|
"invite": {
|
|
"type": "string",
|
|
"maxLength": 64
|
|
},
|
|
"worldId": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"username": {
|
|
"type": "string",
|
|
"minLength": 3,
|
|
"maxLength": 20,
|
|
"pattern": "^[A-Za-z0-9_-]+$"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"minLength": 8,
|
|
"maxLength": 128
|
|
},
|
|
"device": {
|
|
"type": "string",
|
|
"maxLength": 40
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [],
|
|
"responses": {
|
|
"201": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/AuthResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "Error codes: signup_closed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"409": {
|
|
"description": "Error codes: username_taken, world_full",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: idempotency_key_reuse, validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"429": {
|
|
"description": "Error codes: rate_limited",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/tokens": {
|
|
"get": {
|
|
"summary": "List this account's active device tokens",
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"operationId": "getAuthTokens",
|
|
"parameters": [],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"serverTime",
|
|
"tokens"
|
|
],
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"tokens": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Token"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/tokens/{tokenId}": {
|
|
"delete": {
|
|
"summary": "Revoke one of this account's tokens",
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"operationId": "deleteAuthTokensTokenId",
|
|
"parameters": [
|
|
{
|
|
"name": "tokenId",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Ok"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/map": {
|
|
"get": {
|
|
"summary": "Map viewport: rural areas, incumbent sites and POPs within (x±r, y±r); land tiles are implied",
|
|
"tags": [
|
|
"map"
|
|
],
|
|
"operationId": "getMap",
|
|
"parameters": [
|
|
{
|
|
"name": "x",
|
|
"in": "query",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": -1000,
|
|
"maximum": 1000
|
|
}
|
|
},
|
|
{
|
|
"name": "y",
|
|
"in": "query",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": -1000,
|
|
"maximum": 1000
|
|
}
|
|
},
|
|
{
|
|
"name": "r",
|
|
"in": "query",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 40
|
|
}
|
|
},
|
|
{
|
|
"name": "worldId",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
}
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/MapResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/me": {
|
|
"get": {
|
|
"summary": "The current user, their operators and POPs",
|
|
"tags": [
|
|
"me"
|
|
],
|
|
"operationId": "getMe",
|
|
"parameters": [],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Me"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/notifications": {
|
|
"get": {
|
|
"summary": "Notifications for this user (cursor: after = last seen id)",
|
|
"tags": [
|
|
"me"
|
|
],
|
|
"operationId": "getNotifications",
|
|
"parameters": [
|
|
{
|
|
"name": "after",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "limit",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 100
|
|
}
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/NotificationList"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/towns/{id}": {
|
|
"get": {
|
|
"summary": "Full state of one of your POPs: resources, power, buildings, build queue",
|
|
"tags": [
|
|
"towns"
|
|
],
|
|
"operationId": "getTownsId",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/TownResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/towns/{id}/build": {
|
|
"post": {
|
|
"summary": "Build or upgrade a building (fields f1..f18 or an infrastructure building type) by one level",
|
|
"tags": [
|
|
"towns"
|
|
],
|
|
"operationId": "postTownsIdBuild",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"key"
|
|
],
|
|
"properties": {
|
|
"key": {
|
|
"type": "string",
|
|
"maxLength": 32,
|
|
"pattern": "^[a-z0-9_]+$"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"201": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/BuildResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found, unknown_building",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"409": {
|
|
"description": "Error codes: already_queued, max_level, not_buildable, not_enough_resources, queue_full, requirements_not_met",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: idempotency_key_reuse, validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/towns/{id}/queue/{eventId}": {
|
|
"delete": {
|
|
"summary": "Cancel a running build and get 80% of its cost back",
|
|
"tags": [
|
|
"towns"
|
|
],
|
|
"operationId": "deleteTownsIdQueueEventId",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
{
|
|
"name": "eventId",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Ok"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/towns/{id}/rename": {
|
|
"post": {
|
|
"summary": "Rename a POP",
|
|
"tags": [
|
|
"towns"
|
|
],
|
|
"operationId": "postTownsIdRename",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"name"
|
|
],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"minLength": 2,
|
|
"maxLength": 40
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"bearer": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": [
|
|
"serverTime",
|
|
"name"
|
|
],
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Error codes: unauthorized",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Error codes: not_found",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Error codes: idempotency_key_reuse, validation_failed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Error codes: internal_error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"Cost": {
|
|
"type": "object",
|
|
"properties": {
|
|
"fiber": {
|
|
"type": "integer"
|
|
},
|
|
"hardware": {
|
|
"type": "integer"
|
|
},
|
|
"capital": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"fiber",
|
|
"hardware",
|
|
"capital"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Error": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"error": {
|
|
"type": "object",
|
|
"properties": {
|
|
"code": {
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
},
|
|
"details": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"required": [
|
|
"code",
|
|
"message",
|
|
"details"
|
|
],
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"error"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"World": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"speed": {
|
|
"type": "number"
|
|
},
|
|
"mapRadius": {
|
|
"type": "integer"
|
|
},
|
|
"seed": {
|
|
"type": "integer"
|
|
},
|
|
"startAt": {
|
|
"type": "integer"
|
|
},
|
|
"endAt": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
},
|
|
"status": {
|
|
"type": "string"
|
|
},
|
|
"preset": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"speed",
|
|
"mapRadius",
|
|
"seed",
|
|
"startAt",
|
|
"endAt",
|
|
"status",
|
|
"preset"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"TownSummary": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"x": {
|
|
"type": "integer"
|
|
},
|
|
"y": {
|
|
"type": "integer"
|
|
},
|
|
"isCapital": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"x",
|
|
"y",
|
|
"isCapital"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Operator": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"asNumber": {
|
|
"type": "integer"
|
|
},
|
|
"allianceId": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
},
|
|
"protectionUntil": {
|
|
"type": "integer"
|
|
},
|
|
"world": {
|
|
"$ref": "#/components/schemas/World"
|
|
},
|
|
"towns": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/TownSummary"
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"asNumber",
|
|
"allianceId",
|
|
"protectionUntil",
|
|
"world",
|
|
"towns"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Me": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"user": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"username": {
|
|
"type": "string"
|
|
},
|
|
"createdAt": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"username",
|
|
"createdAt"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"operators": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Operator"
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"user",
|
|
"operators"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"AuthResult": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"token": {
|
|
"type": "string"
|
|
},
|
|
"tokenId": {
|
|
"type": "integer"
|
|
},
|
|
"user": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"username": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"username"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"operators": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Operator"
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"token",
|
|
"tokenId",
|
|
"user",
|
|
"operators"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Token": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"device": {
|
|
"type": "string"
|
|
},
|
|
"createdAt": {
|
|
"type": "integer"
|
|
},
|
|
"lastUsedAt": {
|
|
"type": "integer"
|
|
},
|
|
"current": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"device",
|
|
"createdAt",
|
|
"lastUsedAt",
|
|
"current"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"BuildPlan": {
|
|
"type": "object",
|
|
"properties": {
|
|
"ok": {
|
|
"type": "boolean"
|
|
},
|
|
"code": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"toLevel": {
|
|
"type": "integer"
|
|
},
|
|
"cost": {
|
|
"$ref": "#/components/schemas/Cost"
|
|
},
|
|
"durationMs": {
|
|
"type": "integer"
|
|
},
|
|
"missing": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"level": {
|
|
"type": "integer"
|
|
},
|
|
"have": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"type",
|
|
"level",
|
|
"have"
|
|
],
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"ok",
|
|
"code",
|
|
"toLevel"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"BuildingView": {
|
|
"type": "object",
|
|
"properties": {
|
|
"key": {
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"level": {
|
|
"type": "integer"
|
|
},
|
|
"maxLevel": {
|
|
"type": "integer"
|
|
},
|
|
"next": {
|
|
"$ref": "#/components/schemas/BuildPlan"
|
|
}
|
|
},
|
|
"required": [
|
|
"key",
|
|
"type",
|
|
"kind",
|
|
"level",
|
|
"maxLevel",
|
|
"next"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"QueueEntry": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"key": {
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"toLevel": {
|
|
"type": "integer"
|
|
},
|
|
"startedAt": {
|
|
"type": "integer"
|
|
},
|
|
"dueAt": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"key",
|
|
"type",
|
|
"toLevel",
|
|
"startedAt",
|
|
"dueAt"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"ResourceView": {
|
|
"type": "object",
|
|
"properties": {
|
|
"amount": {
|
|
"type": "number"
|
|
},
|
|
"rate": {
|
|
"type": "number"
|
|
},
|
|
"cap": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"required": [
|
|
"amount",
|
|
"rate",
|
|
"cap"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Town": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"x": {
|
|
"type": "integer"
|
|
},
|
|
"y": {
|
|
"type": "integer"
|
|
},
|
|
"isCapital": {
|
|
"type": "boolean"
|
|
},
|
|
"ownerId": {
|
|
"type": "integer"
|
|
},
|
|
"worldId": {
|
|
"type": "integer"
|
|
},
|
|
"loyalty": {
|
|
"type": "number"
|
|
},
|
|
"footprint": {
|
|
"type": "number"
|
|
},
|
|
"footprintPerDay": {
|
|
"type": "number"
|
|
},
|
|
"resources": {
|
|
"type": "object",
|
|
"properties": {
|
|
"fiber": {
|
|
"$ref": "#/components/schemas/ResourceView"
|
|
},
|
|
"hardware": {
|
|
"$ref": "#/components/schemas/ResourceView"
|
|
},
|
|
"capital": {
|
|
"$ref": "#/components/schemas/ResourceView"
|
|
}
|
|
},
|
|
"required": [
|
|
"fiber",
|
|
"hardware",
|
|
"capital"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"power": {
|
|
"type": "object",
|
|
"properties": {
|
|
"out": {
|
|
"type": "number"
|
|
},
|
|
"draw": {
|
|
"type": "number"
|
|
},
|
|
"net": {
|
|
"type": "number"
|
|
},
|
|
"buffer": {
|
|
"type": "number"
|
|
},
|
|
"bufferCap": {
|
|
"type": "number"
|
|
},
|
|
"bufferRate": {
|
|
"type": "number"
|
|
},
|
|
"online": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"out",
|
|
"draw",
|
|
"net",
|
|
"buffer",
|
|
"bufferCap",
|
|
"bufferRate",
|
|
"online"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"buildings": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/BuildingView"
|
|
}
|
|
},
|
|
"queue": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/QueueEntry"
|
|
}
|
|
},
|
|
"queueSlots": {
|
|
"type": "integer"
|
|
},
|
|
"bonus": {
|
|
"type": "object",
|
|
"properties": {
|
|
"fiber": {
|
|
"type": "number"
|
|
},
|
|
"hardware": {
|
|
"type": "number"
|
|
},
|
|
"capital": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"required": [
|
|
"fiber",
|
|
"hardware",
|
|
"capital"
|
|
],
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"x",
|
|
"y",
|
|
"isCapital",
|
|
"ownerId",
|
|
"worldId",
|
|
"loyalty",
|
|
"footprint",
|
|
"footprintPerDay",
|
|
"resources",
|
|
"power",
|
|
"buildings",
|
|
"queue",
|
|
"queueSlots",
|
|
"bonus"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"TownResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"town": {
|
|
"$ref": "#/components/schemas/Town"
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"town"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"MapTown": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"x": {
|
|
"type": "integer"
|
|
},
|
|
"y": {
|
|
"type": "integer"
|
|
},
|
|
"isCapital": {
|
|
"type": "boolean"
|
|
},
|
|
"owner": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"asNumber": {
|
|
"type": "integer"
|
|
},
|
|
"allianceId": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
},
|
|
"protected": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"asNumber",
|
|
"allianceId",
|
|
"protected"
|
|
],
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"x",
|
|
"y",
|
|
"isCapital",
|
|
"owner"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"MapSpecial": {
|
|
"type": "object",
|
|
"properties": {
|
|
"x": {
|
|
"type": "integer"
|
|
},
|
|
"y": {
|
|
"type": "integer"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"bonus": {
|
|
"type": "string",
|
|
"nullable": true
|
|
}
|
|
},
|
|
"required": [
|
|
"x",
|
|
"y",
|
|
"type",
|
|
"bonus"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"MapResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"world": {
|
|
"$ref": "#/components/schemas/World"
|
|
},
|
|
"bounds": {
|
|
"type": "object",
|
|
"properties": {
|
|
"x0": {
|
|
"type": "integer"
|
|
},
|
|
"x1": {
|
|
"type": "integer"
|
|
},
|
|
"y0": {
|
|
"type": "integer"
|
|
},
|
|
"y1": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"x0",
|
|
"x1",
|
|
"y0",
|
|
"y1"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"specials": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/MapSpecial"
|
|
}
|
|
},
|
|
"towns": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/MapTown"
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"world",
|
|
"bounds",
|
|
"specials",
|
|
"towns"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"BuildResult": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"eventId": {
|
|
"type": "integer"
|
|
},
|
|
"key": {
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"toLevel": {
|
|
"type": "integer"
|
|
},
|
|
"startedAt": {
|
|
"type": "integer"
|
|
},
|
|
"dueAt": {
|
|
"type": "integer"
|
|
},
|
|
"cost": {
|
|
"$ref": "#/components/schemas/Cost"
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"eventId",
|
|
"key",
|
|
"type",
|
|
"toLevel",
|
|
"startedAt",
|
|
"dueAt",
|
|
"cost"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Notification": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"worldId": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
},
|
|
"payload": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
},
|
|
"createdAt": {
|
|
"type": "integer"
|
|
},
|
|
"readAt": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"type",
|
|
"worldId",
|
|
"payload",
|
|
"createdAt",
|
|
"readAt"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"NotificationList": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
},
|
|
"items": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Notification"
|
|
}
|
|
},
|
|
"next": {
|
|
"type": "integer",
|
|
"nullable": true
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime",
|
|
"items",
|
|
"next"
|
|
],
|
|
"additionalProperties": true
|
|
},
|
|
"Ok": {
|
|
"type": "object",
|
|
"properties": {
|
|
"serverTime": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"serverTime"
|
|
],
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"securitySchemes": {
|
|
"bearer": {
|
|
"type": "http",
|
|
"scheme": "bearer",
|
|
"description": "Opaque device token from /auth/login or /auth/signup"
|
|
}
|
|
}
|
|
},
|
|
"x-error-codes": {
|
|
"bad_request": {
|
|
"status": 400,
|
|
"description": "The request could not be parsed."
|
|
},
|
|
"validation_failed": {
|
|
"status": 422,
|
|
"description": "A field is missing or has the wrong shape."
|
|
},
|
|
"unauthorized": {
|
|
"status": 401,
|
|
"description": "Missing, invalid or revoked token."
|
|
},
|
|
"invalid_credentials": {
|
|
"status": 401,
|
|
"description": "Wrong username or password."
|
|
},
|
|
"forbidden": {
|
|
"status": 403,
|
|
"description": "You may not do that."
|
|
},
|
|
"not_found": {
|
|
"status": 404,
|
|
"description": "No such thing."
|
|
},
|
|
"method_not_allowed": {
|
|
"status": 405,
|
|
"description": "Wrong HTTP method for this path."
|
|
},
|
|
"conflict": {
|
|
"status": 409,
|
|
"description": "The request conflicts with the current state."
|
|
},
|
|
"request_in_progress": {
|
|
"status": 409,
|
|
"description": "A request with this Idempotency-Key is still running."
|
|
},
|
|
"idempotency_key_reuse": {
|
|
"status": 422,
|
|
"description": "This Idempotency-Key was used for a different request."
|
|
},
|
|
"payload_too_large": {
|
|
"status": 413,
|
|
"description": "Request body too large."
|
|
},
|
|
"rate_limited": {
|
|
"status": 429,
|
|
"description": "Too many requests, slow down."
|
|
},
|
|
"internal_error": {
|
|
"status": 500,
|
|
"description": "Something broke on our side."
|
|
},
|
|
"signup_closed": {
|
|
"status": 403,
|
|
"description": "Signup needs a valid invite code."
|
|
},
|
|
"username_taken": {
|
|
"status": 409,
|
|
"description": "That username is taken."
|
|
},
|
|
"world_full": {
|
|
"status": 409,
|
|
"description": "There is no room left on the map."
|
|
},
|
|
"unknown_building": {
|
|
"status": 404,
|
|
"description": "No such building or slot."
|
|
},
|
|
"not_buildable": {
|
|
"status": 409,
|
|
"description": "That building cannot be built here."
|
|
},
|
|
"max_level": {
|
|
"status": 409,
|
|
"description": "Already at the maximum level."
|
|
},
|
|
"requirements_not_met": {
|
|
"status": 409,
|
|
"description": "A required building level is missing."
|
|
},
|
|
"already_queued": {
|
|
"status": 409,
|
|
"description": "That building is already being built."
|
|
},
|
|
"queue_full": {
|
|
"status": 409,
|
|
"description": "All build slots are busy."
|
|
},
|
|
"not_enough_resources": {
|
|
"status": 409,
|
|
"description": "Not enough resources."
|
|
}
|
|
}
|
|
}
|