Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Generate typings #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
22 changes: 21 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 37 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,54 @@
"description": "JavaScript API client for accessing the Whop API",
"license": "Apache 2.0",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "babel src -d dist",
"prepare": "npm run build",
"test": "mocha --require @babel/register --recursive"
"build": "babel src -d dist",
"prepare": "npm run build",
"test": "mocha --require @babel/register --recursive",
"build-types": "tsc"
},
"browser": {
"fs": false
"fs": false
},
"dependencies": {
"@babel/cli": "^7.0.0",
"superagent": "^5.3.0"
"@babel/cli": "^7.0.0",
"superagent": "^5.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/whopio/whop-javascript-sdk.git"
"type": "git",
"url": "https://github.com/whopio/whop-javascript-sdk.git"
},
"bugs": {
"url": "https://github.com/whopio/whop-javascript-sdk/issues",
"email": "[email protected]"
"url": "https://github.com/whopio/whop-javascript-sdk/issues",
"email": "[email protected]"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"expect.js": "^0.3.1",
"mocha": "^8.0.1",
"sinon": "^7.2.0"
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"expect.js": "^0.3.1",
"mocha": "^8.0.1",
"sinon": "^7.2.0",
"typescript": "^4.9.4"
},
"files": [
"dist"
"dist"
]
}
}
22 changes: 22 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Change this to match your project
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"],
"compilerOptions": {
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
// Types should go into this directory.
// Removing this would place the .d.ts files
// next to the .js files
"outDir": "types",
// go to js file when using IDE functions like
// "Go to Definition" in VSCode
"declarationMap": true
}
}
203 changes: 203 additions & 0 deletions types/ApiClient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
export default ApiClient;
/**
* @module ApiClient
* @version 1.0.10
*/
/**
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
* application to use this class directly - the *Api and model classes provide the public API for the service. The
* contents of this file should be regarded as internal but are documented for completeness.
* @alias module:ApiClient
* @class
*/
declare class ApiClient {
/**
* Returns a boolean indicating if the parameter could be JSON.stringified
* @param param The actual parameter
* @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
*/
static canBeJsonified(str: any): boolean;
/**
* Parses an ISO-8601 string representation or epoch representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/
static parseDate(str: string): Date;
/**
* Converts a value to the specified type.
* @param {(String|Object)} data The data to convert, as a string or object.
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
* all properties on <code>data<code> will be converted to this type.
* @returns An instance of the specified type or null or undefined if data is null or undefined.
*/
static convertToType(data: (string | any), type: (string | Array<string> | any | Function)): any;
/**
* Constructs a new map or array model from REST data.
* @param data {Object|Array} The REST data.
* @param obj {Object|Array} The target object or array.
*/
static constructFromObject(data: any | any[], obj: any | any[], itemType: any): void;
/**
* The base URL against which to resolve every API call's (relative) path.
* Overrides the default value set in spec file if present
* @param {String} basePath
*/
constructor(basePath?: string);
/**
* The base URL against which to resolve every API call's (relative) path.
* @type {String}
* @default https://api.whop.com/api
*/
basePath: string;
/**
* The authentication methods to be included for all API calls.
* @type {Array.<String>}
*/
authentications: Array<string>;
/**
* The default HTTP headers to be included for all API calls.
* @type {Array.<String>}
* @default {}
*/
defaultHeaders: Array<string>;
/**
* The default HTTP timeout for all API calls.
* @type {Number}
* @default 60000
*/
timeout: number;
/**
* If set to false an additional timestamp parameter is added to all API GET calls to
* prevent browser caching
* @type {Boolean}
* @default true
*/
cache: boolean;
/**
* If set to true, the client will save the cookies from each server
* response, and return them in the next request.
* @default false
*/
enableCookies: boolean;
agent: any;
requestAgent: any;
plugins: any;
/**
* Returns a string representation for an actual parameter.
* @param param The actual parameter.
* @returns {String} The string representation of <code>param</code>.
*/
paramToString(param: any): string;
/**
* Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
* NOTE: query parameters are not handled here.
* @param {String} path The path to append to the base URL.
* @param {Object} pathParams The parameter values to append.
* @param {String} apiBasePath Base path defined in the path, operation level to override the default one
* @returns {String} The encoded path with parameter values substituted.
*/
buildUrl(path: string, pathParams: any, apiBasePath: string): string;
/**
* Checks whether the given content type represents JSON.<br>
* JSON content type examples:<br>
* <ul>
* <li>application/json</li>
* <li>application/json; charset=UTF8</li>
* <li>APPLICATION/JSON</li>
* </ul>
* @param {String} contentType The MIME content type to check.
* @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
*/
isJsonMime(contentType: string): boolean;
/**
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
* @param {Array.<String>} contentTypes
* @returns {String} The chosen content type, preferring JSON.
*/
jsonPreferredMime(contentTypes: Array<string>): string;
/**
* Checks whether the given parameter value represents file-like content.
* @param param The parameter to check.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
*/
isFileParam(param: any): boolean;
/**
* Normalizes parameter values:
* <ul>
* <li>remove nils</li>
* <li>keep files and arrays</li>
* <li>format to string with `paramToString` for other cases</li>
* </ul>
* @param {Object.<String, Object>} params The parameters as object properties.
* @returns {Object.<String, Object>} normalized parameters.
*/
normalizeParams(params: any): any;
/**
* Builds a string representation of an array-type actual parameter, according to the given collection format.
* @param {Array} param An array parameter.
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
*/
buildCollectionParam(param: any[], collectionFormat: any): string | any[];
/**
* Applies authentication headers to the request.
* @param {Object} request The request object created by a <code>superagent()</code> call.
* @param {Array.<String>} authNames An array of authentication method names.
*/
applyAuthToRequest(request: any, authNames: Array<string>): void;
/**
* Deserializes an HTTP response body into a value of the specified type.
* @param {Object} response A SuperAgent response object.
* @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
* all properties on <code>data<code> will be converted to this type.
* @returns A value of the specified type.
*/
deserialize(response: any, returnType: (string | Array<string> | any | Function)): any;
/**
* Invokes the REST service using the supplied settings and parameters.
* @param {String} path The base URL to invoke.
* @param {String} httpMethod The HTTP method to use.
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
* @param {Object.<String, Object>} queryParams A map of query parameters and their values.
* @param {Object.<String, Object>} headerParams A map of header parameters and their values.
* @param {Object.<String, Object>} formParams A map of form parameters and their values.
* @param {Object} bodyParam The value to pass as the request body.
* @param {Array.<String>} authNames An array of authentication type names.
* @param {Array.<String>} contentTypes An array of request MIME types.
* @param {Array.<String>} accepts An array of acceptable response MIME types.
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
* constructor for a complex type.
* @param {String} apiBasePath base path defined in the operation/path level to override the default one
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
*/
callApi(path: string, httpMethod: string, pathParams: any, queryParams: any, headerParams: any, formParams: any, bodyParam: any, authNames: Array<string>, contentTypes: Array<string>, accepts: Array<string>, returnType: (string | any[] | ObjectFunction), apiBasePath: string): Promise<any>;
/**
* Gets an array of host settings
* @returns An array of host settings
*/
hostSettings(): {
url: string;
description: string;
}[];
getBasePathFromSettings(index: any, variables?: {}): string;
}
declare namespace ApiClient {
namespace CollectionFormatEnum {
const CSV: string;
const SSV: string;
const TSV: string;
const PIPES: string;
const MULTI: string;
}
/**
* *
*/
type CollectionFormatEnum = string;
const instance: any;
}
//# sourceMappingURL=ApiClient.d.ts.map
1 change: 1 addition & 0 deletions types/ApiClient.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading