Skip to content

Commit

Permalink
fix: Fixing typing structure and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed May 25, 2019
1 parent 7ebb616 commit a79dabe
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 113 deletions.
68 changes: 0 additions & 68 deletions src/types.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions tsconfig-es5.dist.json

This file was deleted.

15 changes: 0 additions & 15 deletions tsconfig.dist.json

This file was deleted.

44 changes: 27 additions & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
/* Basic Options */

"target": "es5",
"module": "es6",
"outDir": "dist",
"pretty": true,
"declaration": true,
"lib": ["ES2015", "ES2016", "ES2017", "DOM"],

/* Module Resolution Options */

"moduleResolution": "node",
"esModuleInterop": true,
"baseUrl": "./",

/* Strict Type-Checking Options */

"strictPropertyInitialization": true,
"strictNullChecks": true,
"noImplicitAny": false,
"downlevelIteration": true,

/* Additional Checks */

"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"pretty": false,
"esModuleInterop": true,
"declaration": false,
"outDir": "dist/latest"
"noImplicitReturns": true
},
"include": [
"src/**/*",
"test/tests/**/*"
],
"exclude": [
"node_modules"
]
}
"include": ["typings/*", "src/**/*"]
}
7 changes: 7 additions & 0 deletions typings/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare function encodeURIComponent(uriComponent: string | number | boolean): string;

declare interface Global {
URL: typeof URL,
URLSearchParams: typeof URLSearchParams,
encodeURIComponent: typeof encodeURIComponent
}
3 changes: 3 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference path="globals.d.ts" />
/// <reference path="services.d.ts" />
/// <reference path="infrastructure.d.ts" />
70 changes: 70 additions & 0 deletions typings/infrastructure.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Bundler
interface Constructor {
new (...args: any): any;
}

type Mapper<T extends { [name: string]: Constructor }, P extends keyof T> = {
[name in P]: InstanceType<T[name]>
};

interface Bundle<T extends { [name: string]: Constructor }, P extends keyof T> {
new (options?: any): Mapper<T, P>;
}

// Base Service
interface Sudo {
sudo?: string | number;
}

interface Requester {
get: Function;
post: Function;
put: Function;
delete: Function;
stream?: Function;
}

interface BaseServiceOptions extends Sudo {
oauthToken?: string;
token?: string;
jobToken?: string;
host?: string;
url?: string;
version?: string;
rejectUnauthorized?: boolean;
camelize?: boolean;
requester?: Requester;
}

// RequestHelper
interface PaginationOptions {
total: number;
next: number | null;
current: number;
previous: number | null;
perPage: number;
totalPages: number;
}

interface DefaultRequestOptions extends Sudo {
body?: object | FormData;
query?: object;
}

interface BaseRequestOptions extends Sudo {
[key: string]: any;
}

interface PaginatedRequestOptions extends BaseRequestOptions {
showPagination?: boolean;
maxPages?: number;
page?: number;
perPage?: number;
}

type PaginationResponse = { data: object[], pagination: PaginationOptions }
type GetResponse = PaginationResponse | object | object[];
type PostResponse = object;
type PutResponse = object;
type DelResponse = object;

Loading

0 comments on commit a79dabe

Please sign in to comment.