Skip to content

Commit f4093c5

Browse files
author
williamd5
authored
Merge branch 'main' into 23-smart-rate-limit-handling
2 parents 41fbe3b + f9248ea commit f4093c5

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Get another page of paginated results
130130
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get a different page of.
131131
- `page` <code>[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)</code> Page to get.
132132
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The new page or null if the page is out of bounds
133-
133+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
134134

135135
<a name="cloudnodegetnextpagetresponse"></a>
136136

@@ -140,7 +140,7 @@ Get next page of paginated results
140140

141141
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get the next page of.
142142
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The next page or null if this is the last page
143-
143+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
144144

145145
<a name="cloudnodegetpreviouspagetresponse"></a>
146146

@@ -150,7 +150,7 @@ Get previous page of paginated results
150150

151151
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get the previous page of.
152152
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The previous page or null if this is the first page
153-
153+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
154154

155155
<a name="cloudnodegetallpagestresponse"></a>
156156

@@ -161,7 +161,7 @@ Get all other pages of paginated results and return the complete data
161161
162162
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get all pages of.
163163
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> All of the data in 1 page
164-
164+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
165165

166166
<a name="cloudnodenewslettergetid"></a>
167167

browser/Cloudnode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class Cloudnode {
136136
* @param response Response to get a different page of
137137
* @param page Page to get
138138
* @returns The new page or null if the page is out of bounds
139+
* @throws {Cloudnode.Error} Error returned by the API
139140
*/
140141
async getPage(response, page) {
141142
if (page * response.limit > response.total || page < 1)
@@ -148,6 +149,7 @@ class Cloudnode {
148149
* Get next page of paginated results
149150
* @param response Response to get the next page of
150151
* @returns The next page or null if this is the last page
152+
* @throws {Cloudnode.Error} Error returned by the API
151153
*/
152154
async getNextPage(response) {
153155
return await this.getPage(response, response.page + 1);
@@ -156,6 +158,7 @@ class Cloudnode {
156158
* Get previous page of paginated results
157159
* @param response Response to get the previous page of
158160
* @returns The previous page or null if this is the first page
161+
* @throws {Cloudnode.Error} Error returned by the API
159162
*/
160163
async getPreviousPage(response) {
161164
return await this.getPage(response, response.page - 1);
@@ -165,6 +168,7 @@ class Cloudnode {
165168
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
166169
* @param response Response to get all pages of
167170
* @returns All of the data in 1 page
171+
* @throws {Cloudnode.Error} Error returned by the API
168172
*/
169173
async getAllPages(response) {
170174
const pages = new Array(Math.ceil(response.total / response.limit)).fill(null);

gen/docs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ export function generateDocSchema (schema: Schema, config: Config, pkg: Package)
8484
], {
8585
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
8686
description: "The new page or null if the page is out of bounds"
87-
}, []));
87+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
8888
always.push(new DocSchema.Method(`${config.name}.getNextPage<T>`, "Get next page of paginated results", [
8989
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get the next page of", true)
9090
], {
9191
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
9292
description: "The next page or null if this is the last page"
93-
}, []));
93+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
9494
always.push(new DocSchema.Method(`${config.name}.getPreviousPage<T>`, "Get previous page of paginated results", [
9595
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get the previous page of", true)
9696
], {
9797
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
9898
description: "The previous page or null if this is the first page"
99-
}, []));
99+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
100100
always.push(new DocSchema.Method(`${config.name}.getAllPages<T>`, "Get all other pages of paginated results and return the complete data\n> **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.", [
101101
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get all pages of", true)
102102
], {
103103
type: `Promise<${config.name}.PaginatedData<T>>`,
104104
description: "All of the data in 1 page"
105-
}, []));
105+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
106106
mainClass.properties.unshift(...always);
107107
mainNamespace.properties.sort((a, b) => a.displayName.localeCompare(b.displayName));
108108

gen/templates/main.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class {{config.name}} {
141141
* @param response Response to get a different page of
142142
* @param page Page to get
143143
* @returns The new page or null if the page is out of bounds
144+
* @throws {Cloudnode.Error} Error returned by the API
144145
*/
145146
async getPage<T>(response: {{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>>, page: number): Promise<{{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>> | null> {
146147
if (page * response.limit > response.total || page < 1) return null;
@@ -153,6 +154,7 @@ class {{config.name}} {
153154
* Get next page of paginated results
154155
* @param response Response to get the next page of
155156
* @returns The next page or null if this is the last page
157+
* @throws {Cloudnode.Error} Error returned by the API
156158
*/
157159
async getNextPage<T>(response: {{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>>): Promise<{{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>> | null> {
158160
return await this.getPage(response, response.page + 1);
@@ -162,6 +164,7 @@ class {{config.name}} {
162164
* Get previous page of paginated results
163165
* @param response Response to get the previous page of
164166
* @returns The previous page or null if this is the first page
167+
* @throws {Cloudnode.Error} Error returned by the API
165168
*/
166169
async getPreviousPage<T>(response: {{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>>): Promise<{{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>> | null> {
167170
return await this.getPage(response, response.page - 1);
@@ -172,6 +175,7 @@ class {{config.name}} {
172175
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
173176
* @param response Response to get all pages of
174177
* @returns All of the data in 1 page
178+
* @throws {Cloudnode.Error} Error returned by the API
175179
*/
176180
async getAllPages<T>(response: {{config.name}}.ApiResponse<{{config.name}}.PaginatedData<T>>): Promise<{{config.name}}.PaginatedData<T>> {
177181
const pages: (true | null)[] = new Array(Math.ceil(response.total / response.limit)).fill(null);

src/Cloudnode.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@ declare class Cloudnode {
1616
* @param response Response to get a different page of
1717
* @param page Page to get
1818
* @returns The new page or null if the page is out of bounds
19+
* @throws {Cloudnode.Error} Error returned by the API
1920
*/
2021
getPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>, page: number): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
2122
/**
2223
* Get next page of paginated results
2324
* @param response Response to get the next page of
2425
* @returns The next page or null if this is the last page
26+
* @throws {Cloudnode.Error} Error returned by the API
2527
*/
2628
getNextPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
2729
/**
2830
* Get previous page of paginated results
2931
* @param response Response to get the previous page of
3032
* @returns The previous page or null if this is the first page
33+
* @throws {Cloudnode.Error} Error returned by the API
3134
*/
3235
getPreviousPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
3336
/**
3437
* Get all other pages of paginated results and return the complete data
3538
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
3639
* @param response Response to get all pages of
3740
* @returns All of the data in 1 page
41+
* @throws {Cloudnode.Error} Error returned by the API
3842
*/
3943
getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>>;
4044
newsletter: {

src/Cloudnode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class Cloudnode {
136136
* @param response Response to get a different page of
137137
* @param page Page to get
138138
* @returns The new page or null if the page is out of bounds
139+
* @throws {Cloudnode.Error} Error returned by the API
139140
*/
140141
async getPage(response, page) {
141142
if (page * response.limit > response.total || page < 1)
@@ -148,6 +149,7 @@ class Cloudnode {
148149
* Get next page of paginated results
149150
* @param response Response to get the next page of
150151
* @returns The next page or null if this is the last page
152+
* @throws {Cloudnode.Error} Error returned by the API
151153
*/
152154
async getNextPage(response) {
153155
return await this.getPage(response, response.page + 1);
@@ -156,6 +158,7 @@ class Cloudnode {
156158
* Get previous page of paginated results
157159
* @param response Response to get the previous page of
158160
* @returns The previous page or null if this is the first page
161+
* @throws {Cloudnode.Error} Error returned by the API
159162
*/
160163
async getPreviousPage(response) {
161164
return await this.getPage(response, response.page - 1);
@@ -165,6 +168,7 @@ class Cloudnode {
165168
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
166169
* @param response Response to get all pages of
167170
* @returns All of the data in 1 page
171+
* @throws {Cloudnode.Error} Error returned by the API
168172
*/
169173
async getAllPages(response) {
170174
const pages = new Array(Math.ceil(response.total / response.limit)).fill(null);

src/Cloudnode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class Cloudnode {
141141
* @param response Response to get a different page of
142142
* @param page Page to get
143143
* @returns The new page or null if the page is out of bounds
144+
* @throws {Cloudnode.Error} Error returned by the API
144145
*/
145146
async getPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>, page: number): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
146147
if (page * response.limit > response.total || page < 1) return null;
@@ -153,6 +154,7 @@ class Cloudnode {
153154
* Get next page of paginated results
154155
* @param response Response to get the next page of
155156
* @returns The next page or null if this is the last page
157+
* @throws {Cloudnode.Error} Error returned by the API
156158
*/
157159
async getNextPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
158160
return await this.getPage(response, response.page + 1);
@@ -162,6 +164,7 @@ class Cloudnode {
162164
* Get previous page of paginated results
163165
* @param response Response to get the previous page of
164166
* @returns The previous page or null if this is the first page
167+
* @throws {Cloudnode.Error} Error returned by the API
165168
*/
166169
async getPreviousPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
167170
return await this.getPage(response, response.page - 1);
@@ -172,6 +175,7 @@ class Cloudnode {
172175
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
173176
* @param response Response to get all pages of
174177
* @returns All of the data in 1 page
178+
* @throws {Cloudnode.Error} Error returned by the API
175179
*/
176180
async getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>> {
177181
const pages: (true | null)[] = new Array(Math.ceil(response.total / response.limit)).fill(null);

0 commit comments

Comments
 (0)