Skip to content

Commit cdd6708

Browse files
committed
chore: added types files in build
1 parent 806acd0 commit cdd6708

File tree

15 files changed

+127
-1
lines changed

15 files changed

+127
-1
lines changed

build/core/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { MockServerResponse } from "../types";
2+
export declare const handleMockEndpoint: (req: any, pathPrefix: string) => Promise<MockServerResponse>;

build/core/mockProcessor.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { MockServerResponse, RequestMethod } from "../types";
2+
import { Mock, Response } from "../types/mock";
3+
declare class MockProcessor {
4+
static process: (mockData: Mock, endpoint: string, method: RequestMethod) => Promise<MockServerResponse>;
5+
static renderMockServerResponse: (mockData: Mock) => Promise<MockServerResponse>;
6+
static renderStatusCode: (responseTemplate: Response) => number;
7+
static renderHeaders: (responseTemplate: Response) => any;
8+
static renderBody: (responseTemplate: Response) => string;
9+
static addDelay: (delay?: number) => Promise<unknown>;
10+
}
11+
export default MockProcessor;

build/core/mockSelector.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { RequestMethod } from "../types";
2+
import { Mock } from "../types/mock";
3+
declare class MockSelector {
4+
static selectMock: (endpoint: string, method: RequestMethod, kwargs: any) => Promise<Mock | null | undefined>;
5+
static compareSelector: (selector: any, endpoint: string, method: RequestMethod) => Boolean;
6+
}
7+
export default MockSelector;

build/core/utils/urlMatcher.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Common method that gets called
3+
* - selecting mock
4+
* - processing mock to find out path params
5+
* @param pattern Pattern To match (endpoint defined while creating mock)
6+
* @param url Actual Url that got hit
7+
* @return If pattern matches the url, then return the variables as kwargs, else return null
8+
*/
9+
declare const urlMatcher: (pattern: string, url: string) => any;
10+
export default urlMatcher;

build/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import IConfigFetcher from "./interfaces/configFetcherInterface";
2+
import { setupMockServer, startMockServer } from "./main";
3+
import { Mock as MockSchema, Response as MockResponseSchema, Header as MockHeaderSchema } from "./types/mock";
4+
export { startMockServer, setupMockServer, IConfigFetcher, MockSchema, MockResponseSchema, MockHeaderSchema, };
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Mock } from "../types/mock";
2+
declare class IConfigFetcher {
3+
/**
4+
*
5+
* @param id Mock Id
6+
* @param kwargs Contains extra val required for storage fetching. Eg. uid in case of firebaseStorageService
7+
* @returns Return the Mock definition
8+
*/
9+
getMock: (id: string, kwargs?: any) => Mock | null;
10+
/**
11+
* Get the mock selector map. Used to easily select the mock to apply.
12+
* - Firebase stores this in a doc
13+
* - Local JSON will process and return this in realtime.
14+
*
15+
* {
16+
* mockId: {
17+
* route: "",
18+
* method: "",
19+
* }
20+
* }
21+
*/
22+
getMockSelectorMap: (kwargs?: any) => any;
23+
}
24+
export default IConfigFetcher;

build/main.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import IConfigFetcher from "./interfaces/configFetcherInterface";
2+
export declare const setupMockServer: (configFetcher: IConfigFetcher, pathPrefix?: string) => any;
3+
export declare const startMockServer: (configFetcher: IConfigFetcher) => void;

build/services/storageService.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import IConfigFetcher from "../interfaces/configFetcherInterface";
2+
declare class StorageService {
3+
configFetcher?: IConfigFetcher | null;
4+
constructor(configFetcher?: IConfigFetcher);
5+
setConfigFetcher: (configFetcher: IConfigFetcher) => void;
6+
getMockSelectorMap: (kwargs?: any) => Promise<any>;
7+
getMock: (id: string, kwargs?: any) => Promise<any>;
8+
}
9+
declare const storageService: StorageService;
10+
export default storageService;

build/test/dummy/mock1.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Mock } from "../../types/mock";
2+
export declare const dummyMock1: Mock;
3+
export declare const dummyMock2: Mock;
4+
export declare const getSelectorMap: () => any;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import IConfigFetcher from "../interfaces/configFetcherInterface";
2+
declare class FirebaseConfigFetcher implements IConfigFetcher {
3+
getMockSelectorMap: (kwargs?: any) => any;
4+
getMock: (id: string, kwargs?: any) => import("..").MockSchema | null;
5+
}
6+
declare const firebaseConfigFetcher: FirebaseConfigFetcher;
7+
export default firebaseConfigFetcher;

0 commit comments

Comments
 (0)