From 94e0cbc292ecdd42a19133b721fa83f09d61c00c Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Fri, 1 Sep 2023 19:30:18 +0300 Subject: [PATCH 1/8] Bump API version to 5.12.1 --- README.md | 2 +- browser/Cloudnode.js | 2 +- browser/Cloudnode.min.js | 2 +- gen/config.json | 2 +- src/Cloudnode.js | 2 +- src/Cloudnode.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 20ddf2a..c463b9e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Cloudnode API SDK ![Client Version: 2.1.0](https://img.shields.io/badge/Client%20Version-2.1.0-%2316a34a) -![API Version: 5.12.0](https://img.shields.io/badge/API%20Version-5.12.0-%232563eb) +![API Version: 5.12.1](https://img.shields.io/badge/API%20Version-5.12.1-%232563eb) ![build: passing](https://img.shields.io/badge/build-passing-%2316a34a) ![npm downloads](https://img.shields.io/npm/dt/cloudnode-ts?label=downloads) diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index 342d582..0fbd7a9 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -31,7 +31,7 @@ class Cloudnode { /** * API version */ - #apiVersion = `5.12.0`; + #apiVersion = `5.12.1`; /** * Client user agent */ diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index 45dfd88..5dd4741 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/gen/config.json b/gen/config.json index d7545db..844197e 100644 --- a/gen/config.json +++ b/gen/config.json @@ -2,6 +2,6 @@ "name": "Cloudnode", "instanceName": "cloudnode", "baseUrl": "https://api.cloudnode.pro/v5/", - "apiVersion": "5.12.0", + "apiVersion": "5.12.1", "browserSdkUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js" } diff --git a/src/Cloudnode.js b/src/Cloudnode.js index 774b494..6b4f7df 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -31,7 +31,7 @@ class Cloudnode { /** * API version */ - #apiVersion = `5.12.0`; + #apiVersion = `5.12.1`; /** * Client user agent */ diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index 0411dd9..52755bd 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -37,7 +37,7 @@ class Cloudnode { /** * API version */ - readonly #apiVersion = `5.12.0`; + readonly #apiVersion = `5.12.1`; /** * Client user agent From 48310bd2e55958aff735cb5113e7ddc546725531 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 01:05:40 +0300 Subject: [PATCH 2/8] username max length 20 --- README.md | 6 +++--- browser/Cloudnode.js | 12 ++++++------ browser/Cloudnode.min.js | 2 +- schema.json | 6 +++--- src/Cloudnode.d.ts | 6 +++--- src/Cloudnode.js | 12 ++++++------ src/Cloudnode.ts | 12 ++++++------ 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index b8586ce..2195df8 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ List account permissions with user-friendly descriptions. Some permissions (such Replace account identity. Requires token with scope `account.details.identity.update`. - - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity)>> - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} @@ -329,7 +329,7 @@ Set your primary e-mail address. Requires token with scope `account.details.emai Update account identity. Requires token with scope `account.details.identity.update`. - - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity) | [void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> `void` if nothing was changed. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} @@ -366,7 +366,7 @@ Create an account and session. After signing up, a welcome e-mail is sent to con > **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service. - - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. + - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. - `email` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required. - `password` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<{session: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>> Session token. Also returned in `Set-Cookie` header. diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index 60807c0..bcc08a4 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -410,7 +410,7 @@ class Cloudnode { > **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service. * @POST /auth/register - * @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. + * @param username The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. * @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required. * @param password The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -421,7 +421,7 @@ class Cloudnode { * @returns Session token. Also returned in `Set-Cookie` header. */ register: async (username, email, password) => { - return await this.#sendRequest({ "type": "operation", "description": "Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.", "method": "POST", "path": "/auth/register", "token": null, "parameters": { "body": { "username": { "description": "The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, "email": { "description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.", "type": "string", "required": true }, "password": { "description": "The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, email, password }); + return await this.#sendRequest({ "type": "operation", "description": "Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.", "method": "POST", "path": "/auth/register", "token": null, "parameters": { "body": { "username": { "description": "The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, "email": { "description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.", "type": "string", "required": true }, "password": { "description": "The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, email, password }); }, /** * Create a session using user ID/username/e-mail and password. @@ -470,7 +470,7 @@ class Cloudnode { /** * Update account identity * @PATCH /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -483,12 +483,12 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * Replace account identity * @PUT /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -500,7 +500,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * List account e-mail addresses diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index 5dd4741..b0fd209 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/schema.json b/schema.json index 0f27798..2af3778 100644 --- a/schema.json +++ b/schema.json @@ -923,7 +923,7 @@ "parameters": { "body": { "username": { - "description": "The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", + "description": "The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, @@ -1037,7 +1037,7 @@ "parameters": { "body": { "username": { - "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", + "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, @@ -1081,7 +1081,7 @@ "parameters": { "body": { "username": { - "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", + "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, diff --git a/src/Cloudnode.d.ts b/src/Cloudnode.d.ts index 3579949..785713b 100644 --- a/src/Cloudnode.d.ts +++ b/src/Cloudnode.d.ts @@ -211,7 +211,7 @@ declare class Cloudnode { > **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service. * @POST /auth/register - * @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. + * @param username The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. * @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required. * @param password The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -267,7 +267,7 @@ declare class Cloudnode { /** * Update account identity * @PATCH /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -283,7 +283,7 @@ declare class Cloudnode { /** * Replace account identity * @PUT /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} diff --git a/src/Cloudnode.js b/src/Cloudnode.js index e5b3906..6e5cb68 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -410,7 +410,7 @@ class Cloudnode { > **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service. * @POST /auth/register - * @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. + * @param username The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. * @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required. * @param password The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -421,7 +421,7 @@ class Cloudnode { * @returns Session token. Also returned in `Set-Cookie` header. */ register: async (username, email, password) => { - return await this.#sendRequest({ "type": "operation", "description": "Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.", "method": "POST", "path": "/auth/register", "token": null, "parameters": { "body": { "username": { "description": "The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, "email": { "description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.", "type": "string", "required": true }, "password": { "description": "The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, email, password }); + return await this.#sendRequest({ "type": "operation", "description": "Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.", "method": "POST", "path": "/auth/register", "token": null, "parameters": { "body": { "username": { "description": "The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, "email": { "description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.", "type": "string", "required": true }, "password": { "description": "The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, email, password }); }, /** * Create a session using user ID/username/e-mail and password. @@ -470,7 +470,7 @@ class Cloudnode { /** * Update account identity * @PATCH /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -483,12 +483,12 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * Replace account identity * @PUT /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -500,7 +500,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * List account e-mail addresses diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index af6bbc9..654bd27 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -424,7 +424,7 @@ class Cloudnode { > **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service. * @POST /auth/register - * @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. + * @param username The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique. * @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required. * @param password The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -435,7 +435,7 @@ class Cloudnode { * @returns Session token. Also returned in `Set-Cookie` header. */ register: async (username: string, email: string, password: string): Promise> => { - return await this.#sendRequest<{session: string}>({"type":"operation","description":"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.","method":"POST","path":"/auth/register","token":null,"parameters":{"body":{"username":{"description":"The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.","type":"string","required":true},"email":{"description":"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.","type":"string","required":true},"password":{"description":"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.","type":"string","required":true}}},"returns":[{"status":201,"type":"{session: string}","description":"Session token. Also returned in `Set-Cookie` header."},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":403,"type":"Error & {code: \"IP_REJECTED\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, email, password}); + return await this.#sendRequest<{session: string}>({"type":"operation","description":"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.","method":"POST","path":"/auth/register","token":null,"parameters":{"body":{"username":{"description":"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.","type":"string","required":true},"email":{"description":"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.","type":"string","required":true},"password":{"description":"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.","type":"string","required":true}}},"returns":[{"status":201,"type":"{session: string}","description":"Session token. Also returned in `Set-Cookie` header."},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":403,"type":"Error & {code: \"IP_REJECTED\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, email, password}); }, /** * Create a session using user ID/username/e-mail and password. @@ -484,7 +484,7 @@ class Cloudnode { /** * Update account identity * @PATCH /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -497,12 +497,12 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username: string, name?: string | null): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Update account identity","token":"account.details.identity.update","method":"PATCH","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":false}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":204,"type":"void","description":"`void` if nothing was changed."},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); + return await this.#sendRequest({"type":"operation","description":"Update account identity","token":"account.details.identity.update","method":"PATCH","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":false}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":204,"type":"void","description":"`void` if nothing was changed."},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); }, /** * Replace account identity * @PUT /account/identity - * @param username Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. + * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. * @param name Your full name. Set to `null` to remove. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} @@ -514,7 +514,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username: string, name: string | null): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Replace account identity","token":"account.details.identity.update","method":"PUT","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 64 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":true}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); + return await this.#sendRequest({"type":"operation","description":"Replace account identity","token":"account.details.identity.update","method":"PUT","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":true}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); }, /** * List account e-mail addresses From 4dc14e0162c5db670a47b4efa0fa53155f1a27d0 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 01:07:19 +0300 Subject: [PATCH 3/8] new name min length and allowed characters --- README.md | 4 ++-- browser/Cloudnode.js | 8 ++++---- browser/Cloudnode.min.js | 2 +- schema.json | 4 ++-- src/Cloudnode.d.ts | 4 ++-- src/Cloudnode.js | 8 ++++---- src/Cloudnode.ts | 8 ++++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 2195df8..50707c7 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,7 @@ List account permissions with user-friendly descriptions. Some permissions (such Replace account identity. Requires token with scope `account.details.identity.update`. - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. + - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity)>> - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"} @@ -330,7 +330,7 @@ Set your primary e-mail address. Requires token with scope `account.details.emai Update account identity. Requires token with scope `account.details.identity.update`. - `username` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. + - `name` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null) Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity) | [void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> `void` if nothing was changed. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"} diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index bcc08a4..d192366 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -471,7 +471,7 @@ class Cloudnode { * Update account identity * @PATCH /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -483,13 +483,13 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * Replace account identity * @PUT /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -500,7 +500,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * List account e-mail addresses diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index b0fd209..6076aa3 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove.",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/schema.json b/schema.json index 2af3778..8d95e27 100644 --- a/schema.json +++ b/schema.json @@ -1042,7 +1042,7 @@ "required": true }, "name": { - "description": "Your full name. Set to `null` to remove.", + "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": false } @@ -1086,7 +1086,7 @@ "required": true }, "name": { - "description": "Your full name. Set to `null` to remove.", + "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": true } diff --git a/src/Cloudnode.d.ts b/src/Cloudnode.d.ts index 785713b..bbcecad 100644 --- a/src/Cloudnode.d.ts +++ b/src/Cloudnode.d.ts @@ -268,7 +268,7 @@ declare class Cloudnode { * Update account identity * @PATCH /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -284,7 +284,7 @@ declare class Cloudnode { * Replace account identity * @PUT /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} diff --git a/src/Cloudnode.js b/src/Cloudnode.js index 6e5cb68..a33ded4 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -471,7 +471,7 @@ class Cloudnode { * Update account identity * @PATCH /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -483,13 +483,13 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Update account identity", "token": "account.details.identity.update", "method": "PATCH", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": false } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 204, "type": "void", "description": "`void` if nothing was changed." }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * Replace account identity * @PUT /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -500,7 +500,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username, name) => { - return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove.", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); + return await this.#sendRequest({ "type": "operation", "description": "Replace account identity", "token": "account.details.identity.update", "method": "PUT", "path": "/account/identity", "parameters": { "body": { "username": { "description": "Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.", "type": "string", "required": true }, "name": { "description": "Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`", "type": "string | null", "required": true } } }, "returns": [{ "status": 200, "type": "AccountIdentity" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, name }); }, /** * List account e-mail addresses diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index 654bd27..b5e89a8 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -485,7 +485,7 @@ class Cloudnode { * Update account identity * @PATCH /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -497,13 +497,13 @@ class Cloudnode { * @returns `void` if nothing was changed. */ updateIdentity: async (username: string, name?: string | null): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Update account identity","token":"account.details.identity.update","method":"PATCH","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":false}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":204,"type":"void","description":"`void` if nothing was changed."},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); + return await this.#sendRequest({"type":"operation","description":"Update account identity","token":"account.details.identity.update","method":"PATCH","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`","type":"string | null","required":false}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":204,"type":"void","description":"`void` if nothing was changed."},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); }, /** * Replace account identity * @PUT /account/identity * @param username Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`. - * @param name Your full name. Set to `null` to remove. + * @param name Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ` * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -514,7 +514,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ replaceIdentity: async (username: string, name: string | null): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Replace account identity","token":"account.details.identity.update","method":"PUT","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove.","type":"string | null","required":true}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); + return await this.#sendRequest({"type":"operation","description":"Replace account identity","token":"account.details.identity.update","method":"PUT","path":"/account/identity","parameters":{"body":{"username":{"description":"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.","type":"string","required":true},"name":{"description":"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`","type":"string | null","required":true}}},"returns":[{"status":200,"type":"AccountIdentity"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {username, name}); }, /** * List account e-mail addresses From 993281b48a146ba6f457e0cddeaae719955921b7 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 01:49:59 +0300 Subject: [PATCH 4/8] new newsletters & subscriptions API --- README.md | 124 ++++++++++++++++++++++----------------- browser/Cloudnode.js | 70 +++++++++++++--------- browser/Cloudnode.min.js | 2 +- schema.json | 121 ++++++++++++++++++++++---------------- src/Cloudnode.d.ts | 58 ++++++++++-------- src/Cloudnode.js | 70 +++++++++++++--------- src/Cloudnode.ts | 70 +++++++++++++--------- 7 files changed, 299 insertions(+), 216 deletions(-) diff --git a/README.md b/README.md index 50707c7..14484a0 100644 --- a/README.md +++ b/README.md @@ -89,16 +89,17 @@ console.log(newsletter._response.status); // 200 - [`cloudnode.account.updateIdentity(username, [name])`](#cloudnodeaccountupdateidentityusername-name) - [`cloudnode.auth.login(user, password)`](#cloudnodeauthloginuser-password) - [`cloudnode.auth.register(username, email, password)`](#cloudnodeauthregisterusername-email-password) - - [`cloudnode.newsletter.get(id)`](#cloudnodenewslettergetid) - - [`cloudnode.newsletter.list([limit], [page])`](#cloudnodenewsletterlistlimit-page) - - [`cloudnode.newsletter.subscribe(id, email, [data])`](#cloudnodenewslettersubscribeid-email-data) - - [`cloudnode.newsletters.listSubscriptions([limit], [page])`](#cloudnodenewsletterslistsubscriptionslimit-page) - - [`cloudnode.newsletters.unsubscribe(subscription)`](#cloudnodenewslettersunsubscribesubscription) + - [`cloudnode.newsletters.get(id)`](#cloudnodenewslettersgetid) + - [`cloudnode.newsletters.list([limit], [page])`](#cloudnodenewsletterslistlimit-page) - [`cloudnode.projects.create(name)`](#cloudnodeprojectscreatename) - [`cloudnode.projects.delete(id)`](#cloudnodeprojectsdeleteid) - [`cloudnode.projects.get(id)`](#cloudnodeprojectsgetid) - [`cloudnode.projects.list([limit], [page])`](#cloudnodeprojectslistlimit-page) - [`cloudnode.projects.update(id, name)`](#cloudnodeprojectsupdateid-name) + - [`cloudnode.subscriptions.create(newsletter, email, [data])`](#cloudnodesubscriptionscreatenewsletter-email-data) + - [`cloudnode.subscriptions.delete(id)`](#cloudnodesubscriptionsdeleteid) + - [`cloudnode.subscriptions.get(id)`](#cloudnodesubscriptionsgetid) + - [`cloudnode.subscriptions.list([limit], [page])`](#cloudnodesubscriptionslistlimit-page) - [`cloudnode.token.create(permissions, lifetime, [note])`](#cloudnodetokencreatepermissions-lifetime-note) - [`cloudnode.token.get(id)`](#cloudnodetokengetid) - [`cloudnode.token.getRequest(id, request)`](#cloudnodetokengetrequestid-request) @@ -376,9 +377,9 @@ Create an account and session. After signing up, a welcome e-mail is sent to con - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.newsletter.get(id)` +### `cloudnode.newsletters.get(id)` Get newsletter @@ -389,9 +390,9 @@ Get newsletter - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.newsletter.list([limit], [page])` +### `cloudnode.newsletters.list([limit], [page])` List newsletters @@ -402,52 +403,6 @@ List newsletters - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - - -### `cloudnode.newsletter.subscribe(id, email, [data])` - -Subscribe to newsletter - - - `id` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) A newsletter ID. - - `email` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Subscriber's email address. - - `data` [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Additional data that this newsletter requires. - - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.NewsletterSubscription](#interface-cloudnodenewslettersubscription)>> - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - - - -### `cloudnode.newsletters.listSubscriptions([limit], [page])` - -List subscriptions of the authenticated user. Requires token with scope `newsletter.subscriptions.list.own`. - - - `limit` [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) The number of subscriptions to return per page. No more than 50. Default: `10` - - `page` [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) The page number. No more than 2³² (4294967296). Default: `1` - - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.DatedNewsletterSubscription[]](#interface-cloudnodedatednewslettersubscription)>>> - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - - - -### `cloudnode.newsletters.unsubscribe(subscription)` - -Revoke a subscription (unsubscribe) - - - `subscription` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The ID of the subscription to revoke. - - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - ### `cloudnode.projects.create(name)` @@ -525,6 +480,65 @@ Update a project. Requires token with scope `projects.update.own`. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} + + +### `cloudnode.subscriptions.create(newsletter, email, [data])` + +Subscribe to newsletter + + - `newsletter` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The ID of the newsletter to subscribe to. + - `email` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Subscriber's email address. + - `data` [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Additional data that this newsletter requires. + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.NewsletterSubscription](#interface-cloudnodenewslettersubscription)>> + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} + + + +### `cloudnode.subscriptions.delete(id)` + +Unsubscribe from newsletter + + - `id` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The ID of the subscription to revoke. + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} + + + +### `cloudnode.subscriptions.get(id)` + +Get newsletter subscription + + - `id` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) The ID of the subscription to get. + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.DatedNewsletterSubscription](#interface-cloudnodedatednewslettersubscription)>> + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} + + + +### `cloudnode.subscriptions.list([limit], [page])` + +List newsletter subscriptions. Requires token with scope `newsletter.subscriptions.list.own`. + + - `limit` [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) The number of subscriptions to return per page. No more than 50. Default: `10` + - `page` [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) The page number. No more than 2³² (4294967296). Default: `1` + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.DatedNewsletterSubscription[]](#interface-cloudnodedatednewslettersubscription)>>> + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} + ### `cloudnode.token.create(permissions, lifetime, [note])` diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index d192366..3fa764f 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -221,10 +221,10 @@ class Cloudnode { page: 1 }; } - newsletter = { + newsletters = { /** * List newsletters - * @GET /newsletter + * @GET /newsletters * @param limit The number of newsletters to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -232,11 +232,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "List newsletters", "method": "GET", "path": "/newsletter", "parameters": { "query": { "limit": { "description": "The number of newsletters to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "Newsletter[]" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "List newsletters", "method": "GET", "path": "/newsletters", "parameters": { "query": { "limit": { "description": "The number of newsletters to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "Newsletter[]" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); }, /** * Get newsletter - * @GET /newsletter/:id + * @GET /newsletters/:id * @param id A newsletter ID * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -244,52 +244,64 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Get newsletter", "method": "GET", "path": "/newsletter/:id", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Newsletter" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get newsletter", "method": "GET", "path": "/newsletters/:id", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Newsletter" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, + }; + subscriptions = { /** - * Subscribe to newsletter - * @POST /newsletter/:id/subscribe - * @param id A newsletter ID - * @param email Subscriber's email address - * @param data Additional data that this newsletter requires + * List newsletter subscriptions + * @GET /subscriptions + * @param limit The number of subscriptions to return per page. No more than 50. + * @param page The page number. No more than 2³² (4294967296). + * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} + * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} + * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} + * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} + */ + list: async (limit = 10, page = 1) => { + return await this.#sendRequest({ "type": "operation", "description": "List newsletter subscriptions", "token": "newsletter.subscriptions.list.own", "method": "GET", "path": "/subscriptions", "parameters": { "query": { "limit": { "description": "The number of subscriptions to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + }, + /** + * Get newsletter subscription + * @GET /subscriptions/:id + * @param id The ID of the subscription to get * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} - * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} - * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - subscribe: async (id, email, data) => { - return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/newsletter/:id/subscribe", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } }, "body": { "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, { email, data }); + get: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Get newsletter subscription", "method": "GET", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to get", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, - }; - newsletters = { /** - * Revoke a subscription (unsubscribe) - * @POST /newsletters/unsubscribe - * @param subscription The ID of the subscription to revoke + * Subscribe to newsletter + * @POST /subscriptions + * @param newsletter The ID of the newsletter to subscribe to + * @param email Subscriber's email address + * @param data Additional data that this newsletter requires * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - unsubscribe: async (subscription) => { - return await this.#sendRequest({ "type": "operation", "description": "Revoke a subscription (unsubscribe)", "method": "POST", "path": "/newsletters/unsubscribe", "parameters": { "body": { "subscription": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { subscription }); + create: async (newsletter, email, data) => { + return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); }, /** - * List subscriptions of the authenticated user - * @GET /newsletters/subscriptions - * @param limit The number of subscriptions to return per page. No more than 50. - * @param page The page number. No more than 2³² (4294967296). - * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} - * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * Unsubscribe from newsletter + * @DELETE /subscriptions/:id + * @param id The ID of the subscription to revoke + * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} + * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - listSubscriptions: async (limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "List subscriptions of the authenticated user", "token": "newsletter.subscriptions.list.own", "method": "GET", "path": "/newsletters/subscriptions", "parameters": { "query": { "limit": { "description": "The number of subscriptions to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + delete: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Unsubscribe from newsletter", "method": "DELETE", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; token = { diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index 6076aa3..bcca5a9 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletter={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletter",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletter/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),subscribe:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/newsletter/:id/subscribe",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}},body:{email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{email:t,data:r})};newsletters={unsubscribe:async e=>await this.#n({type:"operation",description:"Revoke a subscription (unsubscribe)",method:"POST",path:"/newsletters/unsubscribe",parameters:{body:{subscription:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{subscription:e}),listSubscriptions:async(e=10,t=1)=>await this.#n({type:"operation",description:"List subscriptions of the authenticated user",token:"newsletter.subscriptions.list.own",method:"GET",path:"/newsletters/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/schema.json b/schema.json index 8d95e27..3408087 100644 --- a/schema.json +++ b/schema.json @@ -504,14 +504,14 @@ } ], "operations": { - "newsletter": { + "newsletters": { "type": "namespace", "operations": { "list": { "type": "operation", "description": "List newsletters", "method": "GET", - "path": "/newsletter", + "path": "/newsletters", "parameters": { "query": { "limit": { @@ -539,7 +539,7 @@ "type": "operation", "description": "Get newsletter", "method": "GET", - "path": "/newsletter/:id", + "path": "/newsletters/:id", "parameters": { "path": { "id": { @@ -559,21 +559,78 @@ "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" } ] + } + } + }, + "subscriptions": { + "type": "namespace", + "operations": { + "list": { + "type": "operation", + "description": "List newsletter subscriptions", + "token": "newsletter.subscriptions.list.own", + "method": "GET", + "path": "/subscriptions", + "parameters": { + "query": { + "limit": { + "description": "The number of subscriptions to return per page. No more than 50.", + "default": "10", + "type": "number", + "required": false + }, + "page": { + "description": "The page number. No more than 2³² (4294967296).", + "default": "1", + "type": "number", + "required": false + } + } + }, + "returns": [ + { + "status": 200, + "type": "DatedNewsletterSubscription[]" + } + ] }, - "subscribe": { + "get": { "type": "operation", - "description": "Subscribe to newsletter", - "method": "POST", - "path": "/newsletter/:id/subscribe", + "description": "Get newsletter subscription", + "method": "GET", + "path": "/subscriptions/:id", "parameters": { "path": { "id": { - "description": "A newsletter ID", + "description": "The ID of the subscription to get", "type": "string", "required": true } + } + }, + "returns": [ + { + "status": 200, + "type": "DatedNewsletterSubscription" }, + { + "status": 404, + "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" + } + ] + }, + "create": { + "type": "operation", + "description": "Subscribe to newsletter", + "method": "POST", + "path": "/subscriptions", + "parameters": { "body": { + "newsletter": { + "description": "The ID of the newsletter to subscribe to", + "type": "string", + "required": true + }, "email": { "description": "Subscriber's email address", "type": "string", @@ -604,20 +661,15 @@ "type": "Error & {code: \"CONFLICT\"}" } ] - } - } - }, - "newsletters": { - "type": "namespace", - "operations": { - "unsubscribe": { + }, + "delete": { "type": "operation", - "description": "Revoke a subscription (unsubscribe)", - "method": "POST", - "path": "/newsletters/unsubscribe", + "description": "Unsubscribe from newsletter", + "method": "DELETE", + "path": "/subscriptions/:id", "parameters": { - "body": { - "subscription": { + "path": { + "id": { "description": "The ID of the subscription to revoke", "type": "string", "required": true @@ -638,35 +690,6 @@ "type": "Error & {code: \"INVALID_DATA\"}" } ] - }, - "listSubscriptions": { - "type": "operation", - "description": "List subscriptions of the authenticated user", - "token": "newsletter.subscriptions.list.own", - "method": "GET", - "path": "/newsletters/subscriptions", - "parameters": { - "query": { - "limit": { - "description": "The number of subscriptions to return per page. No more than 50.", - "default": "10", - "type": "number", - "required": false - }, - "page": { - "description": "The page number. No more than 2³² (4294967296).", - "default": "1", - "type": "number", - "required": false - } - } - }, - "returns": [ - { - "status": 200, - "type": "DatedNewsletterSubscription[]" - } - ] } } }, diff --git a/src/Cloudnode.d.ts b/src/Cloudnode.d.ts index bbcecad..4826488 100644 --- a/src/Cloudnode.d.ts +++ b/src/Cloudnode.d.ts @@ -46,10 +46,10 @@ declare class Cloudnode { * @throws {Cloudnode.Error} Error returned by the API */ getAllPages(response: Cloudnode.ApiResponse>): Promise>; - newsletter: { + newsletters: { /** * List newsletters - * @GET /newsletter + * @GET /newsletters * @param limit The number of newsletters to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -59,7 +59,7 @@ declare class Cloudnode { readonly list: (limit?: number, page?: number) => Promise>>; /** * Get newsletter - * @GET /newsletter/:id + * @GET /newsletters/:id * @param id A newsletter ID * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -67,45 +67,55 @@ declare class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ readonly get: (id: string) => Promise>; + }; + subscriptions: { /** - * Subscribe to newsletter - * @POST /newsletter/:id/subscribe - * @param id A newsletter ID - * @param email Subscriber's email address - * @param data Additional data that this newsletter requires + * List newsletter subscriptions + * @GET /subscriptions + * @param limit The number of subscriptions to return per page. No more than 50. + * @param page The page number. No more than 2³² (4294967296). + * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} + * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} + * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} + * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} + */ + readonly list: (limit?: number, page?: number) => Promise>>; + /** + * Get newsletter subscription + * @GET /subscriptions/:id + * @param id The ID of the subscription to get * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} - * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} - * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - readonly subscribe: (id: string, email: string, data?: Record) => Promise>; - }; - newsletters: { + readonly get: (id: string) => Promise>; /** - * Revoke a subscription (unsubscribe) - * @POST /newsletters/unsubscribe - * @param subscription The ID of the subscription to revoke + * Subscribe to newsletter + * @POST /subscriptions + * @param newsletter The ID of the newsletter to subscribe to + * @param email Subscriber's email address + * @param data Additional data that this newsletter requires * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - readonly unsubscribe: (subscription: string) => Promise>; + readonly create: (newsletter: string, email: string, data?: Record) => Promise>; /** - * List subscriptions of the authenticated user - * @GET /newsletters/subscriptions - * @param limit The number of subscriptions to return per page. No more than 50. - * @param page The page number. No more than 2³² (4294967296). - * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} - * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * Unsubscribe from newsletter + * @DELETE /subscriptions/:id + * @param id The ID of the subscription to revoke + * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} + * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - readonly listSubscriptions: (limit?: number, page?: number) => Promise>>; + readonly delete: (id: string) => Promise>; }; token: { /** diff --git a/src/Cloudnode.js b/src/Cloudnode.js index a33ded4..b9cab5d 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -221,10 +221,10 @@ class Cloudnode { page: 1 }; } - newsletter = { + newsletters = { /** * List newsletters - * @GET /newsletter + * @GET /newsletters * @param limit The number of newsletters to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -232,11 +232,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "List newsletters", "method": "GET", "path": "/newsletter", "parameters": { "query": { "limit": { "description": "The number of newsletters to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "Newsletter[]" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "List newsletters", "method": "GET", "path": "/newsletters", "parameters": { "query": { "limit": { "description": "The number of newsletters to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "Newsletter[]" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); }, /** * Get newsletter - * @GET /newsletter/:id + * @GET /newsletters/:id * @param id A newsletter ID * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -244,52 +244,64 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Get newsletter", "method": "GET", "path": "/newsletter/:id", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Newsletter" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get newsletter", "method": "GET", "path": "/newsletters/:id", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Newsletter" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, + }; + subscriptions = { /** - * Subscribe to newsletter - * @POST /newsletter/:id/subscribe - * @param id A newsletter ID - * @param email Subscriber's email address - * @param data Additional data that this newsletter requires + * List newsletter subscriptions + * @GET /subscriptions + * @param limit The number of subscriptions to return per page. No more than 50. + * @param page The page number. No more than 2³² (4294967296). + * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} + * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} + * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} + * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} + */ + list: async (limit = 10, page = 1) => { + return await this.#sendRequest({ "type": "operation", "description": "List newsletter subscriptions", "token": "newsletter.subscriptions.list.own", "method": "GET", "path": "/subscriptions", "parameters": { "query": { "limit": { "description": "The number of subscriptions to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + }, + /** + * Get newsletter subscription + * @GET /subscriptions/:id + * @param id The ID of the subscription to get * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} - * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} - * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - subscribe: async (id, email, data) => { - return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/newsletter/:id/subscribe", "parameters": { "path": { "id": { "description": "A newsletter ID", "type": "string", "required": true } }, "body": { "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, { email, data }); + get: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Get newsletter subscription", "method": "GET", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to get", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, - }; - newsletters = { /** - * Revoke a subscription (unsubscribe) - * @POST /newsletters/unsubscribe - * @param subscription The ID of the subscription to revoke + * Subscribe to newsletter + * @POST /subscriptions + * @param newsletter The ID of the newsletter to subscribe to + * @param email Subscriber's email address + * @param data Additional data that this newsletter requires * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - unsubscribe: async (subscription) => { - return await this.#sendRequest({ "type": "operation", "description": "Revoke a subscription (unsubscribe)", "method": "POST", "path": "/newsletters/unsubscribe", "parameters": { "body": { "subscription": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { subscription }); + create: async (newsletter, email, data) => { + return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); }, /** - * List subscriptions of the authenticated user - * @GET /newsletters/subscriptions - * @param limit The number of subscriptions to return per page. No more than 50. - * @param page The page number. No more than 2³² (4294967296). - * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} - * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * Unsubscribe from newsletter + * @DELETE /subscriptions/:id + * @param id The ID of the subscription to revoke + * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} + * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - listSubscriptions: async (limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "List subscriptions of the authenticated user", "token": "newsletter.subscriptions.list.own", "method": "GET", "path": "/newsletters/subscriptions", "parameters": { "query": { "limit": { "description": "The number of subscriptions to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "DatedNewsletterSubscription[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}` }, {}); + delete: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Unsubscribe from newsletter", "method": "DELETE", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; token = { diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index b5e89a8..5c78686 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -235,10 +235,10 @@ class Cloudnode { }; } - public newsletter = { + public newsletters = { /** * List newsletters - * @GET /newsletter + * @GET /newsletters * @param limit The number of newsletters to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -246,11 +246,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit: number = 10, page: number = 1): Promise>> => { - return await this.#sendRequest>({"type":"operation","description":"List newsletters","method":"GET","path":"/newsletter","parameters":{"query":{"limit":{"description":"The number of newsletters to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"Newsletter[]"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`}, {}); + return await this.#sendRequest>({"type":"operation","description":"List newsletters","method":"GET","path":"/newsletters","parameters":{"query":{"limit":{"description":"The number of newsletters to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"Newsletter[]"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`}, {}); }, /** * Get newsletter - * @GET /newsletter/:id + * @GET /newsletters/:id * @param id A newsletter ID * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -258,52 +258,64 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id: string): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Get newsletter","method":"GET","path":"/newsletter/:id","parameters":{"path":{"id":{"description":"A newsletter ID","type":"string","required":true}}},"returns":[{"status":200,"type":"Newsletter"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); + return await this.#sendRequest({"type":"operation","description":"Get newsletter","method":"GET","path":"/newsletters/:id","parameters":{"path":{"id":{"description":"A newsletter ID","type":"string","required":true}}},"returns":[{"status":200,"type":"Newsletter"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, + } as const; + public subscriptions = { /** - * Subscribe to newsletter - * @POST /newsletter/:id/subscribe - * @param id A newsletter ID - * @param email Subscriber's email address - * @param data Additional data that this newsletter requires + * List newsletter subscriptions + * @GET /subscriptions + * @param limit The number of subscriptions to return per page. No more than 50. + * @param page The page number. No more than 2³² (4294967296). + * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} + * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} + * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} + * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} + */ + list: async (limit: number = 10, page: number = 1): Promise>> => { + return await this.#sendRequest>({"type":"operation","description":"List newsletter subscriptions","token":"newsletter.subscriptions.list.own","method":"GET","path":"/subscriptions","parameters":{"query":{"limit":{"description":"The number of subscriptions to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"DatedNewsletterSubscription[]"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`}, {}); + }, + /** + * Get newsletter subscription + * @GET /subscriptions/:id + * @param id The ID of the subscription to get * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} - * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} - * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - subscribe: async (id: string, email: string, data?: Record): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Subscribe to newsletter","method":"POST","path":"/newsletter/:id/subscribe","parameters":{"path":{"id":{"description":"A newsletter ID","type":"string","required":true}},"body":{"email":{"description":"Subscriber's email address","type":"string","required":true},"data":{"description":"Additional data that this newsletter requires","type":"Record","required":false}}},"returns":[{"status":201,"type":"NewsletterSubscription"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {email, data}); + get: async (id: string): Promise> => { + return await this.#sendRequest({"type":"operation","description":"Get newsletter subscription","method":"GET","path":"/subscriptions/:id","parameters":{"path":{"id":{"description":"The ID of the subscription to get","type":"string","required":true}}},"returns":[{"status":200,"type":"DatedNewsletterSubscription"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, - } as const; - public newsletters = { /** - * Revoke a subscription (unsubscribe) - * @POST /newsletters/unsubscribe - * @param subscription The ID of the subscription to revoke + * Subscribe to newsletter + * @POST /subscriptions + * @param newsletter The ID of the newsletter to subscribe to + * @param email Subscriber's email address + * @param data Additional data that this newsletter requires * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - unsubscribe: async (subscription: string): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Revoke a subscription (unsubscribe)","method":"POST","path":"/newsletters/unsubscribe","parameters":{"body":{"subscription":{"description":"The ID of the subscription to revoke","type":"string","required":true}}},"returns":[{"status":204,"type":"void"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {subscription}); + create: async (newsletter: string, email: string, data?: Record): Promise> => { + return await this.#sendRequest({"type":"operation","description":"Subscribe to newsletter","method":"POST","path":"/subscriptions","parameters":{"body":{"newsletter":{"description":"The ID of the newsletter to subscribe to","type":"string","required":true},"email":{"description":"Subscriber's email address","type":"string","required":true},"data":{"description":"Additional data that this newsletter requires","type":"Record","required":false}}},"returns":[{"status":201,"type":"NewsletterSubscription"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {newsletter, email, data}); }, /** - * List subscriptions of the authenticated user - * @GET /newsletters/subscriptions - * @param limit The number of subscriptions to return per page. No more than 50. - * @param page The page number. No more than 2³² (4294967296). - * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} - * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} + * Unsubscribe from newsletter + * @DELETE /subscriptions/:id + * @param id The ID of the subscription to revoke + * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} + * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - listSubscriptions: async (limit: number = 10, page: number = 1): Promise>> => { - return await this.#sendRequest>({"type":"operation","description":"List subscriptions of the authenticated user","token":"newsletter.subscriptions.list.own","method":"GET","path":"/newsletters/subscriptions","parameters":{"query":{"limit":{"description":"The number of subscriptions to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"DatedNewsletterSubscription[]"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`}, {}); + delete: async (id: string): Promise> => { + return await this.#sendRequest({"type":"operation","description":"Unsubscribe from newsletter","method":"DELETE","path":"/subscriptions/:id","parameters":{"path":{"id":{"description":"The ID of the subscription to revoke","type":"string","required":true}}},"returns":[{"status":204,"type":"void"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, } as const; public token = { From 5a35dccc80e368b4b9fbf3530bbb95b72d2a6389 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 02:01:30 +0300 Subject: [PATCH 5/8] Bump API to 5.13.0 --- README.md | 2 +- browser/Cloudnode.js | 2 +- browser/Cloudnode.min.js | 2 +- gen/config.json | 2 +- src/Cloudnode.js | 2 +- src/Cloudnode.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 14484a0..404effe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Cloudnode API Client ![Client Version: 2.1.0](https://img.shields.io/badge/Client%20Version-2.1.0-%2316a34a) -![API Version: 5.12.1](https://img.shields.io/badge/API%20Version-5.12.1-%232563eb) +![API Version: 5.13.0](https://img.shields.io/badge/API%20Version-5.13.0-%232563eb) ![build: passing](https://img.shields.io/badge/build-passing-%2316a34a) ![npm downloads](https://img.shields.io/npm/dt/cloudnode-ts?label=downloads) diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index 3fa764f..ccede09 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -31,7 +31,7 @@ class Cloudnode { /** * API version */ - #apiVersion = `5.12.1`; + #apiVersion = `5.13.0`; /** * Client user agent */ diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index bcca5a9..082d044 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.12.1";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.13.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/gen/config.json b/gen/config.json index 844197e..45d59de 100644 --- a/gen/config.json +++ b/gen/config.json @@ -2,6 +2,6 @@ "name": "Cloudnode", "instanceName": "cloudnode", "baseUrl": "https://api.cloudnode.pro/v5/", - "apiVersion": "5.12.1", + "apiVersion": "5.13.0", "browserSdkUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js" } diff --git a/src/Cloudnode.js b/src/Cloudnode.js index b9cab5d..0f13bd9 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -31,7 +31,7 @@ class Cloudnode { /** * API version */ - #apiVersion = `5.12.1`; + #apiVersion = `5.13.0`; /** * Client user agent */ diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index 5c78686..84542de 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -37,7 +37,7 @@ class Cloudnode { /** * API version */ - readonly #apiVersion = `5.12.1`; + readonly #apiVersion = `5.13.0`; /** * Client user agent From 89bb378261c26497a6b240f59f5a0052ff510dbf Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 02:03:36 +0300 Subject: [PATCH 6/8] subscriptions.create no longer can return 404 --- README.md | 1 - browser/Cloudnode.js | 3 +-- browser/Cloudnode.min.js | 2 +- schema.json | 4 ---- src/Cloudnode.d.ts | 1 - src/Cloudnode.js | 3 +-- src/Cloudnode.ts | 3 +-- 7 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 404effe..12bd028 100644 --- a/README.md +++ b/README.md @@ -490,7 +490,6 @@ Subscribe to newsletter - `email` [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Subscriber's email address. - `data` [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Additional data that this newsletter requires. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.NewsletterSubscription](#interface-cloudnodenewslettersubscription)>> - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index ccede09..9cf5582 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -280,7 +280,6 @@ class Cloudnode { * @param newsletter The ID of the newsletter to subscribe to * @param email Subscriber's email address * @param data Additional data that this newsletter requires - * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -288,7 +287,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (newsletter, email, data) => { - return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); + return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); }, /** * Unsubscribe from newsletter diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index 082d044..3d59a67 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.13.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.13.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/schema.json b/schema.json index 3408087..a908a02 100644 --- a/schema.json +++ b/schema.json @@ -648,10 +648,6 @@ "status": 201, "type": "NewsletterSubscription" }, - { - "status": 404, - "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" - }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" diff --git a/src/Cloudnode.d.ts b/src/Cloudnode.d.ts index 4826488..71ad1af 100644 --- a/src/Cloudnode.d.ts +++ b/src/Cloudnode.d.ts @@ -97,7 +97,6 @@ declare class Cloudnode { * @param newsletter The ID of the newsletter to subscribe to * @param email Subscriber's email address * @param data Additional data that this newsletter requires - * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} diff --git a/src/Cloudnode.js b/src/Cloudnode.js index 0f13bd9..51ddd6f 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -280,7 +280,6 @@ class Cloudnode { * @param newsletter The ID of the newsletter to subscribe to * @param email Subscriber's email address * @param data Additional data that this newsletter requires - * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -288,7 +287,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (newsletter, email, data) => { - return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); + return await this.#sendRequest({ "type": "operation", "description": "Subscribe to newsletter", "method": "POST", "path": "/subscriptions", "parameters": { "body": { "newsletter": { "description": "The ID of the newsletter to subscribe to", "type": "string", "required": true }, "email": { "description": "Subscriber's email address", "type": "string", "required": true }, "data": { "description": "Additional data that this newsletter requires", "type": "Record", "required": false } } }, "returns": [{ "status": 201, "type": "NewsletterSubscription" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 409, "type": "Error & {code: \"CONFLICT\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { newsletter, email, data }); }, /** * Unsubscribe from newsletter diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index 84542de..74f3ac1 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -294,7 +294,6 @@ class Cloudnode { * @param newsletter The ID of the newsletter to subscribe to * @param email Subscriber's email address * @param data Additional data that this newsletter requires - * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "CONFLICT"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -302,7 +301,7 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (newsletter: string, email: string, data?: Record): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Subscribe to newsletter","method":"POST","path":"/subscriptions","parameters":{"body":{"newsletter":{"description":"The ID of the newsletter to subscribe to","type":"string","required":true},"email":{"description":"Subscriber's email address","type":"string","required":true},"data":{"description":"Additional data that this newsletter requires","type":"Record","required":false}}},"returns":[{"status":201,"type":"NewsletterSubscription"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {newsletter, email, data}); + return await this.#sendRequest({"type":"operation","description":"Subscribe to newsletter","method":"POST","path":"/subscriptions","parameters":{"body":{"newsletter":{"description":"The ID of the newsletter to subscribe to","type":"string","required":true},"email":{"description":"Subscriber's email address","type":"string","required":true},"data":{"description":"Additional data that this newsletter requires","type":"Record","required":false}}},"returns":[{"status":201,"type":"NewsletterSubscription"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":409,"type":"Error & {code: \"CONFLICT\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {newsletter, email, data}); }, /** * Unsubscribe from newsletter From 94e43c2a6aec3e7d66bbd669937de6ec5ced2d58 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 02:13:15 +0300 Subject: [PATCH 7/8] new tokens API uri --- README.md | 59 ++++++++++++++++++++-------------------- browser/Cloudnode.js | 36 ++++++++++++------------ browser/Cloudnode.min.js | 2 +- schema.json | 41 ++++++++++++++++------------ src/Cloudnode.d.ts | 22 +++++++-------- src/Cloudnode.js | 36 ++++++++++++------------ src/Cloudnode.ts | 36 ++++++++++++------------ 7 files changed, 120 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index 12bd028..6443c7a 100644 --- a/README.md +++ b/README.md @@ -100,13 +100,13 @@ console.log(newsletter._response.status); // 200 - [`cloudnode.subscriptions.delete(id)`](#cloudnodesubscriptionsdeleteid) - [`cloudnode.subscriptions.get(id)`](#cloudnodesubscriptionsgetid) - [`cloudnode.subscriptions.list([limit], [page])`](#cloudnodesubscriptionslistlimit-page) - - [`cloudnode.token.create(permissions, lifetime, [note])`](#cloudnodetokencreatepermissions-lifetime-note) - - [`cloudnode.token.get(id)`](#cloudnodetokengetid) - - [`cloudnode.token.getRequest(id, request)`](#cloudnodetokengetrequestid-request) - - [`cloudnode.token.list([limit], [page], [internal])`](#cloudnodetokenlistlimit-page-internal) - - [`cloudnode.token.listRequests(id, [limit], [page])`](#cloudnodetokenlistrequestsid-limit-page) - - [`cloudnode.token.revoke(id)`](#cloudnodetokenrevokeid) - - [`cloudnode.tokens.refresh()`](#cloudnodetokensrefresh) + - [`cloudnode.tokens.create(permissions, lifetime, [note])`](#cloudnodetokenscreatepermissions-lifetime-note) + - [`cloudnode.tokens.get(id)`](#cloudnodetokensgetid) + - [`cloudnode.tokens.getRequest(id, request)`](#cloudnodetokensgetrequestid-request) + - [`cloudnode.tokens.list([limit], [page], [internal])`](#cloudnodetokenslistlimit-page-internal) + - [`cloudnode.tokens.listRequests(id, [limit], [page])`](#cloudnodetokenslistrequestsid-limit-page) + - [`cloudnode.tokens.refresh(id)`](#cloudnodetokensrefreshid) + - [`cloudnode.tokens.revoke(id)`](#cloudnodetokensrevokeid) - [Namespace: `Cloudnode`](#namespace-cloudnode) - [Class: `Cloudnode.ApiResponse`](#class-cloudnodeapiresponset) @@ -538,9 +538,9 @@ List newsletter subscriptions. Requires token with scope `newsletter.subscriptio - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.create(permissions, lifetime, [note])` +### `cloudnode.tokens.create(permissions, lifetime, [note])` Create token. Requires token with scope `tokens.create.own`. @@ -555,9 +555,9 @@ Create token. Requires token with scope `tokens.create.own`. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.get(id)` +### `cloudnode.tokens.get(id)` Get token details. Requires token with scope `tokens.get.own`. @@ -571,9 +571,9 @@ Get token details. Requires token with scope `tokens.get.own`. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.getRequest(id, request)` +### `cloudnode.tokens.getRequest(id, request)` Get a recent request by ID. Requires token with scope `tokens.get.own.requests`. @@ -582,15 +582,16 @@ Get a recent request by ID. Requires token with scope `tokens.get.own.requests`. - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Request](#interface-cloudnoderequest)>> - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MODIFICATION_NOT_ALLOWED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.list([limit], [page], [internal])` +### `cloudnode.tokens.list([limit], [page], [internal])` List tokens of user. Requires token with scope `tokens.list.own`. @@ -604,9 +605,9 @@ List tokens of user. Requires token with scope `tokens.list.own`. - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.listRequests(id, [limit], [page])` +### `cloudnode.tokens.listRequests(id, [limit], [page])` Get list of recent requests made with the token. Requires token with scope `tokens.get.own.requests`. @@ -622,32 +623,32 @@ Get list of recent requests made with the token. Requires token with scope `toke - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.token.revoke(id)` +### `cloudnode.tokens.refresh(id)` -Revoke token. Requires token with scope `tokens.revoke.own`. +Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. Requires token with scope `token.refresh`. - - `id` string | "current" The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. - - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} + - `id` string | "current" The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request. + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Token](#interface-cloudnodetoken)>> - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} - - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MODIFICATION_NOT_ALLOWED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"} - + -### `cloudnode.tokens.refresh()` - -Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. Requires token with scope `token.refresh`. +### `cloudnode.tokens.revoke(id)` +Revoke token. Requires token with scope `tokens.revoke.own`. - - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Token](#interface-cloudnodetoken)>> + - `id` string | "current" The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. + - Returns: [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>> + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"} + - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "MODIFICATION_NOT_ALLOWED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"} - Throws: [Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"} diff --git a/browser/Cloudnode.js b/browser/Cloudnode.js index 9cf5582..b34450a 100644 --- a/browser/Cloudnode.js +++ b/browser/Cloudnode.js @@ -303,10 +303,10 @@ class Cloudnode { return await this.#sendRequest({ "type": "operation", "description": "Unsubscribe from newsletter", "method": "DELETE", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; - token = { + tokens = { /** * List tokens of user - * @GET /token + * @GET /tokens * @param limit The number of tokens to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @param internal Internal tokens are returned as well if this parameter is present. @@ -317,11 +317,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit = 10, page = 1, internal) => { - return await this.#sendRequest({ "type": "operation", "description": "List tokens of user", "token": "tokens.list.own", "method": "GET", "path": "/token", "parameters": { "query": { "limit": { "description": "The number of tokens to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false }, "internal": { "description": "Internal tokens are returned as well if this parameter is present.", "type": "any", "required": false } } }, "returns": [{ "status": 200, "type": "PartialToken[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}`, internal: `${internal}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "List tokens of user", "token": "tokens.list.own", "method": "GET", "path": "/tokens", "parameters": { "query": { "limit": { "description": "The number of tokens to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false }, "internal": { "description": "Internal tokens are returned as well if this parameter is present.", "type": "any", "required": false } } }, "returns": [{ "status": 200, "type": "PartialToken[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}`, internal: `${internal}` }, {}); }, /** * Create token - * @POST /token + * @POST /tokens * @param permissions List of permissions to grant to the token. You must already have each of these permissions with your current token. * @param lifetime Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute). * @param note A user-specified note to label the token. Max length: 2⁸ (256) characters. @@ -333,11 +333,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (permissions, lifetime, note) => { - return await this.#sendRequest({ "type": "operation", "description": "Create token", "token": "tokens.create.own", "method": "POST", "path": "/token", "parameters": { "body": { "permissions": { "description": "List of permissions to grant to the token. You must already have each of these permissions with your current token.", "type": "string[]", "required": true }, "lifetime": { "description": "Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).", "type": "number", "required": true }, "note": { "description": "A user-specified note to label the token. Max length: 2⁸ (256) characters.", "type": "string", "required": false } } }, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { permissions, lifetime, note }); + return await this.#sendRequest({ "type": "operation", "description": "Create token", "token": "tokens.create.own", "method": "POST", "path": "/tokens", "parameters": { "body": { "permissions": { "description": "List of permissions to grant to the token. You must already have each of these permissions with your current token.", "type": "string[]", "required": true }, "lifetime": { "description": "Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).", "type": "number", "required": true }, "note": { "description": "A user-specified note to label the token. Max length: 2⁸ (256) characters.", "type": "string", "required": false } } }, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { permissions, lifetime, note }); }, /** * Get token details - * @GET /token/:id + * @GET /tokens/:id * @param id The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -348,11 +348,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Get token details", "token": "tokens.get.own", "method": "GET", "path": "/token/:id", "parameters": { "path": { "id": { "description": "The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get token details", "token": "tokens.get.own", "method": "GET", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, /** * Revoke token - * @DELETE /token/:id + * @DELETE /tokens/:id * @param id The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -364,11 +364,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ revoke: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Revoke token", "token": "tokens.revoke.own", "method": "DELETE", "path": "/token/:id", "parameters": { "path": { "id": { "description": "The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 400, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Revoke token", "token": "tokens.revoke.own", "method": "DELETE", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 423, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, /** * Get list of recent requests made with the token - * @GET /token/:id/requests + * @GET /tokens/:id/requests * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param limit The number of requests to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). @@ -381,15 +381,16 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ listRequests: async (id, limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "Get list of recent requests made with the token", "token": "tokens.get.own.requests", "method": "GET", "path": "/token/:id/requests", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } }, "query": { "limit": { "description": "The number of requests to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "ShortRequest[]" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, { limit: `${limit}`, page: `${page}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get list of recent requests made with the token", "token": "tokens.get.own.requests", "method": "GET", "path": "/tokens/:id/requests", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } }, "query": { "limit": { "description": "The number of requests to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "ShortRequest[]" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, { limit: `${limit}`, page: `${page}` }, {}); }, /** * Get a recent request by ID - * @GET /token/:id/requests/:request + * @GET /tokens/:id/requests/:request * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param request The ID of the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -397,13 +398,12 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ getRequest: async (id, request) => { - return await this.#sendRequest({ "type": "operation", "description": "Get a recent request by ID", "token": "tokens.get.own.requests", "method": "GET", "path": "/token/:id/requests/:request", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true }, "request": { "description": "The ID of the request.", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Request" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}`, request: `${request}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get a recent request by ID", "token": "tokens.get.own.requests", "method": "GET", "path": "/tokens/:id/requests/:request", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true }, "request": { "description": "The ID of the request.", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Request" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 423, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}`, request: `${request}` }, {}, {}); }, - }; - tokens = { /** * Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. - * @POST /token/refresh + * @POST /tokens/:id + * @param id The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} @@ -411,8 +411,8 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - refresh: async () => { - return await this.#sendRequest({ "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", "path": "/token/refresh", "parameters": {}, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, {}); + refresh: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; auth = { diff --git a/browser/Cloudnode.min.js b/browser/Cloudnode.min.js index 3d59a67..b852b69 100644 --- a/browser/Cloudnode.min.js +++ b/browser/Cloudnode.min.js @@ -1 +1 @@ -class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.13.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};token={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/token",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/token",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/token/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:400,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/token/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{})};tokens={refresh:async()=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/token/refresh",parameters:{},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file +class Cloudnode{#e;#t;static#r={baseUrl:"https://api.cloudnode.pro/v5/",autoRetry:!0,maxRetryDelay:5,maxRetries:3};#s="5.13.0";#o="cloudnode/2.1.0";constructor(e,t=Cloudnode.#r){const r=Cloudnode.#r;r.baseUrl=t.baseUrl??Cloudnode.#r.baseUrl,r.autoRetry=t.autoRetry??Cloudnode.#r.autoRetry,r.maxRetryDelay=t.maxRetryDelay??Cloudnode.#r.maxRetryDelay,r.maxRetries=t.maxRetries??Cloudnode.#r.maxRetries,this.#e=e,this.#t=r}async#a(e,t,r,s){const o=new URL(e.path.replace(/^\/+/,""),this.#t.baseUrl);for(const[e,r]of Object.entries(t))o.pathname=o.pathname.replaceAll(`/:${e}`,`/${r}`);for(const[e,t]of Object.entries(r))o.searchParams.append(e,t);const a={method:e.method,headers:{}};s&&!["GET","HEAD"].includes(e.method)&&("string"!=typeof s?(a.body=JSON.stringify(s),a.headers["Content-Type"]="application/json"):(a.body=s,a.headers["Content-Type"]="text/plain")),a.headers["User-Agent"]=this.#o,this.#e&&void 0!==e.token&&(a.headers.Authorization=`Bearer ${this.#e}`),void 0!==e.token&&(a.credentials="include");const n=await fetch(o.toString(),a);if(204===n.status)return;const i=await n.text();let p;p=n.headers.get("Content-Type")?.startsWith("application/json")?JSON.parse(i,((e,t)=>/^\d{4}-\d{2}-\d{2}T(?:\d{2}:){2}\d{2}(?:\.\d+)?(?:[a-zA-Z]+|\+\d{2}:\d{2})?$/.test(t)?new Date(t):t)):i;const d=Cloudnode.makeApiResponse(p,new Cloudnode.RawResponse(n,{operation:e,pathParams:t,queryParams:r,body:s}));if(n.ok)return d;throw d}#n(e,t,r,s,o){return new Promise((async(a,n)=>{const i=(p=0)=>{this.#a(e,t,r,s).then((e=>a(e))).catch((e=>{if(o??=this.#t,o.baseUrl??=this.#t.baseUrl,o.autoRetry??=this.#t.autoRetry,o.maxRetries??=this.#t.maxRetries,o.maxRetryDelay??=this.#t.maxRetryDelay,o.autoRetry&&po.maxRetryDelay)return n(e);setTimeout(i,1e3*Number(r),++p)}else n(e)}))};i(0)}))}#i(e,t){const r=e.split("."),s=t.split("."),o=[r[0]||"0",r[1]||"0"],a=[s[0]||"0",s[1]||"0"];return o[0]!==a[0]?"incompatible":o[1]!==a[1]?"outdated":"compatible"}async checkCompatibility(){const e=await(await fetch(new URL("../",this.#t.baseUrl).toString(),{method:"GET",headers:{"User-Agent":this.#o}})).json();return this.#i(e.version,this.#s)}async getPage(e,t){if(t*e.limit>e.total||t<1)return null;const r=Object.assign({},e._response.request.queryParams);return r.page=t.toString(),await this.#n(e._response.request.operation,e._response.request.pathParams,r,e._response.request.body)}async getNextPage(e){return await this.getPage(e,e.page+1)}async getPreviousPage(e){return await this.getPage(e,e.page-1)}async getAllPages(e){const t=new Array(Math.ceil(e.total/e.limit)).fill(null);t[e.page-1]=!0;const r=t.map(((t,r)=>null!==t||this.getPage(e,r+1))),s=await Promise.all(r.filter((e=>!0!==e)));s.splice(e.page-1,0,e);return{items:s.filter((e=>null!==e)).map((e=>e.items)).flat(),total:e.total,limit:e.limit,page:1}}newsletters={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletters",method:"GET",path:"/newsletters",parameters:{query:{limit:{description:"The number of newsletters to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Newsletter[]"},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter",method:"GET",path:"/newsletters/:id",parameters:{path:{id:{description:"A newsletter ID",type:"string",required:!0}}},returns:[{status:200,type:"Newsletter"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};subscriptions={list:async(e=10,t=1)=>await this.#n({type:"operation",description:"List newsletter subscriptions",token:"newsletter.subscriptions.list.own",method:"GET",path:"/subscriptions",parameters:{query:{limit:{description:"The number of subscriptions to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"DatedNewsletterSubscription[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),get:async e=>await this.#n({type:"operation",description:"Get newsletter subscription",method:"GET",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to get",type:"string",required:!0}}},returns:[{status:200,type:"DatedNewsletterSubscription"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Subscribe to newsletter",method:"POST",path:"/subscriptions",parameters:{body:{newsletter:{description:"The ID of the newsletter to subscribe to",type:"string",required:!0},email:{description:"Subscriber's email address",type:"string",required:!0},data:{description:"Additional data that this newsletter requires",type:"Record",required:!1}}},returns:[{status:201,type:"NewsletterSubscription"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{newsletter:e,email:t,data:r}),delete:async e=>await this.#n({type:"operation",description:"Unsubscribe from newsletter",method:"DELETE",path:"/subscriptions/:id",parameters:{path:{id:{description:"The ID of the subscription to revoke",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};tokens={list:async(e=10,t=1,r)=>await this.#n({type:"operation",description:"List tokens of user",token:"tokens.list.own",method:"GET",path:"/tokens",parameters:{query:{limit:{description:"The number of tokens to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1},internal:{description:"Internal tokens are returned as well if this parameter is present.",type:"any",required:!1}}},returns:[{status:200,type:"PartialToken[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`,internal:`${r}`},{}),create:async(e,t,r)=>await this.#n({type:"operation",description:"Create token",token:"tokens.create.own",method:"POST",path:"/tokens",parameters:{body:{permissions:{description:"List of permissions to grant to the token. You must already have each of these permissions with your current token.",type:"string[]",required:!0},lifetime:{description:"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).",type:"number",required:!0},note:{description:"A user-specified note to label the token. Max length: 2⁸ (256) characters.",type:"string",required:!1}}},returns:[{status:201,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{permissions:e,lifetime:t,note:r}),get:async e=>await this.#n({type:"operation",description:"Get token details",token:"tokens.get.own",method:"GET",path:"/tokens/:id",parameters:{path:{id:{description:"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),revoke:async e=>await this.#n({type:"operation",description:"Revoke token",token:"tokens.revoke.own",method:"DELETE",path:"/tokens/:id",parameters:{path:{id:{description:"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:423,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),listRequests:async(e,t=10,r=1)=>await this.#n({type:"operation",description:"Get list of recent requests made with the token",token:"tokens.get.own.requests",method:"GET",path:"/tokens/:id/requests",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0}},query:{limit:{description:"The number of requests to return per page. No more than 50.",default:"10",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"ShortRequest[]"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{limit:`${t}`,page:`${r}`},{}),getRequest:async(e,t)=>await this.#n({type:"operation",description:"Get a recent request by ID",token:"tokens.get.own.requests",method:"GET",path:"/tokens/:id/requests/:request",parameters:{path:{id:{description:"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.",type:'string | "current"',required:!0},request:{description:"The ID of the request.",type:"string",required:!0}}},returns:[{status:200,type:"Request"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:423,type:'Error & {code: "MODIFICATION_NOT_ALLOWED"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`,request:`${t}`},{},{}),refresh:async e=>await this.#n({type:"operation",description:"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.",token:"token.refresh",method:"POST",path:"/tokens/:id",parameters:{path:{id:{description:"The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.",type:'string | "current"',required:!0}}},returns:[{status:200,type:"Token"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})};auth={register:async(e,t,r)=>await this.#n({type:"operation",description:"Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.",method:"POST",path:"/auth/register",token:null,parameters:{body:{username:{description:"The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.",type:"string",required:!0},email:{description:"The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",type:"string",required:!0},password:{description:"The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,email:t,password:r}),login:async(e,t)=>await this.#n({type:"operation",description:"Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.",method:"POST",path:"/auth/login",token:null,parameters:{body:{user:{description:"User ID (starts with `user_`), username or e-mail address.",type:"string",required:!0},password:{description:"The password of the account.",type:"string",required:!0}}},returns:[{status:201,type:"{session: string}",description:"Session token. Also returned in `Set-Cookie` header."},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:403,type:'Error & {code: "IP_REJECTED"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{user:e,password:t})};account={get:async()=>await this.#n({type:"operation",description:"Get account details",token:"account.details",method:"GET",path:"/account",parameters:{},returns:[{status:200,type:"AccountDetails"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getIdentity:async()=>await this.#n({type:"operation",description:"Get account identity",token:"account.details.identity",method:"GET",path:"/account/identity",parameters:{},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),updateIdentity:async(e,t)=>await this.#n({type:"operation",description:"Update account identity",token:"account.details.identity.update",method:"PATCH",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!1}}},returns:[{status:200,type:"AccountIdentity"},{status:204,type:"void",description:"`void` if nothing was changed."},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),replaceIdentity:async(e,t)=>await this.#n({type:"operation",description:"Replace account identity",token:"account.details.identity.update",method:"PUT",path:"/account/identity",parameters:{body:{username:{description:"Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.",type:"string",required:!0},name:{description:"Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`",type:"string | null",required:!0}}},returns:[{status:200,type:"AccountIdentity"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{username:e,name:t}),listEmails:async()=>await this.#n({type:"operation",description:"List account e-mail addresses",token:"account.details.email.list",method:"GET",path:"/account/email",parameters:{},returns:[{status:200,type:"AccountEmail[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),getEmail:async()=>await this.#n({type:"operation",description:"Get your primary e-mail address",token:"account.details.email",method:"GET",path:"/account/email/primary",parameters:{},returns:[{status:200,type:"DatedPrimaryEmail"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{}),setEmail:async e=>await this.#n({type:"operation",description:"Set your primary e-mail address",token:"account.details.email.update",method:"PUT",path:"/account/email/primary",parameters:{body:{email:{description:"E-mail address to set as primary.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:409,type:'Error & {code: "CONFLICT"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{email:e}),changePassword:async(e,t)=>await this.#n({type:"operation",description:"Change account password",token:"account.details.password.update",method:"PUT",path:"/account/password",parameters:{body:{currentPassword:{description:"Your current password.",type:"string",required:!0},newPassword:{description:"The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{currentPassword:e,newPassword:t}),listPermissions:async()=>await this.#n({type:"operation",description:"List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description.",token:"account.details",method:"GET",path:"/account/permissions",parameters:{},returns:[{status:200,type:"Permission[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{})};projects={list:async(e=20,t=1)=>await this.#n({type:"operation",description:"List projects",token:"projects.get.own",method:"GET",path:"/projects",parameters:{query:{limit:{description:"The number of projects to return per page. No more than 100.",default:"20",type:"number",required:!1},page:{description:"The page number. No more than 2³² (4294967296).",default:"1",type:"number",required:!1}}},returns:[{status:200,type:"Project[]"},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{limit:`${e}`,page:`${t}`},{}),create:async e=>await this.#n({type:"operation",description:"Create a project",token:"projects.create.own",method:"POST",path:"/projects",parameters:{body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:201,type:"Project"},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{},{},{name:e}),get:async e=>await this.#n({type:"operation",description:"Get a project",token:"projects.get.own",method:"GET",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{}),update:async(e,t)=>await this.#n({type:"operation",description:"Update a project",token:"projects.update.own",method:"PATCH",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}},body:{name:{description:"Project name. Max 255 characters.",type:"string",required:!0}}},returns:[{status:200,type:"Project"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:422,type:'Error & {code: "INVALID_DATA"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{name:t}),delete:async e=>await this.#n({type:"operation",description:"Delete a project",token:"projects.delete.own",method:"DELETE",path:"/projects/:id",parameters:{path:{id:{description:"Project ID",type:"string",required:!0}}},returns:[{status:204,type:"void"},{status:404,type:'Error & {code: "RESOURCE_NOT_FOUND"}'},{status:401,type:'Error & {code: "UNAUTHORIZED"}'},{status:403,type:'Error & {code: "NO_PERMISSION"}'},{status:429,type:'Error & {code: "RATE_LIMITED"}'},{status:500,type:'Error & {code: "INTERNAL_SERVER_ERROR"}'},{status:503,type:'Error & {code: "MAINTENANCE"}'}]},{id:`${e}`},{},{})}}!function(e){let t;e.RawResponse=class{headers;ok;redirected;status;statusText;url;request;constructor(e,t){this.headers=Object.fromEntries([...e.headers.entries()].map((([e,t])=>[e.toLowerCase(),t]))),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=new URL(e.url),this.request=t}},function(e){e.ApiResponse=class{#p;constructor(e){this.#p=e}get _response(){return this.#p}}}(t=e.R||(e.R={})),e.makeApiResponse=function(e,r){return Object.assign(new t.ApiResponse(r),e)}}(Cloudnode||(Cloudnode={})); \ No newline at end of file diff --git a/schema.json b/schema.json index a908a02..aea53f8 100644 --- a/schema.json +++ b/schema.json @@ -689,7 +689,7 @@ } } }, - "token": { + "tokens": { "type": "namespace", "operations": { "list": { @@ -697,7 +697,7 @@ "description": "List tokens of user", "token": "tokens.list.own", "method": "GET", - "path": "/token", + "path": "/tokens", "parameters": { "query": { "limit": { @@ -731,7 +731,7 @@ "description": "Create token", "token": "tokens.create.own", "method": "POST", - "path": "/token", + "path": "/tokens", "parameters": { "body": { "permissions": { @@ -767,7 +767,7 @@ "description": "Get token details", "token": "tokens.get.own", "method": "GET", - "path": "/token/:id", + "path": "/tokens/:id", "parameters": { "path": { "id": { @@ -797,7 +797,7 @@ "description": "Revoke token", "token": "tokens.revoke.own", "method": "DELETE", - "path": "/token/:id", + "path": "/tokens/:id", "parameters": { "path": { "id": { @@ -821,7 +821,7 @@ "type": "Error & {code: \"INVALID_DATA\"}" }, { - "status": 400, + "status": 423, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" } ] @@ -831,7 +831,7 @@ "description": "Get list of recent requests made with the token", "token": "tokens.get.own.requests", "method": "GET", - "path": "/token/:id/requests", + "path": "/tokens/:id/requests", "parameters": { "path": { "id": { @@ -875,7 +875,7 @@ "description": "Get a recent request by ID", "token": "tokens.get.own.requests", "method": "GET", - "path": "/token/:id/requests/:request", + "path": "/tokens/:id/requests/:request", "parameters": { "path": { "id": { @@ -902,24 +902,31 @@ { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" + }, + { + "status": 423, + "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" } ] - } - } - }, - "tokens": { - "type": "namespace", - "operations": { + }, "refresh": { "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", - "path": "/token/refresh", - "parameters": {}, + "path": "/tokens/:id", + "parameters": { + "path": { + "id": { + "description": "The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.", + "type": "string | \"current\"", + "required": true + } + } + }, "returns": [ { - "status": 201, + "status": 200, "type": "Token" }, { diff --git a/src/Cloudnode.d.ts b/src/Cloudnode.d.ts index 71ad1af..8601deb 100644 --- a/src/Cloudnode.d.ts +++ b/src/Cloudnode.d.ts @@ -116,10 +116,10 @@ declare class Cloudnode { */ readonly delete: (id: string) => Promise>; }; - token: { + tokens: { /** * List tokens of user - * @GET /token + * @GET /tokens * @param limit The number of tokens to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @param internal Internal tokens are returned as well if this parameter is present. @@ -132,7 +132,7 @@ declare class Cloudnode { readonly list: (limit?: number, page?: number, internal?: any) => Promise>>; /** * Create token - * @POST /token + * @POST /tokens * @param permissions List of permissions to grant to the token. You must already have each of these permissions with your current token. * @param lifetime Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute). * @param note A user-specified note to label the token. Max length: 2⁸ (256) characters. @@ -146,7 +146,7 @@ declare class Cloudnode { readonly create: (permissions: string[], lifetime: number, note?: string) => Promise>; /** * Get token details - * @GET /token/:id + * @GET /tokens/:id * @param id The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -159,7 +159,7 @@ declare class Cloudnode { readonly get: (id: string | "current") => Promise>; /** * Revoke token - * @DELETE /token/:id + * @DELETE /tokens/:id * @param id The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -173,7 +173,7 @@ declare class Cloudnode { readonly revoke: (id: string | "current") => Promise>; /** * Get list of recent requests made with the token - * @GET /token/:id/requests + * @GET /tokens/:id/requests * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param limit The number of requests to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). @@ -188,11 +188,12 @@ declare class Cloudnode { readonly listRequests: (id: string | "current", limit?: number, page?: number) => Promise>>; /** * Get a recent request by ID - * @GET /token/:id/requests/:request + * @GET /tokens/:id/requests/:request * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param request The ID of the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -200,11 +201,10 @@ declare class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ readonly getRequest: (id: string | "current", request: string) => Promise>; - }; - tokens: { /** * Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. - * @POST /token/refresh + * @POST /tokens/:id + * @param id The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} @@ -212,7 +212,7 @@ declare class Cloudnode { * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - readonly refresh: () => Promise>; + readonly refresh: (id: string | "current") => Promise>; }; auth: { /** diff --git a/src/Cloudnode.js b/src/Cloudnode.js index 51ddd6f..c34e494 100644 --- a/src/Cloudnode.js +++ b/src/Cloudnode.js @@ -303,10 +303,10 @@ class Cloudnode { return await this.#sendRequest({ "type": "operation", "description": "Unsubscribe from newsletter", "method": "DELETE", "path": "/subscriptions/:id", "parameters": { "path": { "id": { "description": "The ID of the subscription to revoke", "type": "string", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; - token = { + tokens = { /** * List tokens of user - * @GET /token + * @GET /tokens * @param limit The number of tokens to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @param internal Internal tokens are returned as well if this parameter is present. @@ -317,11 +317,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit = 10, page = 1, internal) => { - return await this.#sendRequest({ "type": "operation", "description": "List tokens of user", "token": "tokens.list.own", "method": "GET", "path": "/token", "parameters": { "query": { "limit": { "description": "The number of tokens to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false }, "internal": { "description": "Internal tokens are returned as well if this parameter is present.", "type": "any", "required": false } } }, "returns": [{ "status": 200, "type": "PartialToken[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}`, internal: `${internal}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "List tokens of user", "token": "tokens.list.own", "method": "GET", "path": "/tokens", "parameters": { "query": { "limit": { "description": "The number of tokens to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false }, "internal": { "description": "Internal tokens are returned as well if this parameter is present.", "type": "any", "required": false } } }, "returns": [{ "status": 200, "type": "PartialToken[]" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, { limit: `${limit}`, page: `${page}`, internal: `${internal}` }, {}); }, /** * Create token - * @POST /token + * @POST /tokens * @param permissions List of permissions to grant to the token. You must already have each of these permissions with your current token. * @param lifetime Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute). * @param note A user-specified note to label the token. Max length: 2⁸ (256) characters. @@ -333,11 +333,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (permissions, lifetime, note) => { - return await this.#sendRequest({ "type": "operation", "description": "Create token", "token": "tokens.create.own", "method": "POST", "path": "/token", "parameters": { "body": { "permissions": { "description": "List of permissions to grant to the token. You must already have each of these permissions with your current token.", "type": "string[]", "required": true }, "lifetime": { "description": "Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).", "type": "number", "required": true }, "note": { "description": "A user-specified note to label the token. Max length: 2⁸ (256) characters.", "type": "string", "required": false } } }, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { permissions, lifetime, note }); + return await this.#sendRequest({ "type": "operation", "description": "Create token", "token": "tokens.create.own", "method": "POST", "path": "/tokens", "parameters": { "body": { "permissions": { "description": "List of permissions to grant to the token. You must already have each of these permissions with your current token.", "type": "string[]", "required": true }, "lifetime": { "description": "Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).", "type": "number", "required": true }, "note": { "description": "A user-specified note to label the token. Max length: 2⁸ (256) characters.", "type": "string", "required": false } } }, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { permissions, lifetime, note }); }, /** * Get token details - * @GET /token/:id + * @GET /tokens/:id * @param id The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -348,11 +348,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Get token details", "token": "tokens.get.own", "method": "GET", "path": "/token/:id", "parameters": { "path": { "id": { "description": "The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get token details", "token": "tokens.get.own", "method": "GET", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, /** * Revoke token - * @DELETE /token/:id + * @DELETE /tokens/:id * @param id The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -364,11 +364,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ revoke: async (id) => { - return await this.#sendRequest({ "type": "operation", "description": "Revoke token", "token": "tokens.revoke.own", "method": "DELETE", "path": "/token/:id", "parameters": { "path": { "id": { "description": "The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 400, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Revoke token", "token": "tokens.revoke.own", "method": "DELETE", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 204, "type": "void" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 423, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, /** * Get list of recent requests made with the token - * @GET /token/:id/requests + * @GET /tokens/:id/requests * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param limit The number of requests to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). @@ -381,15 +381,16 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ listRequests: async (id, limit = 10, page = 1) => { - return await this.#sendRequest({ "type": "operation", "description": "Get list of recent requests made with the token", "token": "tokens.get.own.requests", "method": "GET", "path": "/token/:id/requests", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } }, "query": { "limit": { "description": "The number of requests to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "ShortRequest[]" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, { limit: `${limit}`, page: `${page}` }, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get list of recent requests made with the token", "token": "tokens.get.own.requests", "method": "GET", "path": "/tokens/:id/requests", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } }, "query": { "limit": { "description": "The number of requests to return per page. No more than 50.", "default": "10", "type": "number", "required": false }, "page": { "description": "The page number. No more than 2³² (4294967296).", "default": "1", "type": "number", "required": false } } }, "returns": [{ "status": 200, "type": "ShortRequest[]" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, { limit: `${limit}`, page: `${page}` }, {}); }, /** * Get a recent request by ID - * @GET /token/:id/requests/:request + * @GET /tokens/:id/requests/:request * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param request The ID of the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -397,13 +398,12 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ getRequest: async (id, request) => { - return await this.#sendRequest({ "type": "operation", "description": "Get a recent request by ID", "token": "tokens.get.own.requests", "method": "GET", "path": "/token/:id/requests/:request", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true }, "request": { "description": "The ID of the request.", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Request" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}`, request: `${request}` }, {}, {}); + return await this.#sendRequest({ "type": "operation", "description": "Get a recent request by ID", "token": "tokens.get.own.requests", "method": "GET", "path": "/tokens/:id/requests/:request", "parameters": { "path": { "id": { "description": "The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true }, "request": { "description": "The ID of the request.", "type": "string", "required": true } } }, "returns": [{ "status": 200, "type": "Request" }, { "status": 404, "type": "Error & {code: \"RESOURCE_NOT_FOUND\"}" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 423, "type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}`, request: `${request}` }, {}, {}); }, - }; - tokens = { /** * Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. - * @POST /token/refresh + * @POST /tokens/:id + * @param id The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} @@ -411,8 +411,8 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - refresh: async () => { - return await this.#sendRequest({ "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", "path": "/token/refresh", "parameters": {}, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, {}); + refresh: async (id) => { + return await this.#sendRequest({ "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", "path": "/tokens/:id", "parameters": { "path": { "id": { "description": "The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.", "type": "string | \"current\"", "required": true } } }, "returns": [{ "status": 200, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, { id: `${id}` }, {}, {}); }, }; auth = { diff --git a/src/Cloudnode.ts b/src/Cloudnode.ts index 74f3ac1..09a6ad9 100644 --- a/src/Cloudnode.ts +++ b/src/Cloudnode.ts @@ -317,10 +317,10 @@ class Cloudnode { return await this.#sendRequest({"type":"operation","description":"Unsubscribe from newsletter","method":"DELETE","path":"/subscriptions/:id","parameters":{"path":{"id":{"description":"The ID of the subscription to revoke","type":"string","required":true}}},"returns":[{"status":204,"type":"void"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, } as const; - public token = { + public tokens = { /** * List tokens of user - * @GET /token + * @GET /tokens * @param limit The number of tokens to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). * @param internal Internal tokens are returned as well if this parameter is present. @@ -331,11 +331,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ list: async (limit: number = 10, page: number = 1, internal?: any): Promise>> => { - return await this.#sendRequest>({"type":"operation","description":"List tokens of user","token":"tokens.list.own","method":"GET","path":"/token","parameters":{"query":{"limit":{"description":"The number of tokens to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false},"internal":{"description":"Internal tokens are returned as well if this parameter is present.","type":"any","required":false}}},"returns":[{"status":200,"type":"PartialToken[]"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`, internal: `${internal}`}, {}); + return await this.#sendRequest>({"type":"operation","description":"List tokens of user","token":"tokens.list.own","method":"GET","path":"/tokens","parameters":{"query":{"limit":{"description":"The number of tokens to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false},"internal":{"description":"Internal tokens are returned as well if this parameter is present.","type":"any","required":false}}},"returns":[{"status":200,"type":"PartialToken[]"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {limit: `${limit}`, page: `${page}`, internal: `${internal}`}, {}); }, /** * Create token - * @POST /token + * @POST /tokens * @param permissions List of permissions to grant to the token. You must already have each of these permissions with your current token. * @param lifetime Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute). * @param note A user-specified note to label the token. Max length: 2⁸ (256) characters. @@ -347,11 +347,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ create: async (permissions: string[], lifetime: number, note?: string): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Create token","token":"tokens.create.own","method":"POST","path":"/token","parameters":{"body":{"permissions":{"description":"List of permissions to grant to the token. You must already have each of these permissions with your current token.","type":"string[]","required":true},"lifetime":{"description":"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).","type":"number","required":true},"note":{"description":"A user-specified note to label the token. Max length: 2⁸ (256) characters.","type":"string","required":false}}},"returns":[{"status":201,"type":"Token"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {permissions, lifetime, note}); + return await this.#sendRequest({"type":"operation","description":"Create token","token":"tokens.create.own","method":"POST","path":"/tokens","parameters":{"body":{"permissions":{"description":"List of permissions to grant to the token. You must already have each of these permissions with your current token.","type":"string[]","required":true},"lifetime":{"description":"Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).","type":"number","required":true},"note":{"description":"A user-specified note to label the token. Max length: 2⁸ (256) characters.","type":"string","required":false}}},"returns":[{"status":201,"type":"Token"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {permissions, lifetime, note}); }, /** * Get token details - * @GET /token/:id + * @GET /tokens/:id * @param id The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -362,11 +362,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ get: async (id: string | "current"): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Get token details","token":"tokens.get.own","method":"GET","path":"/token/:id","parameters":{"path":{"id":{"description":"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true}}},"returns":[{"status":200,"type":"Token"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); + return await this.#sendRequest({"type":"operation","description":"Get token details","token":"tokens.get.own","method":"GET","path":"/tokens/:id","parameters":{"path":{"id":{"description":"The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true}}},"returns":[{"status":200,"type":"Token"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, /** * Revoke token - * @DELETE /token/:id + * @DELETE /tokens/:id * @param id The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} @@ -378,11 +378,11 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ revoke: async (id: string | "current"): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Revoke token","token":"tokens.revoke.own","method":"DELETE","path":"/token/:id","parameters":{"path":{"id":{"description":"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.","type":"string | \"current\"","required":true}}},"returns":[{"status":204,"type":"void"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":400,"type":"Error & {code: \"MODIFICATION_NOT_ALLOWED\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); + return await this.#sendRequest({"type":"operation","description":"Revoke token","token":"tokens.revoke.own","method":"DELETE","path":"/tokens/:id","parameters":{"path":{"id":{"description":"The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.","type":"string | \"current\"","required":true}}},"returns":[{"status":204,"type":"void"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":423,"type":"Error & {code: \"MODIFICATION_NOT_ALLOWED\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, /** * Get list of recent requests made with the token - * @GET /token/:id/requests + * @GET /tokens/:id/requests * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param limit The number of requests to return per page. No more than 50. * @param page The page number. No more than 2³² (4294967296). @@ -395,15 +395,16 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ listRequests: async (id: string | "current", limit: number = 10, page: number = 1): Promise>> => { - return await this.#sendRequest>({"type":"operation","description":"Get list of recent requests made with the token","token":"tokens.get.own.requests","method":"GET","path":"/token/:id/requests","parameters":{"path":{"id":{"description":"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true}},"query":{"limit":{"description":"The number of requests to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"ShortRequest[]"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {limit: `${limit}`, page: `${page}`}, {}); + return await this.#sendRequest>({"type":"operation","description":"Get list of recent requests made with the token","token":"tokens.get.own.requests","method":"GET","path":"/tokens/:id/requests","parameters":{"path":{"id":{"description":"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true}},"query":{"limit":{"description":"The number of requests to return per page. No more than 50.","default":"10","type":"number","required":false},"page":{"description":"The page number. No more than 2³² (4294967296).","default":"1","type":"number","required":false}}},"returns":[{"status":200,"type":"ShortRequest[]"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {limit: `${limit}`, page: `${page}`}, {}); }, /** * Get a recent request by ID - * @GET /token/:id/requests/:request + * @GET /tokens/:id/requests/:request * @param id The ID of the token. Specify `current` to get information about the token that was used to authenticate the request. * @param request The ID of the request. * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}} * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} + * @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} * @throws {Cloudnode.Error & {code: "RATE_LIMITED"}} @@ -411,13 +412,12 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ getRequest: async (id: string | "current", request: string): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Get a recent request by ID","token":"tokens.get.own.requests","method":"GET","path":"/token/:id/requests/:request","parameters":{"path":{"id":{"description":"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true},"request":{"description":"The ID of the request.","type":"string","required":true}}},"returns":[{"status":200,"type":"Request"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`, request: `${request}`}, {}, {}); + return await this.#sendRequest({"type":"operation","description":"Get a recent request by ID","token":"tokens.get.own.requests","method":"GET","path":"/tokens/:id/requests/:request","parameters":{"path":{"id":{"description":"The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.","type":"string | \"current\"","required":true},"request":{"description":"The ID of the request.","type":"string","required":true}}},"returns":[{"status":200,"type":"Request"},{"status":404,"type":"Error & {code: \"RESOURCE_NOT_FOUND\"}"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":423,"type":"Error & {code: \"MODIFICATION_NOT_ALLOWED\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`, request: `${request}`}, {}, {}); }, - } as const; - public tokens = { /** * Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. - * @POST /token/refresh + * @POST /tokens/:id + * @param id The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request. * @throws {Cloudnode.Error & {code: "INVALID_DATA"}} * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}} * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}} @@ -425,8 +425,8 @@ class Cloudnode { * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}} * @throws {Cloudnode.Error & {code: "MAINTENANCE"}} */ - refresh: async (): Promise> => { - return await this.#sendRequest({"type":"operation","description":"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.","token":"token.refresh","method":"POST","path":"/token/refresh","parameters":{},"returns":[{"status":201,"type":"Token"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {}, {}, {}); + refresh: async (id: string | "current"): Promise> => { + return await this.#sendRequest({"type":"operation","description":"Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.","token":"token.refresh","method":"POST","path":"/tokens/:id","parameters":{"path":{"id":{"description":"The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.","type":"string | \"current\"","required":true}}},"returns":[{"status":200,"type":"Token"},{"status":422,"type":"Error & {code: \"INVALID_DATA\"}"},{"status":401,"type":"Error & {code: \"UNAUTHORIZED\"}"},{"status":403,"type":"Error & {code: \"NO_PERMISSION\"}"},{"status":429,"type":"Error & {code: \"RATE_LIMITED\"}"},{"status":500,"type":"Error & {code: \"INTERNAL_SERVER_ERROR\"}"},{"status":503,"type":"Error & {code: \"MAINTENANCE\"}"}]}, {id: `${id}`}, {}, {}); }, } as const; public auth = { From ff99380bf3fad797e6ab6d0db3d32daf1e88a1a3 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 2 Sep 2023 02:18:07 +0300 Subject: [PATCH 8/8] browser sdk url stuck from config resolution --- gen/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/config.json b/gen/config.json index 45d59de..2b00cfc 100644 --- a/gen/config.json +++ b/gen/config.json @@ -3,5 +3,5 @@ "instanceName": "cloudnode", "baseUrl": "https://api.cloudnode.pro/v5/", "apiVersion": "5.13.0", - "browserSdkUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js" + "browserUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js" }