🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

cloudnode-ts

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudnode-ts - npm Package Compare versions

Comparing version

to
3.0.0

gen/readme.d.ts

127

browser/Cloudnode.js
/**
* A client SDK for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* @class

@@ -34,3 +34,3 @@ */

*/
#apiVersion = `5.12.0`;
#apiVersion = `5.13.0`;
/**

@@ -225,6 +225,6 @@ * Client user agent

}
newsletter = {
newsletters = {
/**
* List newsletters
* @GET /newsletter
* @GET /newsletters
* @param limit The number of newsletters to return per page. No more than 50.

@@ -237,7 +237,7 @@ * @param page The page number. No more than 2³² (4294967296).

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

@@ -250,13 +250,25 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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"}}

@@ -266,13 +278,13 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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<string, string | number | boolean>", "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
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}
* 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: "INVALID_DATA"}}
* @throws {Cloudnode.Error & {code: "CONFLICT"}}
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}

@@ -282,12 +294,11 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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<string, string | number | boolean>", "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 });
},
/**
* 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"}}

@@ -297,10 +308,10 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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 = {
tokens = {
/**
* List tokens of user
* @GET /token
* @GET /tokens
* @param limit The number of tokens to return per page. No more than 50.

@@ -316,7 +327,7 @@ * @param page The page number. No more than 2³² (4294967296).

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.

@@ -333,7 +344,7 @@ * @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).

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.

@@ -349,7 +360,7 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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.

@@ -366,7 +377,7 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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.

@@ -384,7 +395,7 @@ * @param limit The number of requests to return per page. No more than 50.

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.

@@ -394,2 +405,3 @@ * @param request The ID of the request.

* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
* @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}}
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

@@ -402,9 +414,8 @@ * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}}

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"}}

@@ -417,4 +428,4 @@ * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

*/
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}` }, {}, {});
},

@@ -428,3 +439,3 @@ };

* @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.

@@ -440,3 +451,3 @@ * @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.

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 });
},

@@ -490,4 +501,4 @@ /**

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -504,3 +515,3 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

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. 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 });
},

@@ -510,4 +521,4 @@ /**

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -523,3 +534,3 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

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. 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 });
},

@@ -526,0 +537,0 @@ /**

@@ -1,1 +0,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&&p<o.maxRetries&&e instanceof Cloudnode.R.ApiResponse){const t=e,r=Number(429!==t._response.status?t._response.headers["x-retry-after"]??t._response.headers["retry-after"]:t._response.headers["x-ratelimit-reset"]??t._response.headers["x-rate-limit-reset"]??t._response.headers["ratelimit-reset"]??t._response.headers["rate-limit-reset"]??t._response.headers["retry-after"]??t._response.headers["x-retry-after"]);if(Number.isNaN(r)||r>o.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<string, string | number | boolean>",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={}));
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&&p<o.maxRetries&&e instanceof Cloudnode.R.ApiResponse){const t=e,r=Number(429!==t._response.status?t._response.headers["x-retry-after"]??t._response.headers["retry-after"]:t._response.headers["x-ratelimit-reset"]??t._response.headers["x-rate-limit-reset"]??t._response.headers["ratelimit-reset"]??t._response.headers["rate-limit-reset"]??t._response.headers["retry-after"]??t._response.headers["x-retry-after"]);if(Number.isNaN(r)||r>o.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<string, string | number | boolean>",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={}));

@@ -7,4 +7,4 @@ import fs from "node:fs/promises";

// create a browser-compatible SDK
export async function createBrowserSDK(config: Config): Promise<void> {
// create a browser-compatible version
export async function createBrowser(config: Config): Promise<void> {
const mainJs = await fs.readFile(path.join("src", config.name + ".js"), "utf-8");

@@ -11,0 +11,0 @@ // remove imports at beginning of file and export default at end of file

@@ -5,4 +5,4 @@ {

"baseUrl": "https://api.cloudnode.pro/v5/",
"apiVersion": "5.12.0",
"browserSdkUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js"
"apiVersion": "5.13.0",
"browserUrl": "https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js"
}

@@ -23,5 +23,5 @@ export interface Config {

/**
* Link to hosted browser SDK
* Link to hosted browser version
*/
browserSdkUrl: string;
browserUrl: string;
}

@@ -11,3 +11,3 @@ import Schema from "./Schema";

import {promisify} from "util";
import {createBrowserSDK} from "./browser.js";
import {createBrowser} from "./browser.js";

@@ -38,4 +38,4 @@ // load `/schema.json`

// generate browser SDK
await createBrowserSDK(config);
// generate browser version
await createBrowser(config);

@@ -42,0 +42,0 @@ // generate doc schema

{
"name": "cloudnode-ts",
"version": "2.1.0",
"description": "A client SDK for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)",
"version": "3.0.0",
"description": "A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)",
"main": "src/Cloudnode.js",

@@ -21,4 +21,4 @@ "type": "module",

"api",
"sdk",
"client"
"client",
"library"
],

@@ -25,0 +25,0 @@ "author": "Cloudnode",

@@ -1,2 +0,2 @@

# {{config.name}} API SDK
# {{config.name}} API Client

@@ -41,5 +41,5 @@ {{{shield.version}}}

#### Browser
Download the browser SDK from `browser/{{config.name}}.js` or use our hosted version.
Download the browser version from `browser/{{config.name}}.js` or use our hosted version.
```html
<script src="{{{config.browserSdkUrl}}}"></script>
<script src="{{{config.browserUrl}}}"></script>
<script>

@@ -46,0 +46,0 @@ const {{config.instanceName}} = new {{config.name}}();

@@ -507,3 +507,3 @@ {

"operations": {
"newsletter": {
"newsletters": {
"type": "namespace",

@@ -515,3 +515,3 @@ "operations": {

"method": "GET",
"path": "/newsletter",
"path": "/newsletters",
"parameters": {

@@ -544,3 +544,3 @@ "query": {

"method": "GET",
"path": "/newsletter/:id",
"path": "/newsletters/:id",
"parameters": {

@@ -565,17 +565,74 @@ "path": {

]
}
}
},
"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": {

@@ -599,6 +656,2 @@ "description": "Subscriber's email address",

{
"status": 404,
"type": "Error & {code: \"RESOURCE_NOT_FOUND\"}"
},
{
"status": 422,

@@ -612,16 +665,11 @@ "type": "Error & {code: \"INVALID_DATA\"}"

]
}
}
},
"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",

@@ -647,35 +695,6 @@ "type": "string",

]
},
"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[]"
}
]
}
}
},
"token": {
"tokens": {
"type": "namespace",

@@ -688,3 +707,3 @@ "operations": {

"method": "GET",
"path": "/token",
"path": "/tokens",
"parameters": {

@@ -723,3 +742,3 @@ "query": {

"method": "POST",
"path": "/token",
"path": "/tokens",
"parameters": {

@@ -760,3 +779,3 @@ "body": {

"method": "GET",
"path": "/token/:id",
"path": "/tokens/:id",
"parameters": {

@@ -791,3 +810,3 @@ "path": {

"method": "DELETE",
"path": "/token/:id",
"path": "/tokens/:id",
"parameters": {

@@ -816,3 +835,3 @@ "path": {

{
"status": 400,
"status": 423,
"type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}"

@@ -827,3 +846,3 @@ }

"method": "GET",
"path": "/token/:id/requests",
"path": "/tokens/:id/requests",
"parameters": {

@@ -872,3 +891,3 @@ "path": {

"method": "GET",
"path": "/token/:id/requests/:request",
"path": "/tokens/:id/requests/:request",
"parameters": {

@@ -900,10 +919,9 @@ "path": {

"type": "Error & {code: \"INVALID_DATA\"}"
},
{
"status": 423,
"type": "Error & {code: \"MODIFICATION_NOT_ALLOWED\"}"
}
]
}
}
},
"tokens": {
"type": "namespace",
"operations": {
},
"refresh": {

@@ -914,7 +932,15 @@ "type": "operation",

"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"

@@ -942,3 +968,3 @@ },

"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",

@@ -1057,3 +1083,3 @@ "required": true

"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",

@@ -1063,3 +1089,3 @@ "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",

@@ -1103,3 +1129,3 @@ "required": false

"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",

@@ -1109,3 +1135,3 @@ "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",

@@ -1112,0 +1138,0 @@ "required": true

import Schema from "../gen/Schema";
/**
* A client SDK for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* @class

@@ -49,6 +49,6 @@ */

getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>>;
newsletter: {
newsletters: {
/**
* List newsletters
* @GET /newsletter
* @GET /newsletters
* @param limit The number of newsletters to return per page. No more than 50.

@@ -63,3 +63,3 @@ * @param page The page number. No more than 2³² (4294967296).

* Get newsletter
* @GET /newsletter/:id
* @GET /newsletters/:id
* @param id A newsletter ID

@@ -72,9 +72,32 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

readonly get: (id: string) => Promise<Cloudnode.ApiResponse<Cloudnode.Newsletter>>;
};
subscriptions: {
/**
* 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<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.DatedNewsletterSubscription[]>>>;
/**
* 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: "RATE_LIMITED"}}
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
*/
readonly get: (id: string) => Promise<Cloudnode.ApiResponse<Cloudnode.DatedNewsletterSubscription>>;
/**
* Subscribe to newsletter
* @POST /newsletter/:id/subscribe
* @param id A newsletter ID
* @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"}}

@@ -86,9 +109,7 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

*/
readonly subscribe: (id: string, email: string, data?: Record<string, string | number | boolean>) => Promise<Cloudnode.ApiResponse<Cloudnode.NewsletterSubscription>>;
};
newsletters: {
readonly create: (newsletter: string, email: string, data?: Record<string, string | number | boolean>) => Promise<Cloudnode.ApiResponse<Cloudnode.NewsletterSubscription>>;
/**
* Revoke a subscription (unsubscribe)
* @POST /newsletters/unsubscribe
* @param subscription The ID of the subscription to revoke
* Unsubscribe from newsletter
* @DELETE /subscriptions/:id
* @param id The ID of the subscription to revoke
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -100,20 +121,8 @@ * @throws {Cloudnode.Error & {code: "INVALID_DATA"}}

*/
readonly unsubscribe: (subscription: string) => Promise<Cloudnode.ApiResponse<void>>;
/**
* 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"}}
* @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<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.DatedNewsletterSubscription[]>>>;
readonly delete: (id: string) => Promise<Cloudnode.ApiResponse<void>>;
};
token: {
tokens: {
/**
* List tokens of user
* @GET /token
* @GET /tokens
* @param limit The number of tokens to return per page. No more than 50.

@@ -131,3 +140,3 @@ * @param page The page number. No more than 2³² (4294967296).

* 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.

@@ -146,3 +155,3 @@ * @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).

* 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.

@@ -160,3 +169,3 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

* 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.

@@ -175,3 +184,3 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

* 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.

@@ -191,3 +200,3 @@ * @param limit The number of requests to return per page. No more than 50.

* 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.

@@ -197,2 +206,3 @@ * @param request The ID of the request.

* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
* @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}}
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

@@ -205,7 +215,6 @@ * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}}

readonly getRequest: (id: string | "current", request: string) => Promise<Cloudnode.ApiResponse<Cloudnode.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"}}

@@ -218,3 +227,3 @@ * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

*/
readonly refresh: () => Promise<Cloudnode.ApiResponse<Cloudnode.Token>>;
readonly refresh: (id: string | "current") => Promise<Cloudnode.ApiResponse<Cloudnode.Token>>;
};

@@ -227,3 +236,3 @@ auth: {

* @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.

@@ -284,4 +293,4 @@ * @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.

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -301,4 +310,4 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -305,0 +314,0 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

/**
* A client SDK for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
* @class

@@ -34,3 +34,3 @@ */

*/
#apiVersion = `5.12.0`;
#apiVersion = `5.13.0`;
/**

@@ -225,6 +225,6 @@ * Client user agent

}
newsletter = {
newsletters = {
/**
* List newsletters
* @GET /newsletter
* @GET /newsletters
* @param limit The number of newsletters to return per page. No more than 50.

@@ -237,7 +237,7 @@ * @param page The page number. No more than 2³² (4294967296).

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

@@ -250,13 +250,25 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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"}}

@@ -266,13 +278,13 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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<string, string | number | boolean>", "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
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}
* 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: "INVALID_DATA"}}
* @throws {Cloudnode.Error & {code: "CONFLICT"}}
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}

@@ -282,12 +294,11 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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<string, string | number | boolean>", "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 });
},
/**
* 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"}}

@@ -297,10 +308,10 @@ * @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}

*/
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 = {
tokens = {
/**
* List tokens of user
* @GET /token
* @GET /tokens
* @param limit The number of tokens to return per page. No more than 50.

@@ -316,7 +327,7 @@ * @param page The page number. No more than 2³² (4294967296).

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.

@@ -333,7 +344,7 @@ * @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).

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.

@@ -349,7 +360,7 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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.

@@ -366,7 +377,7 @@ * @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

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.

@@ -384,7 +395,7 @@ * @param limit The number of requests to return per page. No more than 50.

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.

@@ -394,2 +405,3 @@ * @param request The ID of the request.

* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
* @throws {Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}}
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

@@ -402,9 +414,8 @@ * @throws {Cloudnode.Error & {code: "NO_PERMISSION"}}

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"}}

@@ -417,4 +428,4 @@ * @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}

*/
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}` }, {}, {});
},

@@ -428,3 +439,3 @@ };

* @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.

@@ -440,3 +451,3 @@ * @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.

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 });
},

@@ -490,4 +501,4 @@ /**

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -504,3 +515,3 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

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. 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 });
},

@@ -510,4 +521,4 @@ /**

* @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 name Your full name. Set to `null` to remove.
* @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. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`
* @throws {Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}}

@@ -523,3 +534,3 @@ * @throws {Cloudnode.Error & {code: "CONFLICT"}}

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. 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 });
},

@@ -526,0 +537,0 @@ /**

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display