@nano-lib/util 1.1.10 → 1.1.12

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.
@@ -60,9 +60,15 @@ export interface LoadingInstanceType {
60
60
  forceHide(): void;
61
61
  isLoading(): boolean;
62
62
  }
63
+ export interface TokenKeys {
64
+ TOKEN_KEY?: string;
65
+ REFRESH_TOKEN_KEY?: string;
66
+ TOKEN_EXPIRES_KEY?: string;
67
+ }
63
68
  export interface RequestConstructorOptions<T extends string, U extends AnyObj> extends RequestConfig {
64
69
  toastInstance: ToastInstanceType<T, U>;
65
70
  loadingInstance?: LoadingInstanceType;
71
+ tokenKeys?: TokenKeys;
66
72
  }
67
73
  export interface BaseResponse<T = any> {
68
74
  code: number;
@@ -22,6 +22,8 @@ export declare function getSystemConfig<T extends AnyObj, U>(options: {
22
22
  baseUrl: Nullable<string> | Fn<Nullable<string>>;
23
23
  initUrl: string;
24
24
  initParams?: T;
25
+ defaultHttpsPort?: string;
26
+ defaultHttpPort?: string;
25
27
  initFn: (initUrl: string, initParams: T) => Promise<U>;
26
28
  }): Promise<boolean | U>;
27
29
  /**
@@ -0,0 +1,15 @@
1
+ import { default as Request } from './index';
2
+ import { PromiseResponse, PromiseResponseList } from '../../types/request';
3
+ import { AnyObj } from '../../types';
4
+ export default class CommonRequest {
5
+ private controllerUrl;
6
+ private controllerType;
7
+ private requestInstance;
8
+ constructor(controllerUrl: string, requestInstance: Request);
9
+ detail: <T extends AnyObj>(id: string | number) => PromiseResponse<T>;
10
+ list: <T extends AnyObj>(params?: AnyObj) => PromiseResponseList<T>;
11
+ submitData: (action: "add" | "edit", data: AnyObj) => PromiseResponse;
12
+ add: (data: AnyObj) => PromiseResponse;
13
+ edit: (data: AnyObj) => PromiseResponse;
14
+ del: (ids: string) => PromiseResponse;
15
+ }
@@ -1,10 +1,11 @@
1
- import { PromiseResponse, TokenInfo } from '../../types/request';
1
+ import { PromiseResponse, TokenInfo, TokenKeys } from '../../types/request';
2
2
  export default class TokenManager {
3
3
  private TOKEN_KEY;
4
4
  private REFRESH_TOKEN_KEY;
5
5
  private TOKEN_EXPIRES_KEY;
6
6
  private isRefreshing;
7
7
  private refreshSubscribers;
8
+ constructor(option?: TokenKeys);
8
9
  setToken({ accessToken, refreshToken, expiresIn }: TokenInfo): void;
9
10
  getAccessToken(): string;
10
11
  getRefreshToken(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-lib/util",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "Custom utility functions for the nano library",
5
5
  "author": "xylo",
6
6
  "license": "MIT",