lambder 1.0.36 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,21 @@
1
1
  import ResolverLight, { ResolverResponse } from "./ResolverLight";
2
- interface IResolverMethods {
3
- raw(param: {
4
- statusCode: number;
5
- isBase64Encoded?: boolean;
6
- body: null | string;
7
- multiValueHeaders: {
8
- [key: string]: string[];
9
- };
10
- }): ResolverResponse;
11
- json(data: {
12
- [key: string]: any;
13
- }, headers?: {
14
- [key: string]: string | string[];
15
- }): ResolverResponse;
16
- xml(data: string): ResolverResponse;
17
- html(data: string, headers?: {
18
- [key: string]: string | string[];
19
- }): ResolverResponse;
20
- status301(url: string, headers?: {
21
- [key: string]: string | string[];
22
- }): ResolverResponse;
23
- status404(data: string, headers?: {
24
- [key: string]: string | string[];
25
- }): ResolverResponse;
26
- cors(): ResolverResponse;
27
- fileBase64(fileBase64: string, mimeType: string, headers?: {
28
- [key: string]: string | string[];
29
- }): ResolverResponse;
30
- file(filePath: string, headers?: {
31
- [key: string]: string | string[];
32
- }): ResolverResponse;
33
- api({ payload, versionExpired, sessionExpired, notAuthorized, message, errorMessage, ...other }: {
34
- payload?: any;
35
- versionExpired?: boolean;
36
- sessionExpired?: boolean;
37
- notAuthorized?: boolean;
38
- message?: any;
39
- errorMessage?: any;
40
- }, headers?: {
41
- [key: string]: string | string[];
42
- }): ResolverResponse;
2
+ type MethodType<T, M extends keyof T> = T[M] extends (...args: any[]) => any ? T[M] : never;
3
+ interface DieResolverMethods {
4
+ raw: MethodType<ResolverLight, 'raw'>;
5
+ json: MethodType<ResolverLight, 'json'>;
6
+ xml: MethodType<ResolverLight, 'xml'>;
7
+ html: MethodType<ResolverLight, 'html'>;
8
+ status301: MethodType<ResolverLight, 'status301'>;
9
+ status404: MethodType<ResolverLight, 'status404'>;
10
+ cors: MethodType<ResolverLight, 'cors'>;
11
+ fileBase64: MethodType<ResolverLight, 'fileBase64'>;
12
+ file: MethodType<ResolverLight, 'file'>;
13
+ api: MethodType<ResolverLight, 'api'>;
43
14
  }
44
15
  export default class Resolver extends ResolverLight {
45
16
  resolve: (renderResult: ResolverResponse) => void;
46
17
  reject: (err: Error) => void;
47
- die: IResolverMethods;
18
+ die: DieResolverMethods;
48
19
  constructor({ isCorsEnabled, publicPath, apiVersion, resolve, reject }: {
49
20
  isCorsEnabled: boolean;
50
21
  publicPath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Resolver.ts CHANGED
@@ -1,43 +1,24 @@
1
1
  import ResolverLight, { ResolverResponse } from "./ResolverLight";
2
2
 
3
-
4
- interface IResolverMethods {
5
- raw(param: {
6
- statusCode: number,
7
- isBase64Encoded?: boolean,
8
- body: null | string,
9
- multiValueHeaders: { [key: string]: string[] },
10
- }): ResolverResponse;
11
- json(data: { [key: string]: any }, headers?: { [key: string]: string | string[] }): ResolverResponse;
12
- xml(data: string): ResolverResponse;
13
- html(data: string, headers?: { [key: string]: string | string[] }): ResolverResponse;
14
- status301(url: string, headers?: { [key: string]: string | string[] }): ResolverResponse;
15
- status404(data: string, headers?: { [key: string]: string | string[] }): ResolverResponse;
16
- cors(): ResolverResponse;
17
- fileBase64(fileBase64: string, mimeType: string, headers?: { [key: string]: string | string[] }): ResolverResponse;
18
- file(filePath: string, headers?: { [key: string]: string | string[] }): ResolverResponse;
19
- api({
20
- payload,
21
- versionExpired, sessionExpired, notAuthorized,
22
- message, errorMessage,
23
- ...other
24
- }: {
25
- payload?: any;
26
- versionExpired?: boolean;
27
- sessionExpired?: boolean;
28
- notAuthorized?: boolean;
29
- message?: any;
30
- errorMessage?: any;
31
- },
32
- headers?: { [key:string]: string|string[] }
33
- ): ResolverResponse;
3
+ type MethodType<T, M extends keyof T> = T[M] extends (...args: any[]) => any ? T[M] : never;
4
+
5
+ interface DieResolverMethods {
6
+ raw: MethodType<ResolverLight, 'raw'>;
7
+ json: MethodType<ResolverLight, 'json'>;
8
+ xml: MethodType<ResolverLight, 'xml'>;
9
+ html: MethodType<ResolverLight, 'html'>;
10
+ status301: MethodType<ResolverLight, 'status301'>;
11
+ status404: MethodType<ResolverLight, 'status404'>;
12
+ cors: MethodType<ResolverLight, 'cors'>;
13
+ fileBase64: MethodType<ResolverLight, 'fileBase64'>;
14
+ file: MethodType<ResolverLight, 'file'>;
15
+ api: MethodType<ResolverLight, 'api'>;
34
16
  }
35
17
 
36
-
37
18
  export default class Resolver extends ResolverLight {
38
19
  public resolve: (renderResult: ResolverResponse) => void;
39
20
  public reject: (err: Error) => void;
40
- public die: IResolverMethods;
21
+ public die: DieResolverMethods;
41
22
 
42
23
  constructor(
43
24
  { isCorsEnabled, publicPath, apiVersion, resolve, reject }: