Skip to content

Commit d557796

Browse files
committed
Generate typescript declarations & mappings
1 parent 70fe28e commit d557796

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+956
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.1.1",
44
"description": "An official asynchronous JavaScript (Node.js) wrapper for MC-Market's Ultimate REST API.",
55
"main": "./src/index.js",
6+
"types": "./types/index.d.ts",
67
"scripts": {
78
"test": "node ./tests/test.js && npx eslint ./src/"
89
},

types/Error.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** A type which represents a parsed error from the API, or an internal wrapper error. */
2+
export class Error {
3+
/** Constructs a new Error which originated within the wrapper.
4+
*
5+
* @param {string} message The internal error message.
6+
* @returns {Error} The newly-constructed error.
7+
*/
8+
static internal(message: string): Error;
9+
constructor(json: any);
10+
/** Converts this error into a human-readable string.
11+
*
12+
* @returns {string} A string representation of this error.
13+
*/
14+
toString(): string;
15+
#private;
16+
}
17+
//# sourceMappingURL=Error.d.ts.map

types/Error.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/Http.d.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/** A type that handles raw HTTP requests to the API. */
2+
export class Http {
3+
/** The maximum number of objects returned by a list endpoint for a single request. */
4+
static "__#2@#PER_PAGE": number;
5+
/** The content type used for WRITE operations with bodies (ie. POST/PATCH). */
6+
static "__#2@#WRITE_HEADERS": {
7+
headers: {
8+
"Content-Type": string;
9+
};
10+
};
11+
constructor(client: any, throtter: any);
12+
/** Schedules a GET request for a specific endpoint.
13+
*
14+
* @param {string} endpoint The path of the endpoint (incl. any path parameters).
15+
* @param {SortOptions} sort The optional set of sort options.
16+
*
17+
* @return {*} The response data on success.
18+
*/
19+
get(endpoint: string, sort?: SortOptions): any;
20+
/** Schedules a POST request for a specific endpoint.
21+
*
22+
* @param {string} endpoint The path of the endpoint (incl. any path parameters).
23+
* @param {object} body The request body options.
24+
*
25+
* @return {number} The response data on success (ie. a content identifier).
26+
*/
27+
post(endpoint: string, body: object): number;
28+
/** Schedules a PATCH request for a specific endpoint.
29+
*
30+
* @param {string} endpoint The path of the endpoint (incl. any path parameters).
31+
* @param {object} body The request body options.
32+
*/
33+
patch(endpoint: string, body: object): any;
34+
/** Schedules a DELETE request for a specific endpoint.
35+
*
36+
* @param {string} endpoint The path of the endpoint (incl. any path parameters).
37+
*/
38+
delete(endpoint: string): any;
39+
/** A raw function returning a compiled list of objects from all available pages or until we decide to stop.
40+
*
41+
* <br><br>
42+
*
43+
* 'shouldContinue' expects a function with a single parameter and should return a boolean representing if we
44+
* should continue to add the current (and future) objects to the final list (and thus, if we should continue
45+
* to make requests). This function is called for every single object as a parameter within each request's
46+
* returned list.
47+
*
48+
* <br><br>
49+
*
50+
* This function continuously makes requests to a specific endpoint with a set of sort options, and increments the
51+
* sort option page count after each request.
52+
*
53+
* @param {string} endpoint The path of the endpoint (incl. any path parameters).
54+
* @param {function(object):boolean} shouldContinue A function which determines if further pages are requested.
55+
* @param {SortOptions} sort An optional set of sort options.
56+
*
57+
* @return {Array<object>} An array of raw objects.
58+
*/
59+
listUntil(endpoint: string, shouldContinue: (arg0: object) => boolean, sort?: SortOptions): Array<object>;
60+
#private;
61+
}
62+
import { SortOptions } from "./SortOptions.js";
63+
//# sourceMappingURL=Http.d.ts.map

types/Http.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/SortOptions.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** A type representing the sorting options available for listing-style endpoints. */
2+
export class SortOptions {
3+
sort: any;
4+
order: any;
5+
page: any;
6+
/** Convets this SortOptions instance into a query string.
7+
*
8+
* @returns {string} The query-string representation.
9+
*/
10+
toQueryString(): string;
11+
/** Returns whether or not any sort options have been set.
12+
*
13+
* @returns {bool} Whether or not any sort options have been set.
14+
*/
15+
isSet(): bool;
16+
}
17+
//# sourceMappingURL=SortOptions.d.ts.map

types/SortOptions.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/Throttler.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class Throttler {
2+
setRead(retry: any): void;
3+
setWrite(retry: any): void;
4+
resetRead(): void;
5+
resetWrite(): void;
6+
stallIfRequired(write: any): Promise<void>;
7+
#private;
8+
}
9+
//# sourceMappingURL=Throttler.d.ts.map

types/Throttler.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/Token.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** A type representing an API authentication token. */
2+
export class Token {
3+
/** Constructs a new token from its constituents.
4+
*
5+
* @param {TokenType} type The type of this token.
6+
* @param {string} value The value of this token.
7+
*/
8+
constructor(type: TokenType, value: string);
9+
/** Constructs an object containing the header representation of this token.
10+
*
11+
* @returns An object with a single attribute, 'Authorization'.
12+
*/
13+
asHeader(): {
14+
Authorization: string;
15+
};
16+
#private;
17+
}
18+
import { TokenType } from "./TokenType.js";
19+
//# sourceMappingURL=Token.d.ts.map

0 commit comments

Comments
 (0)