lambder 1.0.104 → 1.0.106

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.
@@ -48,7 +48,7 @@ export default class LambderCaller {
48
48
  fetchStartedHandler?: FetchStartEventHandler;
49
49
  fetchEndedHandler?: FetchEndEventHandler;
50
50
  });
51
- apiRaw<T>(apiName: string, payload?: any, options?: {
51
+ apiRaw<T = any>(apiName: string, payload?: any, options?: {
52
52
  headers?: Record<string, any>;
53
53
  versionExpiredHandler?: VoidFunction;
54
54
  sessionExpiredHandler?: VoidFunction;
@@ -58,7 +58,7 @@ export default class LambderCaller {
58
58
  errorHandler?: ErrorHandler;
59
59
  fetchStartedHandler?: FetchStartEventHandler;
60
60
  fetchEndedHandler?: FetchEndEventHandler;
61
- }): Promise<LambderApiResponse<T> | null>;
62
- api<T>(...params: Parameters<typeof LambderCaller.prototype.apiRaw>): Promise<T | null>;
61
+ }): Promise<LambderApiResponse<T> | null | undefined>;
62
+ api<T = any>(...params: Parameters<typeof LambderCaller.prototype.apiRaw>): Promise<T | null | undefined>;
63
63
  }
64
64
  export {};
@@ -116,8 +116,6 @@ export default class LambderCaller {
116
116
  // Use the same type for api but adjust the return type
117
117
  async api(...params) {
118
118
  const result = await this.apiRaw(...params);
119
- if (!result)
120
- return null;
121
- return result.payload ?? null;
119
+ return result?.payload;
122
120
  }
123
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -81,7 +81,7 @@ export default class LambderCaller {
81
81
 
82
82
  };
83
83
 
84
- async apiRaw<T>(apiName: string, payload?: any, options?: {
84
+ async apiRaw<T=any>(apiName: string, payload?: any, options?: {
85
85
  headers?: Record<string, any>
86
86
  versionExpiredHandler?: VoidFunction,
87
87
  sessionExpiredHandler?: VoidFunction,
@@ -91,7 +91,7 @@ export default class LambderCaller {
91
91
  errorHandler?: ErrorHandler,
92
92
  fetchStartedHandler?: FetchStartEventHandler,
93
93
  fetchEndedHandler?: FetchEndEventHandler,
94
- }): Promise<LambderApiResponse<T>|null>{
94
+ }): Promise<LambderApiResponse<T>|null|undefined>{
95
95
  const headers = options?.headers;
96
96
  const fetchTracker: FetchTracker = { apiName, done: false, fetchEndCalled: false };
97
97
  try {
@@ -170,10 +170,9 @@ export default class LambderCaller {
170
170
  };
171
171
 
172
172
  // Use the same type for api but adjust the return type
173
- async api<T>(...params: Parameters<typeof LambderCaller.prototype.apiRaw>): Promise<T|null> {
173
+ async api<T=any>(...params: Parameters<typeof LambderCaller.prototype.apiRaw>): Promise<T|null|undefined> {
174
174
  const result = await this.apiRaw<T>(...params);
175
- if (!result) return null;
176
- return result.payload ?? null;
175
+ return result?.payload;
177
176
  }
178
177
 
179
178
  }