diff options
| author | William Boman <william@redwill.se> | 2023-02-19 22:54:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-19 22:54:29 +0100 |
| commit | 3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe (patch) | |
| tree | a37c7fd00b68f4207dfd20046b6bff29f5885b5a /lua/mason-registry/api.lua | |
| parent | chore: autogenerate (#1007) (diff) | |
| download | mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar.gz mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar.bz2 mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar.lz mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar.xz mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.tar.zst mason-3e5c8e1777e3ec4062306fcb1bb131e1bca2adfe.zip | |
feat(providers): add more endpoints (#1013)
Diffstat (limited to 'lua/mason-registry/api.lua')
| -rw-r--r-- | lua/mason-registry/api.lua | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/lua/mason-registry/api.lua b/lua/mason-registry/api.lua index 7d98c7ef..853690b9 100644 --- a/lua/mason-registry/api.lua +++ b/lua/mason-registry/api.lua @@ -26,10 +26,18 @@ function api.get(path, opts) }):map_catching(vim.json.decode) end ----@alias ApiSignature<T> fun(path_params: T, opts?: ApiFetchOpts): Result +---@alias ApiSignature<T> async fun(path_params: T, opts?: ApiFetchOpts): Result + +---@param char string +local function percent_encode(char) + return ("%%%x"):format(string.byte(char, 1, 1)) +end + +api.encode_uri_component = _.gsub("[!#%$&'%(%)%*%+,/:;=%?@%[%]]", percent_encode) ---@param path_template string local function get(path_template) + ---@async ---@param path_params table ---@param opts ApiFetchOpts? return function(path_params, opts) @@ -83,7 +91,32 @@ api.rubygems = { ---@type ApiSignature<{ gem: string }> latest = get "/api/rubygems/{gem}/versions/latest", ---@type ApiSignature<{ gem: string }> - all = get "/api/rubygemspypi/{gem}/versions/all", + all = get "/api/rubygems/{gem}/versions/all", + }, +} + +api.packagist = { + versions = { + ---@type ApiSignature<{ pkg: string }> + latest = get "/api/packagist/{pkg}/versions/latest", + ---@type ApiSignature<{ pkg: string }> + all = get "/api/packagist/{pkg}/versions/all", + }, +} + +api.crate = { + versions = { + ---@type ApiSignature<{ crate: string }> + latest = get "/api/crate/{crate}/versions/latest", + ---@type ApiSignature<{ crate: string }> + all = get "/api/crate/{crate}/versions/all", + }, +} + +api.golang = { + versions = { + ---@type ApiSignature<{ pkg: string }> + all = get "/api/golang/{pkg}/versions/all", }, } |
