@gofreego/tsutils 0.1.25 → 0.1.26

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.
package/dist/index.d.mts CHANGED
@@ -6,53 +6,6 @@ import { Highlighter } from 'shiki';
6
6
 
7
7
  declare function NotFoundPage(): react_jsx_runtime.JSX.Element;
8
8
 
9
- interface HttpClientConfig {
10
- baseURL?: string;
11
- timeout?: number;
12
- headers?: Record<string, string>;
13
- onUnauthorized?: (error: HttpError) => void;
14
- }
15
- interface RequestConfig extends Omit<RequestInit, 'body'> {
16
- params?: Record<string, string | number | boolean>;
17
- data?: any;
18
- timeout?: number;
19
- }
20
- interface HttpResponse<T = any> {
21
- data: T;
22
- status: number;
23
- statusText: string;
24
- headers: Headers;
25
- }
26
- interface ErrorData {
27
- code: number;
28
- message: string;
29
- }
30
- interface HttpError extends Error {
31
- status?: number;
32
- statusText?: string;
33
- data?: ErrorData;
34
- }
35
-
36
- declare class HttpClient {
37
- private baseURL;
38
- private timeout;
39
- private defaultHeaders;
40
- private onUnauthorized?;
41
- constructor(config?: HttpClientConfig);
42
- private buildURL;
43
- private request;
44
- setOnUnauthorized(handler: (error: HttpError) => void): void;
45
- setDefaultHeader(key: string, value: string): void;
46
- removeDefaultHeader(key: string): void;
47
- getDefaultHeaders(): Record<string, string>;
48
- get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
49
- post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
50
- put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
51
- patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
52
- delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
53
- }
54
- declare function extractErrorMessage(error: any): string;
55
-
56
9
  interface User {
57
10
  id: string;
58
11
  uuid: string;
@@ -181,7 +134,7 @@ declare class SessionManager implements ISessionManager {
181
134
  private readonly key;
182
135
  private cache;
183
136
  private constructor();
184
- static getInstance(client: HttpClient): SessionManager;
137
+ static getInstance(): SessionManager;
185
138
  save(session: SignInResponse): void;
186
139
  patch(updates: Partial<SignInResponse>): void;
187
140
  clear(): void;
@@ -192,6 +145,53 @@ declare class SessionManager implements ISessionManager {
192
145
  isAuthenticated(): boolean;
193
146
  }
194
147
 
148
+ interface HttpClientConfig {
149
+ baseURL?: string;
150
+ timeout?: number;
151
+ headers?: Record<string, string>;
152
+ onUnauthorized?: (error: HttpError) => void;
153
+ }
154
+ interface RequestConfig extends Omit<RequestInit, 'body'> {
155
+ params?: Record<string, string | number | boolean>;
156
+ data?: any;
157
+ timeout?: number;
158
+ }
159
+ interface HttpResponse<T = any> {
160
+ data: T;
161
+ status: number;
162
+ statusText: string;
163
+ headers: Headers;
164
+ }
165
+ interface ErrorData {
166
+ code: number;
167
+ message: string;
168
+ }
169
+ interface HttpError extends Error {
170
+ status?: number;
171
+ statusText?: string;
172
+ data?: ErrorData;
173
+ }
174
+
175
+ declare class HttpClient {
176
+ private baseURL;
177
+ private timeout;
178
+ private defaultHeaders;
179
+ private onUnauthorized?;
180
+ constructor(config?: HttpClientConfig);
181
+ private buildURL;
182
+ private request;
183
+ setOnUnauthorized(handler: (error: HttpError) => void): void;
184
+ setDefaultHeader(key: string, value: string): void;
185
+ removeDefaultHeader(key: string): void;
186
+ getDefaultHeaders(): Record<string, string>;
187
+ get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
188
+ post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
189
+ put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
190
+ patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
191
+ delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
192
+ }
193
+ declare function extractErrorMessage(error: any): string;
194
+
195
195
  interface IAuthService {
196
196
  signIn(request: SignInRequest): Promise<SignInResponse>;
197
197
  refreshToken(request?: Partial<RefreshTokenRequest>): Promise<RefreshTokenResponse>;
package/dist/index.d.ts CHANGED
@@ -6,53 +6,6 @@ import { Highlighter } from 'shiki';
6
6
 
7
7
  declare function NotFoundPage(): react_jsx_runtime.JSX.Element;
8
8
 
9
- interface HttpClientConfig {
10
- baseURL?: string;
11
- timeout?: number;
12
- headers?: Record<string, string>;
13
- onUnauthorized?: (error: HttpError) => void;
14
- }
15
- interface RequestConfig extends Omit<RequestInit, 'body'> {
16
- params?: Record<string, string | number | boolean>;
17
- data?: any;
18
- timeout?: number;
19
- }
20
- interface HttpResponse<T = any> {
21
- data: T;
22
- status: number;
23
- statusText: string;
24
- headers: Headers;
25
- }
26
- interface ErrorData {
27
- code: number;
28
- message: string;
29
- }
30
- interface HttpError extends Error {
31
- status?: number;
32
- statusText?: string;
33
- data?: ErrorData;
34
- }
35
-
36
- declare class HttpClient {
37
- private baseURL;
38
- private timeout;
39
- private defaultHeaders;
40
- private onUnauthorized?;
41
- constructor(config?: HttpClientConfig);
42
- private buildURL;
43
- private request;
44
- setOnUnauthorized(handler: (error: HttpError) => void): void;
45
- setDefaultHeader(key: string, value: string): void;
46
- removeDefaultHeader(key: string): void;
47
- getDefaultHeaders(): Record<string, string>;
48
- get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
49
- post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
50
- put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
51
- patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
52
- delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
53
- }
54
- declare function extractErrorMessage(error: any): string;
55
-
56
9
  interface User {
57
10
  id: string;
58
11
  uuid: string;
@@ -181,7 +134,7 @@ declare class SessionManager implements ISessionManager {
181
134
  private readonly key;
182
135
  private cache;
183
136
  private constructor();
184
- static getInstance(client: HttpClient): SessionManager;
137
+ static getInstance(): SessionManager;
185
138
  save(session: SignInResponse): void;
186
139
  patch(updates: Partial<SignInResponse>): void;
187
140
  clear(): void;
@@ -192,6 +145,53 @@ declare class SessionManager implements ISessionManager {
192
145
  isAuthenticated(): boolean;
193
146
  }
194
147
 
148
+ interface HttpClientConfig {
149
+ baseURL?: string;
150
+ timeout?: number;
151
+ headers?: Record<string, string>;
152
+ onUnauthorized?: (error: HttpError) => void;
153
+ }
154
+ interface RequestConfig extends Omit<RequestInit, 'body'> {
155
+ params?: Record<string, string | number | boolean>;
156
+ data?: any;
157
+ timeout?: number;
158
+ }
159
+ interface HttpResponse<T = any> {
160
+ data: T;
161
+ status: number;
162
+ statusText: string;
163
+ headers: Headers;
164
+ }
165
+ interface ErrorData {
166
+ code: number;
167
+ message: string;
168
+ }
169
+ interface HttpError extends Error {
170
+ status?: number;
171
+ statusText?: string;
172
+ data?: ErrorData;
173
+ }
174
+
175
+ declare class HttpClient {
176
+ private baseURL;
177
+ private timeout;
178
+ private defaultHeaders;
179
+ private onUnauthorized?;
180
+ constructor(config?: HttpClientConfig);
181
+ private buildURL;
182
+ private request;
183
+ setOnUnauthorized(handler: (error: HttpError) => void): void;
184
+ setDefaultHeader(key: string, value: string): void;
185
+ removeDefaultHeader(key: string): void;
186
+ getDefaultHeaders(): Record<string, string>;
187
+ get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
188
+ post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
189
+ put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
190
+ patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
191
+ delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
192
+ }
193
+ declare function extractErrorMessage(error: any): string;
194
+
195
195
  interface IAuthService {
196
196
  signIn(request: SignInRequest): Promise<SignInResponse>;
197
197
  refreshToken(request?: Partial<RefreshTokenRequest>): Promise<RefreshTokenResponse>;
package/dist/index.js CHANGED
@@ -1428,14 +1428,14 @@ function formatDate(date, options = {
1428
1428
  // src/auth/sessionManager.ts
1429
1429
  var SESSION_KEY = "session_details";
1430
1430
  var SessionManager = class _SessionManager {
1431
- constructor(client, key = SESSION_KEY) {
1431
+ constructor(key = SESSION_KEY) {
1432
1432
  // private readonly client: HttpClient
1433
1433
  this.cache = null;
1434
1434
  this.key = key;
1435
1435
  }
1436
- static getInstance(client) {
1436
+ static getInstance() {
1437
1437
  if (!_SessionManager.instance) {
1438
- _SessionManager.instance = new _SessionManager(client);
1438
+ _SessionManager.instance = new _SessionManager();
1439
1439
  }
1440
1440
  return _SessionManager.instance;
1441
1441
  }
@@ -1480,7 +1480,7 @@ var BASE_URL = "/openauth/v1";
1480
1480
  var AuthService = class _AuthService {
1481
1481
  constructor(client) {
1482
1482
  this.client = client;
1483
- this.sessionManager = SessionManager.getInstance(client);
1483
+ this.sessionManager = SessionManager.getInstance();
1484
1484
  }
1485
1485
  static getInstance(client) {
1486
1486
  if (!_AuthService.instance) {