@cloudbase/types 1.2.3-alpha.0 → 2.0.0-alpha.0

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/auth.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { ICloudbaseConfig, KV, ICloudbase } from '.';
2
2
 
3
- export type ICloudbaseAuthConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'persistence' | 'debug' | '_fromApp'>;
3
+ export type ICloudbaseAuthConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'persistence' | 'debug' | '_fromApp' | 'oauthInstance'>;
4
4
 
5
5
  export interface IAccessTokenInfo {
6
6
  accessToken: string;
7
7
  env: string;
8
8
  }
9
9
  export interface ICredential {
10
- refreshToken: string;
10
+ // refreshToken: string;
11
11
  accessToken?: string;
12
12
  accessTokenExpire?: string;
13
13
  }
14
14
  export interface IAuthProvider {
15
- signInWithRedirect(): any;
15
+ signInWithRedirect: () => any;
16
16
  }
17
17
  export interface IUserInfo {
18
18
  uid?: string;
@@ -23,10 +23,12 @@ export interface IUserInfo {
23
23
  unionId?: string;
24
24
  qqMiniOpenId?: string;
25
25
  customUserId?: string;
26
- nickName?: string;
26
+ // nickName?: string;
27
+ name?: string;
27
28
  gender?: string;
28
29
  avatarUrl?: string;
29
30
  email?: string;
31
+ username?: string;
30
32
  hasPassword?: boolean;
31
33
  location?: {
32
34
  country?: string;
@@ -38,24 +40,24 @@ export interface IUserInfo {
38
40
  city?: string;
39
41
  }
40
42
  export interface IUser extends IUserInfo {
41
- checkLocalInfo(): void;
42
- checkLocalInfoAsync(): Promise<void>;
43
- linkWithTicket(ticket: string): Promise<void>;
44
- linkWithRedirect(provider: IAuthProvider): void;
45
- getLinkedUidList(): Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
46
- setPrimaryUid(uid: string): Promise<void>;
47
- unlink(loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION'): Promise<void>;
48
- update(userinfo: IUserInfo): Promise<void>;
49
- refresh(): Promise<IUserInfo>;
43
+ checkLocalInfo: () => void;
44
+ checkLocalInfoAsync: () => Promise<void>;
45
+ linkWithTicket?: (ticket: string) => Promise<void>;
46
+ linkWithRedirect?: (provider: IAuthProvider) => void;
47
+ getLinkedUidList?: () => Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
48
+ setPrimaryUid?: (uid: string) => Promise<void>;
49
+ unlink?: (loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION') => Promise<void>;
50
+ update: (userinfo: IUserInfo) => Promise<void>;
51
+ refresh: () => Promise<IUserInfo>;
50
52
  }
51
53
  export interface ILoginState {
52
- credential: ICredential;
54
+ // credential: ICredential;
53
55
  user: IUser;
54
- isAnonymousAuth: boolean;
55
- isCustomAuth: boolean;
56
- isWeixinAuth: boolean;
57
- isUsernameAuth: boolean;
58
- loginType: string;
56
+ // isAnonymousAuth: boolean;
57
+ // isCustomAuth: boolean;
58
+ // isWeixinAuth: boolean;
59
+ // isUsernameAuth: boolean;
60
+ // loginType: string;
59
61
  }
60
62
  export interface ICloudbaseAuth {
61
63
  config: ICloudbaseConfig;
@@ -63,22 +65,22 @@ export interface ICloudbaseAuth {
63
65
  weixinAuthProvider: any;
64
66
  anonymousAuthProvider: any;
65
67
  customAuthProvider: any;
66
- getAccessToken(): IAccessTokenInfo;
67
- getLoginState(): Promise<ILoginState | null>;
68
- hasLoginState(): Promise<ILoginState | null>;
69
- getUserInfo(): Promise<any>;
70
- getAuthHeader(): Promise<KV<string>>;
71
- onLoginStateChanged(callback: Function): void;
72
- onLoginStateExpired(callback: Function): void;
73
- onAccessTokenRefreshed(callback: Function): void;
74
- onAnonymousConverted(callback: Function): void;
75
- onLoginTypeChanged(callback: Function): void;
76
- shouldRefreshAccessToken(hook: Function): void;
68
+ getAccessToken: () => IAccessTokenInfo;
69
+ getLoginState: () => Promise<ILoginState | null>;
70
+ hasLoginState: () => Promise<ILoginState | null>;
71
+ getUserInfo: () => Promise<any>;
72
+ getAuthHeader: () => Promise<KV<string>>;
73
+ onLoginStateChanged: (callback: Function) => void;
74
+ onLoginStateExpired: (callback: Function) => void;
75
+ onAccessTokenRefreshed: (callback: Function) => void;
76
+ onAnonymousConverted: (callback: Function) => void;
77
+ onLoginTypeChanged: (callback: Function) => void;
78
+ shouldRefreshAccessToken: (hook: Function) => void;
77
79
  }
78
80
 
79
81
  type IProvider = new (...args: any[]) => any;
80
82
 
81
83
  export interface ICloudbaseAuthModule {
82
- registerAuth(app: ICloudbase): void,
83
- registerProvider(name: string, provider: IProvider): void;
84
+ registerAuth: (app: ICloudbase) => void,
85
+ registerProvider: (name: string, provider: IProvider) => void;
84
86
  }
package/cache.d.ts CHANGED
@@ -9,18 +9,18 @@ export type ICacheConfig = Pick < ICloudbaseConfig, 'debug' | 'persistence' > &
9
9
  export interface ICloudbaseCache {
10
10
  keys:KV<string>;
11
11
  mode: 'async' | 'sync';
12
-
13
- setStore(key: string, value: any, version?: string):void;
14
- setStoreAsync(key: string, value: any, version?: string):Promise<void>;
15
12
 
16
- getStore(key: string, version?: string):any;
17
- getStoreAsync(key: string, version?: string):Promise<any>;
18
-
19
- removeStore(key:string):void;
20
- removeStoreAsync(key:string):Promise<void>;
21
-
22
- updatePersistence?(persistence:string):void;
23
- updatePersistenceAsync?(persistence:string):Promise<void>;
13
+ setStore: (key: string, value: any, version?: string) => void;
14
+ setStoreAsync: (key: string, value: any, version?: string) => Promise<void>;
15
+
16
+ getStore: (key: string, version?: string) => any;
17
+ getStoreAsync: (key: string, version?: string) => Promise<any>;
24
18
 
25
- clear?():void;
19
+ removeStore: (key:string) => void;
20
+ removeStoreAsync: (key:string) => Promise<void>;
21
+
22
+ updatePersistence?: (persistence:string) => void;
23
+ updatePersistenceAsync?: (persistence:string) => Promise<void>;
24
+
25
+ clear?: () => void;
26
26
  }
package/index.d.ts CHANGED
@@ -6,9 +6,9 @@ import { ICloudbaseAuth } from './auth'
6
6
 
7
7
  export type Persistence = 'local' | 'session' | 'none';
8
8
 
9
- export type KV<T> = {
9
+ export interface KV<T> {
10
10
  [key: string]: T;
11
- };
11
+ }
12
12
 
13
13
  export interface ICloudbaseAppSecret {
14
14
  appAccessKeyId: string;
@@ -24,14 +24,16 @@ export interface ICloudbaseConfig {
24
24
  oauthClient?: any
25
25
  appSign?: string;
26
26
  debug?: boolean;
27
- _fromApp?: ICloudbase
27
+ _fromApp?: ICloudbase;
28
+ clientId?: string
29
+ oauthInstance?: any;
28
30
  }
29
31
  // 可更新的配置字段
30
32
  export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence' | 'region' | 'debug'>;
31
33
 
32
34
  export interface ICloudbaseExtension {
33
35
  name: string;
34
- invoke(opts: any, app: ICloudbase): Promise<any>;
36
+ invoke: (opts: any, app: ICloudbase) => Promise<any>;
35
37
  }
36
38
 
37
39
  export interface ICloudbase {
@@ -43,15 +45,15 @@ export interface ICloudbase {
43
45
  localCache: ICloudbaseCache;
44
46
  authInstance?: ICloudbaseAuth;
45
47
  oauthInstance?: any;
46
- init(config: ICloudbaseConfig): ICloudbase;
47
- updateConfig(config: ICloudbaseUpgradedConfig): void;
48
- registerExtension(ext: ICloudbaseExtension): void;
49
- invokeExtension(name: string, opts: any): Promise<any>;
50
- useAdapters(adapters: CloudbaseAdapter | CloudbaseAdapter[]): void;
51
- registerComponent(component: ICloudbaseComponent): void;
52
- registerHook(hook: ICloudbaseHook): void;
53
- registerVersion(version: string): void;
54
- fire?(...args: any[]): void;
48
+ init: (config: ICloudbaseConfig) => ICloudbase;
49
+ updateConfig: (config: ICloudbaseUpgradedConfig) => void;
50
+ registerExtension: (ext: ICloudbaseExtension) => void;
51
+ invokeExtension: (name: string, opts: any) => Promise<any>;
52
+ useAdapters: (adapters: CloudbaseAdapter | CloudbaseAdapter[]) => void;
53
+ registerComponent: (component: ICloudbaseComponent) => void;
54
+ registerHook: (hook: ICloudbaseHook) => void;
55
+ registerVersion: (version: string) => void;
56
+ fire?: (...args: any[]) => void;
55
57
  }
56
58
 
57
59
  export interface ICloudbasePlatformInfo {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/types",
3
- "version": "1.2.3-alpha.0",
3
+ "version": "2.0.0-alpha.0",
4
4
  "description": "cloudbase javascript sdk types",
5
5
  "files": [
6
6
  "index.js",
@@ -45,5 +45,5 @@
45
45
  "eslint-config-alloy": "^3.8.0",
46
46
  "typescript": "^4.0.2"
47
47
  },
48
- "gitHead": "eb161dd3c79b90a95a877984bf7c07cdb4563077"
48
+ "gitHead": "9ab9ea4322a548cd981d5fe747b6dee911272a6d"
49
49
  }
package/request.d.ts CHANGED
@@ -17,12 +17,12 @@ export interface IAppendedRequestInfo {
17
17
  }
18
18
  export type IRequestBeforeHook = (...args: any[]) => IAppendedRequestInfo;
19
19
  export interface ICloudbaseRequest {
20
- fetch: (urlOrPath: string, init?: RequestInit) => Promise<Response>;
20
+ // fetch: (urlOrPath: string, init?: RequestInit) => Promise<Response>;
21
21
  post: (options: IRequestOptions) => Promise<ResponseObject>;
22
22
  upload: (options: IUploadRequestOptions) => Promise<ResponseObject>;
23
23
  download: (options: IRequestOptions) => Promise<ResponseObject>;
24
- refreshAccessToken: () => Promise<IGetAccessTokenResult>;
25
- getAccessToken: () => Promise<IGetAccessTokenResult>;
24
+ // refreshAccessToken: () => Promise<IGetAccessTokenResult>;
25
+ // getAccessToken: () => Promise<IGetAccessTokenResult>;
26
26
  request: (action: string, params: KV<any>, options?: KV<any>) => Promise<ResponseObject>;
27
27
  send: (action: string, data: KV<any>) => Promise<any>;
28
28
  }