update annotations

This commit is contained in:
2025-08-01 23:25:46 +03:00
parent 6d49d83ea7
commit 9a274250cd

View File

@@ -1,59 +1,47 @@
---@diagnostic disable: missing-fields, missing-return --@diagnostic disable: missing-fields, missing-return
---@alias AnyTable table<string, any>
---@type AnyTable ---@alias Any any
In = { ---@alias AnyTable table<string, Any>
Params = {},
}
---@type AnyTable --- Global session module interface
Out = { ---@class SessionModule
Result = {}, ---@field request AnyTable Input context (read-only)
} ---@field request.params AnyTable Request parameters
---@field response AnyTable Output context (write results/errors)
---@field response.result Any|string? Result payload (table or primitive)
---@field response.error { code: integer, message: string }? Optional error info
---@class Log --- Global log module interface
---@field Info fun(msg: string) ---@class LogModule
---@field Debug fun(msg: string) ---@field info fun(msg: string) Log informational message
---@field Error fun(msg: string) ---@field debug fun(msg: string) Log debug message
---@field Warn fun(msg: string) ---@field error fun(msg: string) Log error message
---@field Event fun(msg: string) ---@field warn fun(msg: string) Log warning message
---@field EventError fun(msg: string) ---@field event fun(msg: string) Log event (generic)
---@field EventWarn fun(msg: string) ---@field event_error fun(msg: string) Log event error
---@field event_warn fun(msg: string) Log event warning
---@type Log
Log = {}
--- Global net module interface
---@class HttpResponse ---@class HttpResponse
---@field status integer HTTP status code ---@field status integer HTTP status code
---@field status_text string HTTP status text ---@field status_text string HTTP status text
---@field body string Response body ---@field body string Response body
---@field content_length integer Content length ---@field content_length integer Content length
---@field headers table<string, string|string[]> Response headers ---@field headers AnyTable Map of headers
---@class Http ---@class HttpModule
---@field Get fun(log: boolean, url: string): HttpResponse, string? Makes HTTP GET request ---@field get fun(log: boolean, url: string): HttpResponse, string? Perform GET
---@field Post fun(log: boolean, url: string, content_type: string, payload: string): HttpResponse, string? Makes HTTP POST request ---@field post fun(log: boolean, url: string, content_type: string, payload: string): HttpResponse, string? Perform POST
---@class Net ---@class NetModule
---@field Http Http HTTP client methods ---@field http HttpModule HTTP client functions
---@type Net --- Exposed globals
Net = { ---@type SessionModule
Http = { session = session or {}
---Makes HTTP GET request
---@param log boolean Whether to log the request
---@param url string URL to request
---@return HttpResponse response
---@return string? error
Get = function(log, url) end,
---Makes HTTP POST request ---@type LogModule
---@param log boolean Whether to log the request log = log or {}
---@param url string URL to request
---@param content_type string Content-Type header ---@type NetModule
---@param payload string Request body net = net or {}
---@return HttpResponse response
---@return string? error
Post = function(log, url, content_type, payload) end
}
}