@cloudbase/types 1.2.3-alpha.0 → 1.8.2

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,6 +1,6 @@
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'>;
4
4
 
5
5
  export interface IAccessTokenInfo {
6
6
  accessToken: string;
@@ -37,14 +37,14 @@ export interface IUserInfo {
37
37
  province?: string;
38
38
  city?: string;
39
39
  }
40
- export interface IUser extends IUserInfo {
40
+ export interface IUser extends IUserInfo{
41
41
  checkLocalInfo(): void;
42
42
  checkLocalInfoAsync(): Promise<void>;
43
43
  linkWithTicket(ticket: string): Promise<void>;
44
44
  linkWithRedirect(provider: IAuthProvider): void;
45
45
  getLinkedUidList(): Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
46
46
  setPrimaryUid(uid: string): Promise<void>;
47
- unlink(loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION'): Promise<void>;
47
+ unlink(loginType: 'CUSTOM'| 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION'): Promise<void>;
48
48
  update(userinfo: IUserInfo): Promise<void>;
49
49
  refresh(): Promise<IUserInfo>;
50
50
  }
@@ -64,8 +64,8 @@ export interface ICloudbaseAuth {
64
64
  anonymousAuthProvider: any;
65
65
  customAuthProvider: any;
66
66
  getAccessToken(): IAccessTokenInfo;
67
- getLoginState(): Promise<ILoginState | null>;
68
- hasLoginState(): Promise<ILoginState | null>;
67
+ getLoginState(): Promise<ILoginState|null>;
68
+ hasLoginState(): Promise<ILoginState|null>;
69
69
  getUserInfo(): Promise<any>;
70
70
  getAuthHeader(): Promise<KV<string>>;
71
71
  onLoginStateChanged(callback: Function): void;
@@ -76,9 +76,9 @@ export interface ICloudbaseAuth {
76
76
  shouldRefreshAccessToken(hook: Function): void;
77
77
  }
78
78
 
79
- type IProvider = new (...args: any[]) => any;
79
+ type IProvider = new(...args: any[]) => any;
80
80
 
81
81
  export interface ICloudbaseAuthModule {
82
82
  registerAuth(app: ICloudbase): void,
83
83
  registerProvider(name: string, provider: IProvider): void;
84
- }
84
+ }
package/cache.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICloudbasePlatformInfo, KV,ICloudbaseConfig } from ".";
1
+ import { ICloudbasePlatformInfo, KV, ICloudbaseConfig } from '.';
2
2
 
3
3
  export type ICacheConfig = Pick < ICloudbaseConfig, 'debug' | 'persistence' > & {
4
4
  platformInfo?: ICloudbasePlatformInfo;
@@ -7,20 +7,20 @@ export type ICacheConfig = Pick < ICloudbaseConfig, 'debug' | 'persistence' > &
7
7
  };
8
8
 
9
9
  export interface ICloudbaseCache {
10
- keys:KV<string>;
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>;
24
-
25
- clear?():void;
26
- }
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>;
18
+
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
+ }
package/component.d.ts CHANGED
@@ -14,4 +14,4 @@ export interface ICloudbaseComponent {
14
14
  export interface ICloudbaseHook {
15
15
  entity: any;
16
16
  target: string;
17
- }
17
+ }
package/database.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit'
2
- export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update'
1
+ export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
2
+ export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
3
3
 
4
4
  export interface ISingleDBEvent {
5
5
  id: number
@@ -28,4 +28,4 @@ export interface IServiceContext {
28
28
  // identifiers: IRuntimeIdentifiers
29
29
  // debug: boolean
30
30
  env?: string
31
- }
31
+ }
package/events.d.ts CHANGED
@@ -2,12 +2,12 @@ export interface Listeners {
2
2
  [key: string]: Function[];
3
3
  }
4
4
  export interface ICloudbaseEvent {
5
- name:string;
5
+ name: string;
6
6
  target: any;
7
- data:any;
7
+ data: any;
8
8
  }
9
9
  export interface ICloudbaseEventEmitter {
10
10
  on(name: string, listener: Function): this;
11
11
  off(name: string, listener: Function): this;
12
12
  fire(event: string | ICloudbaseEvent, data?: any): this;
13
- }
13
+ }
package/functions.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { KV } from ".";
1
+ import { KV } from '.';
2
2
 
3
3
  export interface ICallFunctionOptions {
4
4
  name: string;
@@ -13,6 +13,4 @@ export interface ICallFunctionResponse {
13
13
  result: any;
14
14
  }
15
15
 
16
- export interface ICallFunction{
17
- (options: ICallFunctionOptions,callback?: Function):Promise<ICallFunctionResponse>;
18
- }
16
+ export type ICallFunction = (options: ICallFunctionOptions, callback?: Function) => Promise<ICallFunctionResponse>;
package/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { CloudbaseAdapter, SDKAdapterInterface } from '@cloudbase/adapter-interface';
2
- import { ICloudbaseComponent, ICloudbaseHook } from "./component";
3
- import { ICloudbaseRequest } from "./request";
4
- import { ICloudbaseCache } from "./cache";
5
- import { ICloudbaseAuth } from './auth'
2
+ import { ICloudbaseComponent, ICloudbaseHook } from './component';
3
+ import { ICloudbaseRequest } from './request';
4
+ import { ICloudbaseCache } from './cache';
6
5
 
7
6
  export type Persistence = 'local' | 'session' | 'none';
8
7
 
@@ -21,33 +20,28 @@ export interface ICloudbaseConfig {
21
20
  timeout?: number;
22
21
  persistence?: Persistence;
23
22
  appSecret?: ICloudbaseAppSecret;
24
- oauthClient?: any
25
23
  appSign?: string;
26
24
  debug?: boolean;
27
- _fromApp?: ICloudbase
28
25
  }
29
26
  // 可更新的配置字段
30
- export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence' | 'region' | 'debug'>;
27
+ export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence'|'region'|'debug'>;
31
28
 
32
29
  export interface ICloudbaseExtension {
33
30
  name: string;
34
31
  invoke(opts: any, app: ICloudbase): Promise<any>;
35
32
  }
36
33
 
37
- export interface ICloudbase {
34
+ export interface ICloudbase{
38
35
  config: ICloudbaseConfig;
39
36
  platform: ICloudbasePlatformInfo;
40
37
  cache: ICloudbaseCache;
41
38
  request: ICloudbaseRequest;
42
- oauthClient: any;
43
39
  localCache: ICloudbaseCache;
44
- authInstance?: ICloudbaseAuth;
45
- oauthInstance?: any;
46
40
  init(config: ICloudbaseConfig): ICloudbase;
47
41
  updateConfig(config: ICloudbaseUpgradedConfig): void;
48
42
  registerExtension(ext: ICloudbaseExtension): void;
49
43
  invokeExtension(name: string, opts: any): Promise<any>;
50
- useAdapters(adapters: CloudbaseAdapter | CloudbaseAdapter[]): void;
44
+ useAdapters(adapters: CloudbaseAdapter|CloudbaseAdapter[]): void;
51
45
  registerComponent(component: ICloudbaseComponent): void;
52
46
  registerHook(hook: ICloudbaseHook): void;
53
47
  registerVersion(version: string): void;
@@ -63,4 +57,4 @@ export interface IGenericError<T extends string, P = any> extends Error {
63
57
  type: T
64
58
  payload: P
65
59
  generic: boolean
66
- }
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/types",
3
- "version": "1.2.3-alpha.0",
3
+ "version": "1.8.2",
4
4
  "description": "cloudbase javascript sdk types",
5
5
  "files": [
6
6
  "index.js",
@@ -38,12 +38,9 @@
38
38
  "dependencies": {
39
39
  "@cloudbase/adapter-interface": "^0.4.0"
40
40
  },
41
- "devDependencies": {
42
- "@typescript-eslint/eslint-plugin": "^3.10.1",
43
- "@typescript-eslint/parser": "^3.10.1",
44
- "eslint": "^7.7.0",
45
- "eslint-config-alloy": "^3.8.0",
46
- "typescript": "^4.0.2"
41
+ "scripts": {
42
+ "lint": "eslint --fix \"./**/*.ts\"",
43
+ "precommit": "npm run lint"
47
44
  },
48
- "gitHead": "eb161dd3c79b90a95a877984bf7c07cdb4563077"
45
+ "gitHead": "5b3ac0446269ebb9ad2b22cdcb48c379ded1cb07"
49
46
  }
package/realtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DataType, QueueType, ISingleDBEvent } from './database'
1
+ import { DataType, QueueType, ISingleDBEvent } from './database';
2
2
 
3
3
  export type IRequestMsgType =
4
4
  | 'LOGIN' // 鉴权(环境维度)
@@ -6,7 +6,7 @@ export type IRequestMsgType =
6
6
  | 'REBUILD_WATCH' // 重建监听,1)数据失序时 2)checkLast 不一致时
7
7
  | 'CHECK_LAST' // 检查是否有未收到的消息
8
8
  | 'CLOSE_WATCH' // 取消监听
9
- | 'PING' // 心跳 ping
9
+ | 'PING'; // 心跳 ping
10
10
 
11
11
  export type IResponseMsgType =
12
12
  | 'LOGIN_RES' // LOGIN 回包
@@ -14,7 +14,7 @@ export type IResponseMsgType =
14
14
  | 'NEXT_EVENT' // 服务端主动推变更事件
15
15
  | 'CHECK_EVENT' // CHECK_LAST 回包
16
16
  | 'PONG' // 心跳 PING 回包
17
- | 'ERROR' // 错误异常
17
+ | 'ERROR'; // 错误异常
18
18
 
19
19
  export interface IRequestMessageBase<W extends boolean = true> {
20
20
  watchId: W extends true ? string : undefined
@@ -29,7 +29,7 @@ export type IRequestMessageMsgData =
29
29
  | IRequestMessageRebuildWatchData
30
30
  | IRequestMessageCheckLastData
31
31
  | IRequestMessageCloseWatchData
32
- | IRequestMessagePingData
32
+ | IRequestMessagePingData;
33
33
 
34
34
  export type IRequestMessage =
35
35
  | IRequestMessageInitWatchMsg
@@ -37,7 +37,7 @@ export type IRequestMessage =
37
37
  | IRequestMessageRebuildWatchMsg
38
38
  | IRequestMessageCheckLastMsg
39
39
  | IRequestMessageCloseWatchMsg
40
- | IRequestMessagePingMsg
40
+ | IRequestMessagePingMsg;
41
41
 
42
42
  export interface IRequestMessageLoginData {
43
43
  envId: string
@@ -95,14 +95,14 @@ export interface IRequestMessageCheckLastMsg extends IRequestMessageBase {
95
95
  msgData: IRequestMessageCheckLastData
96
96
  }
97
97
 
98
- export type IRequestMessageCloseWatchData = null
98
+ export type IRequestMessageCloseWatchData = null;
99
99
 
100
100
  export interface IRequestMessageCloseWatchMsg extends IRequestMessageBase {
101
101
  msgType: 'CLOSE_WATCH'
102
102
  msgData: IRequestMessageCloseWatchData
103
103
  }
104
104
 
105
- export type IRequestMessagePingData = null
105
+ export type IRequestMessagePingData = null;
106
106
 
107
107
  export interface IRequestMessagePingMsg extends IRequestMessageBase<false> {
108
108
  msgType: 'PING'
@@ -125,7 +125,7 @@ export type IResponseMessageMsgData =
125
125
  | IResponseMessageNextEventData
126
126
  | IResponseMessageCheckEventData
127
127
  | IResponseMessagePongData
128
- | IResponseMessageErrorData
128
+ | IResponseMessageErrorData;
129
129
 
130
130
  export type IResponseMessage =
131
131
  | IResponseMessageLoginResMsg
@@ -133,11 +133,11 @@ export type IResponseMessage =
133
133
  | IResponseMessageNextEventMsg
134
134
  | IResponseMessageCheckEventMsg
135
135
  | IResponseMessagePongMsg
136
- | IResponseMessageErrorMsg
136
+ | IResponseMessageErrorMsg;
137
137
 
138
138
  export type IResponseMessageLoginResData = {
139
139
  envId: string
140
- } & Partial<IResponseMessageErrorData>
140
+ } & Partial<IResponseMessageErrorData>;
141
141
 
142
142
  export interface IResponseMessageLoginResMsg
143
143
  extends IResponseMessageBase<false> {
@@ -177,7 +177,7 @@ export interface IResponseMessageCheckEventMsg extends IResponseMessageBase {
177
177
  msgData: IResponseMessageCheckEventData
178
178
  }
179
179
 
180
- export type IResponseMessagePongData = null
180
+ export type IResponseMessagePongData = null;
181
181
 
182
182
  export interface IResponseMessagePongMsg extends IResponseMessageBase {
183
183
  msgType: 'PONG'
@@ -194,14 +194,14 @@ export type IResponseMessageErrorData = {
194
194
  | { code: 'INVALIID_ENV' } // 环境无效
195
195
  | { code: 'SIGN_PARAM_INVALID' } // cam签名无效
196
196
  | { code: 'COLLECTION_PERMISSION_DENIED' } // 没有集合操作权限
197
- | { code: 'QUERYID_INVALID_ERROR' }) // queryID 无效
197
+ | { code: 'QUERYID_INVALID_ERROR' }); // queryID 无效
198
198
 
199
199
  export interface IResponseMessageErrorMsg extends IResponseMessageBase {
200
200
  msgType: 'ERROR'
201
201
  msgData: IResponseMessageErrorData
202
202
  }
203
203
 
204
- export type IDBEvent = IDBInitEvent | IDBNextEvent
204
+ export type IDBEvent = IDBInitEvent | IDBNextEvent;
205
205
 
206
206
  export interface IDBEventBase {
207
207
  ID: number // event id
@@ -237,21 +237,21 @@ export type IDBNextEvent =
237
237
  | IDBNextEventDataReplace
238
238
  | IDBNextEventDataAdd
239
239
  | IDBNextEventDataRemove
240
- | IDBNextEventDataLimit
240
+ | IDBNextEventDataLimit;
241
241
 
242
242
  export type IDBNextEventDataUpdate =
243
243
  | IDBNextEventDataUpdateQueueUpdate
244
244
  | IDBNextEventDataUpdateQueueEnqueue
245
- | IDBNextEventDataUpdateQueueDequeue
245
+ | IDBNextEventDataUpdateQueueDequeue;
246
246
 
247
247
  export type IDBNextEventDataReplace =
248
248
  | IDBNextEventDataReplaceQueueUpdate
249
249
  | IDBNextEventDataReplaceQueueEnqueue
250
- | IDBNextEventDataReplaceQueueDequeue
250
+ | IDBNextEventDataReplaceQueueDequeue;
251
251
 
252
- export type IDBNextEventDataLimit =
252
+ export type IDBNextEventDataLimit =
253
253
  | IDBNextEventDataLimitQueueEnqueue
254
- | IDBNextEventDataLimitQueueDequeue
254
+ | IDBNextEventDataLimitQueueDequeue;
255
255
 
256
256
  export interface IDBNextEventDataUpdateQueueUpdate extends IDBEventBase {
257
257
  DataType: 'update'
@@ -347,9 +347,6 @@ export interface DBRealtimeListener {
347
347
  close: () => void
348
348
  }
349
349
 
350
- export interface IRealtimeListenerConstructorOptions extends IWatchOptions {
351
- // ws: any
352
- // query: string
353
- }
350
+ export type IRealtimeListenerConstructorOptions = IWatchOptions;
354
351
 
355
- export type SnapshotType = 'init'
352
+ export type SnapshotType = 'init';
package/request.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import {
2
- IRequestOptions, IUploadRequestOptions, ResponseObject
3
- } from '@cloudbase/adapter-interface';
4
-
1
+ import { IRequestOptions, ResponseObject, IUploadRequestOptions } from '@cloudbase/adapter-interface';
5
2
  import { ICloudbaseConfig, KV } from '.';
6
3
 
7
4
  export interface IGetAccessTokenResult {
@@ -9,20 +6,19 @@ export interface IGetAccessTokenResult {
9
6
  accessTokenExpire: number;
10
7
  }
11
8
 
12
- export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'timeout' | 'appSecret' | 'appSign' | 'oauthClient' | '_fromApp'>;
9
+ export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env'|'region'|'timeout'|'appSecret'|'appSign'>;
13
10
 
14
- export interface IAppendedRequestInfo {
11
+ export type IAppendedRequestInfo = {
15
12
  data: KV<any>;
16
13
  headers: KV<string>;
17
- }
14
+ };
18
15
  export type IRequestBeforeHook = (...args: any[]) => IAppendedRequestInfo;
19
16
  export interface ICloudbaseRequest {
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>;
28
- }
17
+ post(options: IRequestOptions): Promise<ResponseObject>;
18
+ upload(options: IUploadRequestOptions): Promise<ResponseObject>;
19
+ download(options: IRequestOptions): Promise<ResponseObject>;
20
+ refreshAccessToken(): Promise<IGetAccessTokenResult>;
21
+ getAccessToken(): Promise<IGetAccessTokenResult>;
22
+ request(action: string, params: KV<any>, options?: KV<any>): Promise<ResponseObject>;
23
+ send(action: string, data: KV<any>): Promise<any>;
24
+ }
package/storage.d.ts CHANGED
@@ -9,25 +9,19 @@ export interface ICloudbaseUploadFileResult {
9
9
  requestId: string;
10
10
  }
11
11
 
12
- export interface ICloudbaseUploadFile {
13
- (params: ICloudbaseUploadFileParams, callback?: Function): Promise<ICloudbaseUploadFileResult>;
14
- }
12
+ export type ICloudbaseUploadFile = (params: ICloudbaseUploadFileParams, callback?: Function) => Promise<ICloudbaseUploadFileResult>;
15
13
 
16
14
  export interface ICloudbaseGetUploadMetadataParams {
17
15
  cloudPath: string;
18
16
  }
19
17
 
20
- export interface ICloudbaseGetUploadMetadata {
21
- (params: ICloudbaseGetUploadMetadataParams, callback?: Function): Promise<any>;
22
- }
18
+ export type ICloudbaseGetUploadMetadata = (params: ICloudbaseGetUploadMetadataParams, callback?: Function) => Promise<any>;
23
19
 
24
20
  export interface ICloudbaseDeleteFileParams {
25
21
  fileList: string[];
26
22
  }
27
23
 
28
- export interface ICloudbaseDeleteFile {
29
- (params: ICloudbaseDeleteFileParams, callback?: Function): Promise<ICloudbaseDeleteFileResult>;
30
- }
24
+ export type ICloudbaseDeleteFile = (params: ICloudbaseDeleteFileParams, callback?: Function) => Promise<ICloudbaseDeleteFileResult>;
31
25
 
32
26
  export interface ICloudbaseDeleteFileResult {
33
27
  code?: string;
@@ -61,9 +55,7 @@ export interface ICloudbaseGetTempFileURLResult {
61
55
  requestId?: string;
62
56
  }
63
57
 
64
- export interface ICloudbaseGetTempFileURL {
65
- (params: ICloudbaseGetTempFileURLParams, callback?: Function): Promise<ICloudbaseGetTempFileURLResult>;
66
- }
58
+ export type ICloudbaseGetTempFileURL = (params: ICloudbaseGetTempFileURLParams, callback?: Function) => Promise<ICloudbaseGetTempFileURLResult>;
67
59
 
68
60
  export interface ICloudbaseDownloadFileParams {
69
61
  fileID: string;
@@ -77,9 +69,7 @@ export interface ICloudbaseDownloadFileResult {
77
69
  requestId?: string;
78
70
  }
79
71
 
80
- export interface ICloudbaseDownloadFile {
81
- (params: ICloudbaseDownloadFileParams, callback?: Function): Promise<ICloudbaseDownloadFileResult>;
82
- }
72
+ export type ICloudbaseDownloadFile = (params: ICloudbaseDownloadFileParams, callback?: Function) => Promise<ICloudbaseDownloadFileResult>;
83
73
 
84
74
  export interface ICloudbaseFileMetaData {
85
75
  url: string;
@@ -93,4 +83,4 @@ export interface ICloudbaseFileMetaData {
93
83
  export interface ICloudbaseFileMetaDataRes {
94
84
  data: ICloudbaseFileMetaData;
95
85
  requestId: string;
96
- }
86
+ }