@cloudbase/types 1.1.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'>;
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;
@@ -37,48 +39,48 @@ export interface IUserInfo {
37
39
  province?: string;
38
40
  city?: string;
39
41
  }
40
- 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>;
42
+ export interface IUser extends 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
- config:ICloudbaseConfig;
62
- loginType:string;
63
+ config: ICloudbaseConfig;
64
+ loginType: string;
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
- type IProvider = new(...args:any[]) => any;
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
@@ -2,12 +2,13 @@ import { CloudbaseAdapter, SDKAdapterInterface } from '@cloudbase/adapter-interf
2
2
  import { ICloudbaseComponent, ICloudbaseHook } from "./component";
3
3
  import { ICloudbaseRequest } from "./request";
4
4
  import { ICloudbaseCache } from "./cache";
5
+ import { ICloudbaseAuth } from './auth'
5
6
 
6
7
  export type Persistence = 'local' | 'session' | 'none';
7
8
 
8
- export type KV<T> = {
9
+ export interface KV<T> {
9
10
  [key: string]: T;
10
- };
11
+ }
11
12
 
12
13
  export interface ICloudbaseAppSecret {
13
14
  appAccessKeyId: string;
@@ -20,32 +21,39 @@ export interface ICloudbaseConfig {
20
21
  timeout?: number;
21
22
  persistence?: Persistence;
22
23
  appSecret?: ICloudbaseAppSecret;
24
+ oauthClient?: any
23
25
  appSign?: string;
24
- debug?:boolean;
26
+ debug?: boolean;
27
+ _fromApp?: ICloudbase;
28
+ clientId?: string
29
+ oauthInstance?: any;
25
30
  }
26
31
  // 可更新的配置字段
27
- export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence'|'region'|'debug'>;
32
+ export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence' | 'region' | 'debug'>;
28
33
 
29
34
  export interface ICloudbaseExtension {
30
35
  name: string;
31
- invoke(opts:any,app:ICloudbase):Promise<any>;
36
+ invoke: (opts: any, app: ICloudbase) => Promise<any>;
32
37
  }
33
38
 
34
- export interface ICloudbase{
35
- config:ICloudbaseConfig;
36
- platform:ICloudbasePlatformInfo;
37
- cache:ICloudbaseCache;
38
- request:ICloudbaseRequest;
39
- localCache:ICloudbaseCache;
40
- init(config: ICloudbaseConfig):ICloudbase;
41
- updateConfig(config: ICloudbaseUpgradedConfig):void;
42
- registerExtension(ext:ICloudbaseExtension):void;
43
- invokeExtension(name:string,opts:any):Promise<any>;
44
- useAdapters(adapters: CloudbaseAdapter|CloudbaseAdapter[]):void;
45
- registerComponent(component:ICloudbaseComponent):void;
46
- registerHook(hook:ICloudbaseHook):void;
47
- registerVersion(version:string):void;
48
- fire?(...args:any[]):void;
39
+ export interface ICloudbase {
40
+ config: ICloudbaseConfig;
41
+ platform: ICloudbasePlatformInfo;
42
+ cache: ICloudbaseCache;
43
+ request: ICloudbaseRequest;
44
+ oauthClient: any;
45
+ localCache: ICloudbaseCache;
46
+ authInstance?: ICloudbaseAuth;
47
+ oauthInstance?: any;
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;
49
57
  }
50
58
 
51
59
  export interface ICloudbasePlatformInfo {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/types",
3
- "version": "1.1.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": "c406b2e966b705b12e552cc9a8ef569b732b1118"
48
+ "gitHead": "9ab9ea4322a548cd981d5fe747b6dee911272a6d"
49
49
  }
package/request.d.ts CHANGED
@@ -1,26 +1,28 @@
1
- import { IRequestOptions, ResponseObject, IUploadRequestOptions } from '@cloudbase/adapter-interface';
2
- import { ICloudbaseConfig,KV } from ".";
1
+ import {
2
+ IRequestOptions, IUploadRequestOptions, ResponseObject
3
+ } from '@cloudbase/adapter-interface';
4
+
5
+ import { ICloudbaseConfig, KV } from '.';
3
6
 
4
7
  export interface IGetAccessTokenResult {
5
8
  accessToken: string;
6
9
  accessTokenExpire: number;
7
10
  }
8
11
 
9
- export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env'|'region'|'timeout'|'appSecret'|'appSign'>;
12
+ export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'timeout' | 'appSecret' | 'appSign' | 'oauthClient' | '_fromApp'>;
10
13
 
11
- export type IAppendedRequestInfo = {
14
+ export interface IAppendedRequestInfo {
12
15
  data: KV<any>;
13
16
  headers: KV<string>;
14
17
  }
15
- export interface IRequestBeforeHook {
16
- (...args: any[]): IAppendedRequestInfo;
17
- }
18
+ export type IRequestBeforeHook = (...args: any[]) => IAppendedRequestInfo;
18
19
  export interface ICloudbaseRequest {
19
- post(options: IRequestOptions): Promise<ResponseObject>;
20
- upload(options: IUploadRequestOptions): Promise<ResponseObject>;
21
- download(options: IRequestOptions): Promise<ResponseObject>;
22
- refreshAccessToken(): Promise<IGetAccessTokenResult>;
23
- getAccessToken(): Promise<IGetAccessTokenResult>;
24
- request(action: string, params: KV<any>, options?: KV<any>): Promise<ResponseObject>;
25
- send(action: string, data: KV<any>): Promise<any>;
20
+ // fetch: (urlOrPath: string, init?: RequestInit) => Promise<Response>;
21
+ post: (options: IRequestOptions) => Promise<ResponseObject>;
22
+ upload: (options: IUploadRequestOptions) => Promise<ResponseObject>;
23
+ download: (options: IRequestOptions) => Promise<ResponseObject>;
24
+ // refreshAccessToken: () => Promise<IGetAccessTokenResult>;
25
+ // getAccessToken: () => Promise<IGetAccessTokenResult>;
26
+ request: (action: string, params: KV<any>, options?: KV<any>) => Promise<ResponseObject>;
27
+ send: (action: string, data: KV<any>) => Promise<any>;
26
28
  }