@hyext/builder-revues 1.5.9-alpha.0 → 1.5.10-alpha.1
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.js +43 -2
- package/package.json +6 -5
- package/static/.DS_Store +0 -0
- package/static/projects/.DS_Store +0 -0
- package/static/projects/empty/.eslintrc.js +31 -0
- package/static/projects/empty/app.js +2 -0
- package/static/projects/empty/app.json +11 -0
- package/static/projects/empty/app.wxss +10 -0
- package/static/projects/empty/components/navigation-bar/navigation-bar.js +105 -0
- package/static/projects/empty/components/navigation-bar/navigation-bar.json +5 -0
- package/static/projects/empty/components/navigation-bar/navigation-bar.wxml +64 -0
- package/static/projects/empty/components/navigation-bar/navigation-bar.wxss +96 -0
- package/static/projects/empty/pages/index/index.js +2 -0
- package/static/projects/empty/pages/index/index.json +5 -0
- package/static/projects/empty/pages/index/index.wxml +7 -0
- package/static/projects/empty/pages/index/index.wxss +10 -0
- package/static/projects/empty/project.config.json +25 -0
- package/static/projects/empty/sitemap.json +7 -0
- package/static/projects/ts/.DS_Store +0 -0
- package/static/projects/ts/.eslintrc.js +31 -0
- package/static/projects/ts/app.json +11 -0
- package/static/projects/ts/app.ts +8 -0
- package/static/projects/ts/app.wxss +10 -0
- package/static/projects/ts/components/navigation-bar/navigation-bar.js +105 -0
- package/static/projects/ts/components/navigation-bar/navigation-bar.json +5 -0
- package/static/projects/ts/components/navigation-bar/navigation-bar.wxml +64 -0
- package/static/projects/ts/components/navigation-bar/navigation-bar.wxss +96 -0
- package/static/projects/ts/pages/index/index.json +5 -0
- package/static/projects/ts/pages/index/index.ts +2 -0
- package/static/projects/ts/pages/index/index.wxml +7 -0
- package/static/projects/ts/pages/index/index.wxss +10 -0
- package/static/projects/ts/project.config.json +27 -0
- package/static/projects/ts/sitemap.json +7 -0
- package/static/projects/ts/tsconfig.json +26 -0
- package/static/projects/ts/typings/wechat-miniprogram/LICENSE +21 -0
- package/static/projects/ts/typings/wechat-miniprogram/README.md +15 -0
- package/static/projects/ts/typings/wechat-miniprogram/index.d.ts +143 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.api.d.ts +22112 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.app.d.ts +249 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.behavior.d.ts +47 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.cloud.d.ts +903 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.component.d.ts +613 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.event.d.ts +1413 -0
- package/static/projects/ts/typings/wechat-miniprogram/lib.wx.page.d.ts +246 -0
- package/static/projects/ts/typings/wechat-miniprogram/package.json +63 -0
- package/static/projects/ts/util.ts +3 -0
@@ -0,0 +1,903 @@
|
|
1
|
+
interface IAPIError {
|
2
|
+
errMsg: string;
|
3
|
+
}
|
4
|
+
|
5
|
+
interface IAPIParam<T = any> {
|
6
|
+
config?: ICloudConfig | undefined;
|
7
|
+
success?: ((res: T) => void) | undefined;
|
8
|
+
fail?: ((err: IAPIError) => void) | undefined;
|
9
|
+
complete?: ((val: T | IAPIError) => void) | undefined;
|
10
|
+
}
|
11
|
+
|
12
|
+
interface IAPISuccessParam {
|
13
|
+
errMsg: string;
|
14
|
+
}
|
15
|
+
|
16
|
+
type IAPICompleteParam = IAPISuccessParam | IAPIError;
|
17
|
+
|
18
|
+
type IAPIFunction<T, P extends IAPIParam<T>> = (param?: P) => Promise<T>;
|
19
|
+
|
20
|
+
interface IInitCloudConfig {
|
21
|
+
env?:
|
22
|
+
| string
|
23
|
+
| {
|
24
|
+
database?: string | undefined;
|
25
|
+
functions?: string | undefined;
|
26
|
+
storage?: string | undefined;
|
27
|
+
}
|
28
|
+
| undefined;
|
29
|
+
traceUser?: boolean | undefined;
|
30
|
+
}
|
31
|
+
|
32
|
+
interface ICloudConfig {
|
33
|
+
env?: string | undefined;
|
34
|
+
traceUser?: boolean | undefined;
|
35
|
+
}
|
36
|
+
|
37
|
+
interface IICloudAPI {
|
38
|
+
init: (config?: IInitCloudConfig) => void;
|
39
|
+
[api: string]: AnyFunction | IAPIFunction<any, any>;
|
40
|
+
}
|
41
|
+
|
42
|
+
interface ICloudService {
|
43
|
+
name: string;
|
44
|
+
|
45
|
+
getAPIs: () => { [name: string]: IAPIFunction<any, any> };
|
46
|
+
}
|
47
|
+
|
48
|
+
interface ICloudServices {
|
49
|
+
[serviceName: string]: ICloudService;
|
50
|
+
}
|
51
|
+
|
52
|
+
interface ICloudMetaData {
|
53
|
+
session_id: string;
|
54
|
+
}
|
55
|
+
|
56
|
+
declare class InternalSymbol {}
|
57
|
+
|
58
|
+
interface AnyObject {
|
59
|
+
[x: string]: any;
|
60
|
+
}
|
61
|
+
|
62
|
+
type AnyArray = any[];
|
63
|
+
|
64
|
+
type AnyFunction = (...args: any[]) => any;
|
65
|
+
|
66
|
+
/**
|
67
|
+
* extend wx with cloud
|
68
|
+
*/
|
69
|
+
interface WxCloud {
|
70
|
+
init: (config?: ICloudConfig) => void;
|
71
|
+
|
72
|
+
callFunction(param: OQ<ICloud.CallFunctionParam>): void;
|
73
|
+
callFunction(
|
74
|
+
param: RQ<ICloud.CallFunctionParam>,
|
75
|
+
): Promise<ICloud.CallFunctionResult>;
|
76
|
+
|
77
|
+
uploadFile(param: OQ<ICloud.UploadFileParam>): WechatMiniprogram.UploadTask;
|
78
|
+
uploadFile(
|
79
|
+
param: RQ<ICloud.UploadFileParam>,
|
80
|
+
): Promise<ICloud.UploadFileResult>;
|
81
|
+
|
82
|
+
downloadFile(
|
83
|
+
param: OQ<ICloud.DownloadFileParam>,
|
84
|
+
): WechatMiniprogram.DownloadTask;
|
85
|
+
downloadFile(
|
86
|
+
param: RQ<ICloud.DownloadFileParam>,
|
87
|
+
): Promise<ICloud.DownloadFileResult>;
|
88
|
+
|
89
|
+
getTempFileURL(param: OQ<ICloud.GetTempFileURLParam>): void;
|
90
|
+
getTempFileURL(
|
91
|
+
param: RQ<ICloud.GetTempFileURLParam>,
|
92
|
+
): Promise<ICloud.GetTempFileURLResult>;
|
93
|
+
|
94
|
+
deleteFile(param: OQ<ICloud.DeleteFileParam>): void;
|
95
|
+
deleteFile(
|
96
|
+
param: RQ<ICloud.DeleteFileParam>,
|
97
|
+
): Promise<ICloud.DeleteFileResult>;
|
98
|
+
|
99
|
+
database: (config?: ICloudConfig) => DB.Database;
|
100
|
+
|
101
|
+
CloudID: ICloud.ICloudIDConstructor;
|
102
|
+
CDN: ICloud.ICDNConstructor;
|
103
|
+
}
|
104
|
+
|
105
|
+
declare namespace ICloud {
|
106
|
+
interface ICloudAPIParam<T = any> extends IAPIParam<T> {
|
107
|
+
config?: ICloudConfig | undefined;
|
108
|
+
}
|
109
|
+
|
110
|
+
// === API: callFunction ===
|
111
|
+
type CallFunctionData = AnyObject;
|
112
|
+
|
113
|
+
interface CallFunctionResult extends IAPISuccessParam {
|
114
|
+
result: AnyObject | string | undefined;
|
115
|
+
}
|
116
|
+
|
117
|
+
interface CallFunctionParam extends ICloudAPIParam<CallFunctionResult> {
|
118
|
+
name: string;
|
119
|
+
data?: CallFunctionData | undefined;
|
120
|
+
slow?: boolean | undefined;
|
121
|
+
}
|
122
|
+
// === end ===
|
123
|
+
|
124
|
+
// === API: uploadFile ===
|
125
|
+
interface UploadFileResult extends IAPISuccessParam {
|
126
|
+
fileID: string;
|
127
|
+
statusCode: number;
|
128
|
+
}
|
129
|
+
|
130
|
+
interface UploadFileParam extends ICloudAPIParam<UploadFileResult> {
|
131
|
+
cloudPath: string;
|
132
|
+
filePath: string;
|
133
|
+
header?: AnyObject | undefined;
|
134
|
+
}
|
135
|
+
// === end ===
|
136
|
+
|
137
|
+
// === API: downloadFile ===
|
138
|
+
interface DownloadFileResult extends IAPISuccessParam {
|
139
|
+
tempFilePath: string;
|
140
|
+
statusCode: number;
|
141
|
+
}
|
142
|
+
|
143
|
+
interface DownloadFileParam extends ICloudAPIParam<DownloadFileResult> {
|
144
|
+
fileID: string;
|
145
|
+
cloudPath?: string | undefined;
|
146
|
+
}
|
147
|
+
// === end ===
|
148
|
+
|
149
|
+
// === API: getTempFileURL ===
|
150
|
+
interface GetTempFileURLResult extends IAPISuccessParam {
|
151
|
+
fileList: GetTempFileURLResultItem[];
|
152
|
+
}
|
153
|
+
|
154
|
+
interface GetTempFileURLResultItem {
|
155
|
+
fileID: string;
|
156
|
+
tempFileURL: string;
|
157
|
+
maxAge: number;
|
158
|
+
status: number;
|
159
|
+
errMsg: string;
|
160
|
+
}
|
161
|
+
|
162
|
+
interface GetTempFileURLParam extends ICloudAPIParam<GetTempFileURLResult> {
|
163
|
+
fileList: string[];
|
164
|
+
}
|
165
|
+
// === end ===
|
166
|
+
|
167
|
+
// === API: deleteFile ===
|
168
|
+
interface DeleteFileResult extends IAPISuccessParam {
|
169
|
+
fileList: DeleteFileResultItem[];
|
170
|
+
}
|
171
|
+
|
172
|
+
interface DeleteFileResultItem {
|
173
|
+
fileID: string;
|
174
|
+
status: number;
|
175
|
+
errMsg: string;
|
176
|
+
}
|
177
|
+
|
178
|
+
interface DeleteFileParam extends ICloudAPIParam<DeleteFileResult> {
|
179
|
+
fileList: string[];
|
180
|
+
}
|
181
|
+
// === end ===
|
182
|
+
|
183
|
+
// === API: CloudID ===
|
184
|
+
abstract class CloudID {
|
185
|
+
constructor(cloudID: string);
|
186
|
+
}
|
187
|
+
|
188
|
+
interface ICloudIDConstructor {
|
189
|
+
new(cloudId: string): CloudID;
|
190
|
+
(cloudId: string): CloudID;
|
191
|
+
}
|
192
|
+
// === end ===
|
193
|
+
|
194
|
+
// === API: CDN ===
|
195
|
+
abstract class CDN {
|
196
|
+
target: string | ArrayBuffer | ICDNFilePathSpec;
|
197
|
+
constructor(target: string | ArrayBuffer | ICDNFilePathSpec);
|
198
|
+
}
|
199
|
+
|
200
|
+
interface ICDNFilePathSpec {
|
201
|
+
type: "filePath";
|
202
|
+
filePath: string;
|
203
|
+
}
|
204
|
+
|
205
|
+
interface ICDNConstructor {
|
206
|
+
new(options: string | ArrayBuffer | ICDNFilePathSpec): CDN;
|
207
|
+
(options: string | ArrayBuffer | ICDNFilePathSpec): CDN;
|
208
|
+
}
|
209
|
+
// === end ===
|
210
|
+
}
|
211
|
+
|
212
|
+
// === Database ===
|
213
|
+
declare namespace DB {
|
214
|
+
/**
|
215
|
+
* The class of all exposed cloud database instances
|
216
|
+
*/
|
217
|
+
class Database {
|
218
|
+
readonly config: ICloudConfig;
|
219
|
+
readonly command: DatabaseCommand;
|
220
|
+
readonly Geo: IGeo;
|
221
|
+
readonly serverDate: () => ServerDate;
|
222
|
+
readonly RegExp: IRegExpConstructor;
|
223
|
+
|
224
|
+
private constructor();
|
225
|
+
|
226
|
+
collection(collectionName: string): CollectionReference;
|
227
|
+
}
|
228
|
+
|
229
|
+
class CollectionReference extends Query {
|
230
|
+
readonly collectionName: string;
|
231
|
+
|
232
|
+
private constructor(name: string, database: Database);
|
233
|
+
|
234
|
+
doc(docId: string | number): DocumentReference;
|
235
|
+
|
236
|
+
add(options: OQ<IAddDocumentOptions>): void;
|
237
|
+
add(options: RQ<IAddDocumentOptions>): Promise<IAddResult>;
|
238
|
+
}
|
239
|
+
|
240
|
+
class DocumentReference {
|
241
|
+
private constructor(docId: string | number, database: Database);
|
242
|
+
|
243
|
+
field(object: Record<string, any>): this;
|
244
|
+
|
245
|
+
get(options: OQ<IGetDocumentOptions>): void;
|
246
|
+
get(options?: RQ<IGetDocumentOptions>): Promise<IQuerySingleResult>;
|
247
|
+
|
248
|
+
set(options: OQ<ISetSingleDocumentOptions>): void;
|
249
|
+
set(options?: RQ<ISetSingleDocumentOptions>): Promise<ISetResult>;
|
250
|
+
|
251
|
+
update(options: OQ<IUpdateSingleDocumentOptions>): void;
|
252
|
+
update(
|
253
|
+
options?: RQ<IUpdateSingleDocumentOptions>,
|
254
|
+
): Promise<IUpdateResult>;
|
255
|
+
|
256
|
+
remove(options: OQ<IRemoveSingleDocumentOptions>): void;
|
257
|
+
remove(
|
258
|
+
options?: RQ<IRemoveSingleDocumentOptions>,
|
259
|
+
): Promise<IRemoveResult>;
|
260
|
+
|
261
|
+
watch(options: IWatchOptions): RealtimeListener;
|
262
|
+
}
|
263
|
+
|
264
|
+
class RealtimeListener {
|
265
|
+
// "And Now His Watch Is Ended"
|
266
|
+
close: () => Promise<void>;
|
267
|
+
}
|
268
|
+
|
269
|
+
class Query {
|
270
|
+
where(condition: IQueryCondition): Query;
|
271
|
+
|
272
|
+
orderBy(fieldPath: string, order: string): Query;
|
273
|
+
|
274
|
+
limit(max: number): Query;
|
275
|
+
|
276
|
+
skip(offset: number): Query;
|
277
|
+
|
278
|
+
field(object: Record<string, any>): Query;
|
279
|
+
|
280
|
+
get(options: OQ<IGetDocumentOptions>): void;
|
281
|
+
get(options?: RQ<IGetDocumentOptions>): Promise<IQueryResult>;
|
282
|
+
|
283
|
+
count(options: OQ<ICountDocumentOptions>): void;
|
284
|
+
count(options?: RQ<ICountDocumentOptions>): Promise<ICountResult>;
|
285
|
+
|
286
|
+
watch(options: IWatchOptions): RealtimeListener;
|
287
|
+
}
|
288
|
+
|
289
|
+
interface DatabaseCommand {
|
290
|
+
eq(val: any): DatabaseQueryCommand;
|
291
|
+
neq(val: any): DatabaseQueryCommand;
|
292
|
+
gt(val: any): DatabaseQueryCommand;
|
293
|
+
gte(val: any): DatabaseQueryCommand;
|
294
|
+
lt(val: any): DatabaseQueryCommand;
|
295
|
+
lte(val: any): DatabaseQueryCommand;
|
296
|
+
in(val: any[]): DatabaseQueryCommand;
|
297
|
+
nin(val: any[]): DatabaseQueryCommand;
|
298
|
+
|
299
|
+
geoNear(options: IGeoNearCommandOptions): DatabaseQueryCommand;
|
300
|
+
geoWithin(options: IGeoWithinCommandOptions): DatabaseQueryCommand;
|
301
|
+
geoIntersects(
|
302
|
+
options: IGeoIntersectsCommandOptions,
|
303
|
+
): DatabaseQueryCommand;
|
304
|
+
|
305
|
+
and(
|
306
|
+
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
307
|
+
): DatabaseLogicCommand;
|
308
|
+
or(
|
309
|
+
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
310
|
+
): DatabaseLogicCommand;
|
311
|
+
nor(
|
312
|
+
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
313
|
+
): DatabaseLogicCommand;
|
314
|
+
not(expression: DatabaseLogicCommand): DatabaseLogicCommand;
|
315
|
+
|
316
|
+
exists(val: boolean): DatabaseQueryCommand;
|
317
|
+
|
318
|
+
mod(divisor: number, remainder: number): DatabaseQueryCommand;
|
319
|
+
|
320
|
+
all(val: any[]): DatabaseQueryCommand;
|
321
|
+
elemMatch(val: any): DatabaseQueryCommand;
|
322
|
+
size(val: number): DatabaseQueryCommand;
|
323
|
+
|
324
|
+
set(val: any): DatabaseUpdateCommand;
|
325
|
+
remove(): DatabaseUpdateCommand;
|
326
|
+
inc(val: number): DatabaseUpdateCommand;
|
327
|
+
mul(val: number): DatabaseUpdateCommand;
|
328
|
+
min(val: number): DatabaseUpdateCommand;
|
329
|
+
max(val: number): DatabaseUpdateCommand;
|
330
|
+
rename(val: string): DatabaseUpdateCommand;
|
331
|
+
bit(val: number): DatabaseUpdateCommand;
|
332
|
+
|
333
|
+
push(...values: any[]): DatabaseUpdateCommand;
|
334
|
+
pop(): DatabaseUpdateCommand;
|
335
|
+
shift(): DatabaseUpdateCommand;
|
336
|
+
unshift(...values: any[]): DatabaseUpdateCommand;
|
337
|
+
addToSet(val: any): DatabaseUpdateCommand;
|
338
|
+
pull(val: any): DatabaseUpdateCommand;
|
339
|
+
pullAll(val: any): DatabaseUpdateCommand;
|
340
|
+
|
341
|
+
project: {
|
342
|
+
slice(val: number | [number, number]): DatabaseProjectionCommand;
|
343
|
+
};
|
344
|
+
|
345
|
+
aggregate: {
|
346
|
+
__safe_props__?: Set<string> | undefined;
|
347
|
+
|
348
|
+
abs(val: any): DatabaseAggregateCommand;
|
349
|
+
add(val: any): DatabaseAggregateCommand;
|
350
|
+
addToSet(val: any): DatabaseAggregateCommand;
|
351
|
+
allElementsTrue(val: any): DatabaseAggregateCommand;
|
352
|
+
and(val: any): DatabaseAggregateCommand;
|
353
|
+
anyElementTrue(val: any): DatabaseAggregateCommand;
|
354
|
+
arrayElemAt(val: any): DatabaseAggregateCommand;
|
355
|
+
arrayToObject(val: any): DatabaseAggregateCommand;
|
356
|
+
avg(val: any): DatabaseAggregateCommand;
|
357
|
+
ceil(val: any): DatabaseAggregateCommand;
|
358
|
+
cmp(val: any): DatabaseAggregateCommand;
|
359
|
+
concat(val: any): DatabaseAggregateCommand;
|
360
|
+
concatArrays(val: any): DatabaseAggregateCommand;
|
361
|
+
cond(val: any): DatabaseAggregateCommand;
|
362
|
+
convert(val: any): DatabaseAggregateCommand;
|
363
|
+
dateFromParts(val: any): DatabaseAggregateCommand;
|
364
|
+
dateToParts(val: any): DatabaseAggregateCommand;
|
365
|
+
dateFromString(val: any): DatabaseAggregateCommand;
|
366
|
+
dateToString(val: any): DatabaseAggregateCommand;
|
367
|
+
dayOfMonth(val: any): DatabaseAggregateCommand;
|
368
|
+
dayOfWeek(val: any): DatabaseAggregateCommand;
|
369
|
+
dayOfYear(val: any): DatabaseAggregateCommand;
|
370
|
+
divide(val: any): DatabaseAggregateCommand;
|
371
|
+
eq(val: any): DatabaseAggregateCommand;
|
372
|
+
exp(val: any): DatabaseAggregateCommand;
|
373
|
+
filter(val: any): DatabaseAggregateCommand;
|
374
|
+
first(val: any): DatabaseAggregateCommand;
|
375
|
+
floor(val: any): DatabaseAggregateCommand;
|
376
|
+
gt(val: any): DatabaseAggregateCommand;
|
377
|
+
gte(val: any): DatabaseAggregateCommand;
|
378
|
+
hour(val: any): DatabaseAggregateCommand;
|
379
|
+
ifNull(val: any): DatabaseAggregateCommand;
|
380
|
+
in(val: any): DatabaseAggregateCommand;
|
381
|
+
indexOfArray(val: any): DatabaseAggregateCommand;
|
382
|
+
indexOfBytes(val: any): DatabaseAggregateCommand;
|
383
|
+
indexOfCP(val: any): DatabaseAggregateCommand;
|
384
|
+
isArray(val: any): DatabaseAggregateCommand;
|
385
|
+
isoDayOfWeek(val: any): DatabaseAggregateCommand;
|
386
|
+
isoWeek(val: any): DatabaseAggregateCommand;
|
387
|
+
isoWeekYear(val: any): DatabaseAggregateCommand;
|
388
|
+
last(val: any): DatabaseAggregateCommand;
|
389
|
+
let(val: any): DatabaseAggregateCommand;
|
390
|
+
literal(val: any): DatabaseAggregateCommand;
|
391
|
+
ln(val: any): DatabaseAggregateCommand;
|
392
|
+
log(val: any): DatabaseAggregateCommand;
|
393
|
+
log10(val: any): DatabaseAggregateCommand;
|
394
|
+
lt(val: any): DatabaseAggregateCommand;
|
395
|
+
lte(val: any): DatabaseAggregateCommand;
|
396
|
+
ltrim(val: any): DatabaseAggregateCommand;
|
397
|
+
map(val: any): DatabaseAggregateCommand;
|
398
|
+
max(val: any): DatabaseAggregateCommand;
|
399
|
+
mergeObjects(val: any): DatabaseAggregateCommand;
|
400
|
+
meta(val: any): DatabaseAggregateCommand;
|
401
|
+
min(val: any): DatabaseAggregateCommand;
|
402
|
+
millisecond(val: any): DatabaseAggregateCommand;
|
403
|
+
minute(val: any): DatabaseAggregateCommand;
|
404
|
+
mod(val: any): DatabaseAggregateCommand;
|
405
|
+
month(val: any): DatabaseAggregateCommand;
|
406
|
+
multiply(val: any): DatabaseAggregateCommand;
|
407
|
+
neq(val: any): DatabaseAggregateCommand;
|
408
|
+
not(val: any): DatabaseAggregateCommand;
|
409
|
+
objectToArray(val: any): DatabaseAggregateCommand;
|
410
|
+
or(val: any): DatabaseAggregateCommand;
|
411
|
+
pow(val: any): DatabaseAggregateCommand;
|
412
|
+
push(val: any): DatabaseAggregateCommand;
|
413
|
+
range(val: any): DatabaseAggregateCommand;
|
414
|
+
reduce(val: any): DatabaseAggregateCommand;
|
415
|
+
reverseArray(val: any): DatabaseAggregateCommand;
|
416
|
+
rtrim(val: any): DatabaseAggregateCommand;
|
417
|
+
second(val: any): DatabaseAggregateCommand;
|
418
|
+
setDifference(val: any): DatabaseAggregateCommand;
|
419
|
+
setEquals(val: any): DatabaseAggregateCommand;
|
420
|
+
setIntersection(val: any): DatabaseAggregateCommand;
|
421
|
+
setIsSubset(val: any): DatabaseAggregateCommand;
|
422
|
+
setUnion(val: any): DatabaseAggregateCommand;
|
423
|
+
size(val: any): DatabaseAggregateCommand;
|
424
|
+
slice(val: any): DatabaseAggregateCommand;
|
425
|
+
split(val: any): DatabaseAggregateCommand;
|
426
|
+
sqrt(val: any): DatabaseAggregateCommand;
|
427
|
+
stdDevPop(val: any): DatabaseAggregateCommand;
|
428
|
+
stdDevSamp(val: any): DatabaseAggregateCommand;
|
429
|
+
strcasecmp(val: any): DatabaseAggregateCommand;
|
430
|
+
strLenBytes(val: any): DatabaseAggregateCommand;
|
431
|
+
strLenCP(val: any): DatabaseAggregateCommand;
|
432
|
+
substr(val: any): DatabaseAggregateCommand;
|
433
|
+
substrBytes(val: any): DatabaseAggregateCommand;
|
434
|
+
substrCP(val: any): DatabaseAggregateCommand;
|
435
|
+
subtract(val: any): DatabaseAggregateCommand;
|
436
|
+
sum(val: any): DatabaseAggregateCommand;
|
437
|
+
switch(val: any): DatabaseAggregateCommand;
|
438
|
+
toBool(val: any): DatabaseAggregateCommand;
|
439
|
+
toDate(val: any): DatabaseAggregateCommand;
|
440
|
+
toDecimal(val: any): DatabaseAggregateCommand;
|
441
|
+
toDouble(val: any): DatabaseAggregateCommand;
|
442
|
+
toInt(val: any): DatabaseAggregateCommand;
|
443
|
+
toLong(val: any): DatabaseAggregateCommand;
|
444
|
+
toObjectId(val: any): DatabaseAggregateCommand;
|
445
|
+
toString(val: any): DatabaseAggregateCommand;
|
446
|
+
toLower(val: any): DatabaseAggregateCommand;
|
447
|
+
toUpper(val: any): DatabaseAggregateCommand;
|
448
|
+
trim(val: any): DatabaseAggregateCommand;
|
449
|
+
trunc(val: any): DatabaseAggregateCommand;
|
450
|
+
type(val: any): DatabaseAggregateCommand;
|
451
|
+
week(val: any): DatabaseAggregateCommand;
|
452
|
+
year(val: any): DatabaseAggregateCommand;
|
453
|
+
zip(val: any): DatabaseAggregateCommand;
|
454
|
+
};
|
455
|
+
}
|
456
|
+
|
457
|
+
class DatabaseAggregateCommand {}
|
458
|
+
|
459
|
+
enum LOGIC_COMMANDS_LITERAL {
|
460
|
+
AND = "and",
|
461
|
+
OR = "or",
|
462
|
+
NOT = "not",
|
463
|
+
NOR = "nor",
|
464
|
+
}
|
465
|
+
|
466
|
+
class DatabaseLogicCommand {
|
467
|
+
and(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand;
|
468
|
+
or(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand;
|
469
|
+
nor(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand;
|
470
|
+
not(expression: DatabaseLogicCommand): DatabaseLogicCommand;
|
471
|
+
}
|
472
|
+
|
473
|
+
enum QUERY_COMMANDS_LITERAL {
|
474
|
+
// comparison
|
475
|
+
EQ = "eq",
|
476
|
+
NEQ = "neq",
|
477
|
+
GT = "gt",
|
478
|
+
GTE = "gte",
|
479
|
+
LT = "lt",
|
480
|
+
LTE = "lte",
|
481
|
+
IN = "in",
|
482
|
+
NIN = "nin",
|
483
|
+
// geo
|
484
|
+
GEO_NEAR = "geoNear",
|
485
|
+
GEO_WITHIN = "geoWithin",
|
486
|
+
GEO_INTERSECTS = "geoIntersects",
|
487
|
+
// element
|
488
|
+
EXISTS = "exists",
|
489
|
+
// evaluation
|
490
|
+
MOD = "mod",
|
491
|
+
// array
|
492
|
+
ALL = "all",
|
493
|
+
ELEM_MATCH = "elemMatch",
|
494
|
+
SIZE = "size",
|
495
|
+
}
|
496
|
+
|
497
|
+
class DatabaseQueryCommand extends DatabaseLogicCommand {
|
498
|
+
eq(val: any): DatabaseLogicCommand;
|
499
|
+
neq(val: any): DatabaseLogicCommand;
|
500
|
+
gt(val: any): DatabaseLogicCommand;
|
501
|
+
gte(val: any): DatabaseLogicCommand;
|
502
|
+
lt(val: any): DatabaseLogicCommand;
|
503
|
+
lte(val: any): DatabaseLogicCommand;
|
504
|
+
in(val: any[]): DatabaseLogicCommand;
|
505
|
+
nin(val: any[]): DatabaseLogicCommand;
|
506
|
+
|
507
|
+
exists(val: boolean): DatabaseLogicCommand;
|
508
|
+
|
509
|
+
mod(divisor: number, remainder: number): DatabaseLogicCommand;
|
510
|
+
|
511
|
+
all(val: any[]): DatabaseLogicCommand;
|
512
|
+
elemMatch(val: any): DatabaseLogicCommand;
|
513
|
+
size(val: number): DatabaseLogicCommand;
|
514
|
+
|
515
|
+
geoNear(options: IGeoNearCommandOptions): DatabaseLogicCommand;
|
516
|
+
geoWithin(options: IGeoWithinCommandOptions): DatabaseLogicCommand;
|
517
|
+
geoIntersects(
|
518
|
+
options: IGeoIntersectsCommandOptions,
|
519
|
+
): DatabaseLogicCommand;
|
520
|
+
}
|
521
|
+
|
522
|
+
enum PROJECTION_COMMANDS_LITERAL {
|
523
|
+
SLICE = "slice",
|
524
|
+
}
|
525
|
+
|
526
|
+
class DatabaseProjectionCommand {}
|
527
|
+
|
528
|
+
enum UPDATE_COMMANDS_LITERAL {
|
529
|
+
// field
|
530
|
+
SET = "set",
|
531
|
+
REMOVE = "remove",
|
532
|
+
INC = "inc",
|
533
|
+
MUL = "mul",
|
534
|
+
MIN = "min",
|
535
|
+
MAX = "max",
|
536
|
+
RENAME = "rename",
|
537
|
+
// bitwise
|
538
|
+
BIT = "bit",
|
539
|
+
// array
|
540
|
+
PUSH = "push",
|
541
|
+
POP = "pop",
|
542
|
+
SHIFT = "shift",
|
543
|
+
UNSHIFT = "unshift",
|
544
|
+
ADD_TO_SET = "addToSet",
|
545
|
+
PULL = "pull",
|
546
|
+
PULL_ALL = "pullAll",
|
547
|
+
}
|
548
|
+
|
549
|
+
class DatabaseUpdateCommand {}
|
550
|
+
|
551
|
+
class Batch {}
|
552
|
+
|
553
|
+
/**
|
554
|
+
* A contract that all API provider must adhere to
|
555
|
+
*/
|
556
|
+
class APIBaseContract<
|
557
|
+
PromiseReturn,
|
558
|
+
CallbackReturn,
|
559
|
+
Param extends IAPIParam,
|
560
|
+
Context = any,
|
561
|
+
> {
|
562
|
+
getContext(param: Param): Context;
|
563
|
+
|
564
|
+
/**
|
565
|
+
* In case of callback-style invocation, this function will be called
|
566
|
+
*/
|
567
|
+
getCallbackReturn(param: Param, context: Context): CallbackReturn;
|
568
|
+
|
569
|
+
getFinalParam<T extends Param>(param: Param, context: Context): T;
|
570
|
+
|
571
|
+
run<T extends Param>(param: T): Promise<PromiseReturn>;
|
572
|
+
}
|
573
|
+
|
574
|
+
interface IGeoPointConstructor {
|
575
|
+
new(longitude: number, latitide: number): GeoPoint;
|
576
|
+
new(geojson: IGeoJSONPoint): GeoPoint;
|
577
|
+
(longitude: number, latitide: number): GeoPoint;
|
578
|
+
(geojson: IGeoJSONPoint): GeoPoint;
|
579
|
+
}
|
580
|
+
|
581
|
+
interface IGeoMultiPointConstructor {
|
582
|
+
new(points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint;
|
583
|
+
(points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint;
|
584
|
+
}
|
585
|
+
|
586
|
+
interface IGeoLineStringConstructor {
|
587
|
+
new(points: GeoPoint[] | IGeoJSONLineString): GeoLineString;
|
588
|
+
(points: GeoPoint[] | IGeoJSONLineString): GeoLineString;
|
589
|
+
}
|
590
|
+
|
591
|
+
interface IGeoMultiLineStringConstructor {
|
592
|
+
new(
|
593
|
+
lineStrings: GeoLineString[] | IGeoJSONMultiLineString,
|
594
|
+
): GeoMultiLineString;
|
595
|
+
(
|
596
|
+
lineStrings: GeoLineString[] | IGeoJSONMultiLineString,
|
597
|
+
): GeoMultiLineString;
|
598
|
+
}
|
599
|
+
|
600
|
+
interface IGeoPolygonConstructor {
|
601
|
+
new(lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon;
|
602
|
+
(lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon;
|
603
|
+
}
|
604
|
+
|
605
|
+
interface IGeoMultiPolygonConstructor {
|
606
|
+
new(polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon;
|
607
|
+
(polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon;
|
608
|
+
}
|
609
|
+
|
610
|
+
interface IGeo {
|
611
|
+
Point: IGeoPointConstructor;
|
612
|
+
MultiPoint: IGeoMultiPointConstructor;
|
613
|
+
LineString: IGeoLineStringConstructor;
|
614
|
+
MultiLineString: IGeoMultiLineStringConstructor;
|
615
|
+
Polygon: IGeoPolygonConstructor;
|
616
|
+
MultiPolygon: IGeoMultiPolygonConstructor;
|
617
|
+
}
|
618
|
+
|
619
|
+
interface IGeoJSONPoint {
|
620
|
+
type: "Point";
|
621
|
+
coordinates: [number, number];
|
622
|
+
}
|
623
|
+
|
624
|
+
interface IGeoJSONMultiPoint {
|
625
|
+
type: "MultiPoint";
|
626
|
+
coordinates: Array<[number, number]>;
|
627
|
+
}
|
628
|
+
|
629
|
+
interface IGeoJSONLineString {
|
630
|
+
type: "LineString";
|
631
|
+
coordinates: Array<[number, number]>;
|
632
|
+
}
|
633
|
+
|
634
|
+
interface IGeoJSONMultiLineString {
|
635
|
+
type: "MultiLineString";
|
636
|
+
coordinates: Array<Array<[number, number]>>;
|
637
|
+
}
|
638
|
+
|
639
|
+
interface IGeoJSONPolygon {
|
640
|
+
type: "Polygon";
|
641
|
+
coordinates: Array<Array<[number, number]>>;
|
642
|
+
}
|
643
|
+
|
644
|
+
interface IGeoJSONMultiPolygon {
|
645
|
+
type: "MultiPolygon";
|
646
|
+
coordinates: Array<Array<Array<[number, number]>>>;
|
647
|
+
}
|
648
|
+
|
649
|
+
type IGeoJSONObject =
|
650
|
+
| IGeoJSONPoint
|
651
|
+
| IGeoJSONMultiPoint
|
652
|
+
| IGeoJSONLineString
|
653
|
+
| IGeoJSONMultiLineString
|
654
|
+
| IGeoJSONPolygon
|
655
|
+
| IGeoJSONMultiPolygon;
|
656
|
+
|
657
|
+
abstract class GeoPoint {
|
658
|
+
longitude: number;
|
659
|
+
latitude: number;
|
660
|
+
|
661
|
+
constructor(longitude: number, latitude: number);
|
662
|
+
|
663
|
+
toJSON(): Record<string, any>;
|
664
|
+
toString(): string;
|
665
|
+
}
|
666
|
+
|
667
|
+
abstract class GeoMultiPoint {
|
668
|
+
points: GeoPoint[];
|
669
|
+
|
670
|
+
constructor(points: GeoPoint[]);
|
671
|
+
|
672
|
+
toJSON(): IGeoJSONMultiPoint;
|
673
|
+
toString(): string;
|
674
|
+
}
|
675
|
+
|
676
|
+
abstract class GeoLineString {
|
677
|
+
points: GeoPoint[];
|
678
|
+
|
679
|
+
constructor(points: GeoPoint[]);
|
680
|
+
|
681
|
+
toJSON(): IGeoJSONLineString;
|
682
|
+
toString(): string;
|
683
|
+
}
|
684
|
+
|
685
|
+
abstract class GeoMultiLineString {
|
686
|
+
lines: GeoLineString[];
|
687
|
+
|
688
|
+
constructor(lines: GeoLineString[]);
|
689
|
+
|
690
|
+
toJSON(): IGeoJSONMultiLineString;
|
691
|
+
toString(): string;
|
692
|
+
}
|
693
|
+
|
694
|
+
abstract class GeoPolygon {
|
695
|
+
lines: GeoLineString[];
|
696
|
+
|
697
|
+
constructor(lines: GeoLineString[]);
|
698
|
+
|
699
|
+
toJSON(): IGeoJSONPolygon;
|
700
|
+
toString(): string;
|
701
|
+
}
|
702
|
+
|
703
|
+
abstract class GeoMultiPolygon {
|
704
|
+
polygons: GeoPolygon[];
|
705
|
+
|
706
|
+
constructor(polygons: GeoPolygon[]);
|
707
|
+
|
708
|
+
toJSON(): IGeoJSONMultiPolygon;
|
709
|
+
toString(): string;
|
710
|
+
}
|
711
|
+
|
712
|
+
type GeoInstance =
|
713
|
+
| GeoPoint
|
714
|
+
| GeoMultiPoint
|
715
|
+
| GeoLineString
|
716
|
+
| GeoMultiLineString
|
717
|
+
| GeoPolygon
|
718
|
+
| GeoMultiPolygon;
|
719
|
+
|
720
|
+
interface IGeoNearCommandOptions {
|
721
|
+
geometry: GeoPoint;
|
722
|
+
maxDistance?: number | undefined;
|
723
|
+
minDistance?: number | undefined;
|
724
|
+
}
|
725
|
+
|
726
|
+
interface IGeoWithinCommandOptions {
|
727
|
+
geometry: GeoPolygon | GeoMultiPolygon;
|
728
|
+
}
|
729
|
+
|
730
|
+
interface IGeoIntersectsCommandOptions {
|
731
|
+
geometry:
|
732
|
+
| GeoPoint
|
733
|
+
| GeoMultiPoint
|
734
|
+
| GeoLineString
|
735
|
+
| GeoMultiLineString
|
736
|
+
| GeoPolygon
|
737
|
+
| GeoMultiPolygon;
|
738
|
+
}
|
739
|
+
|
740
|
+
interface IServerDateOptions {
|
741
|
+
offset: number;
|
742
|
+
}
|
743
|
+
|
744
|
+
abstract class ServerDate {
|
745
|
+
readonly options: IServerDateOptions;
|
746
|
+
constructor(options?: IServerDateOptions);
|
747
|
+
}
|
748
|
+
|
749
|
+
interface IRegExpOptions {
|
750
|
+
regexp: string;
|
751
|
+
options?: string | undefined;
|
752
|
+
}
|
753
|
+
|
754
|
+
interface IRegExpConstructor {
|
755
|
+
new(options: IRegExpOptions): RegExp;
|
756
|
+
(options: IRegExpOptions): RegExp;
|
757
|
+
}
|
758
|
+
|
759
|
+
abstract class RegExp {
|
760
|
+
readonly regexp: string;
|
761
|
+
readonly options: string;
|
762
|
+
constructor(options: IRegExpOptions);
|
763
|
+
}
|
764
|
+
|
765
|
+
type DocumentId = string | number;
|
766
|
+
|
767
|
+
interface IDocumentData {
|
768
|
+
_id?: DocumentId | undefined;
|
769
|
+
[key: string]: any;
|
770
|
+
}
|
771
|
+
|
772
|
+
type IDBAPIParam = IAPIParam;
|
773
|
+
|
774
|
+
interface IAddDocumentOptions extends IDBAPIParam {
|
775
|
+
data: IDocumentData;
|
776
|
+
}
|
777
|
+
|
778
|
+
type IGetDocumentOptions = IDBAPIParam;
|
779
|
+
|
780
|
+
type ICountDocumentOptions = IDBAPIParam;
|
781
|
+
|
782
|
+
interface IUpdateDocumentOptions extends IDBAPIParam {
|
783
|
+
data: IUpdateCondition;
|
784
|
+
}
|
785
|
+
|
786
|
+
interface IUpdateSingleDocumentOptions extends IDBAPIParam {
|
787
|
+
data: IUpdateCondition;
|
788
|
+
}
|
789
|
+
|
790
|
+
interface ISetDocumentOptions extends IDBAPIParam {
|
791
|
+
data: IUpdateCondition;
|
792
|
+
}
|
793
|
+
|
794
|
+
interface ISetSingleDocumentOptions extends IDBAPIParam {
|
795
|
+
data: IUpdateCondition;
|
796
|
+
}
|
797
|
+
|
798
|
+
interface IRemoveDocumentOptions extends IDBAPIParam {
|
799
|
+
query: IQueryCondition;
|
800
|
+
}
|
801
|
+
|
802
|
+
type IRemoveSingleDocumentOptions = IDBAPIParam;
|
803
|
+
|
804
|
+
interface IWatchOptions {
|
805
|
+
// server realtime data init & change event
|
806
|
+
onChange: (snapshot: ISnapshot) => void;
|
807
|
+
// error while connecting / listening
|
808
|
+
onError: (error: any) => void;
|
809
|
+
}
|
810
|
+
|
811
|
+
interface ISnapshot {
|
812
|
+
id: number;
|
813
|
+
docChanges: ISingleDBEvent[];
|
814
|
+
docs: Record<string, any>;
|
815
|
+
type?: SnapshotType | undefined;
|
816
|
+
}
|
817
|
+
|
818
|
+
type SnapshotType = "init";
|
819
|
+
|
820
|
+
interface ISingleDBEvent {
|
821
|
+
id: number;
|
822
|
+
dataType: DataType;
|
823
|
+
queueType: QueueType;
|
824
|
+
docId: string;
|
825
|
+
doc: Record<string, any>;
|
826
|
+
updatedFields?: Record<string, any> | undefined;
|
827
|
+
removedFields?: string[] | undefined;
|
828
|
+
}
|
829
|
+
|
830
|
+
type DataType = "init" | "update" | "replace" | "add" | "remove" | "limit";
|
831
|
+
|
832
|
+
type QueueType = "init" | "enqueue" | "dequeue" | "update";
|
833
|
+
|
834
|
+
interface IQueryCondition {
|
835
|
+
[key: string]: any;
|
836
|
+
}
|
837
|
+
|
838
|
+
type IStringQueryCondition = string;
|
839
|
+
|
840
|
+
interface IQueryResult extends IAPISuccessParam {
|
841
|
+
data: IDocumentData[];
|
842
|
+
}
|
843
|
+
|
844
|
+
interface IQuerySingleResult extends IAPISuccessParam {
|
845
|
+
data: IDocumentData;
|
846
|
+
}
|
847
|
+
|
848
|
+
interface IUpdateCondition {
|
849
|
+
[key: string]: any;
|
850
|
+
}
|
851
|
+
|
852
|
+
type IStringUpdateCondition = string;
|
853
|
+
|
854
|
+
interface IAddResult extends IAPISuccessParam {
|
855
|
+
_id: DocumentId;
|
856
|
+
}
|
857
|
+
|
858
|
+
interface IUpdateResult extends IAPISuccessParam {
|
859
|
+
stats: {
|
860
|
+
updated: number;
|
861
|
+
// created: number,
|
862
|
+
};
|
863
|
+
}
|
864
|
+
|
865
|
+
interface ISetResult extends IAPISuccessParam {
|
866
|
+
_id: DocumentId;
|
867
|
+
stats: {
|
868
|
+
updated: number;
|
869
|
+
created: number;
|
870
|
+
};
|
871
|
+
}
|
872
|
+
|
873
|
+
interface IRemoveResult extends IAPISuccessParam {
|
874
|
+
stats: {
|
875
|
+
removed: number;
|
876
|
+
};
|
877
|
+
}
|
878
|
+
|
879
|
+
interface ICountResult extends IAPISuccessParam {
|
880
|
+
total: number;
|
881
|
+
}
|
882
|
+
}
|
883
|
+
|
884
|
+
type Optional<T> = { [K in keyof T]+?: T[K] };
|
885
|
+
|
886
|
+
type OQ<
|
887
|
+
T extends Optional<
|
888
|
+
Record<"complete" | "success" | "fail", (...args: any[]) => any>
|
889
|
+
>,
|
890
|
+
> =
|
891
|
+
| (RQ<T> & Required<Pick<T, "success">>)
|
892
|
+
| (RQ<T> & Required<Pick<T, "fail">>)
|
893
|
+
| (RQ<T> & Required<Pick<T, "complete">>)
|
894
|
+
| (RQ<T> & Required<Pick<T, "success" | "fail">>)
|
895
|
+
| (RQ<T> & Required<Pick<T, "success" | "complete">>)
|
896
|
+
| (RQ<T> & Required<Pick<T, "fail" | "complete">>)
|
897
|
+
| (RQ<T> & Required<Pick<T, "fail" | "complete" | "success">>);
|
898
|
+
|
899
|
+
type RQ<
|
900
|
+
T extends Optional<
|
901
|
+
Record<"complete" | "success" | "fail", (...args: any[]) => any>
|
902
|
+
>,
|
903
|
+
> = Pick<T, Exclude<keyof T, "complete" | "success" | "fail">>;
|