-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
1003 lines (810 loc) · 26.8 KB
/
Copy pathindex.d.ts
File metadata and controls
1003 lines (810 loc) · 26.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { ReadStream } from "fs"
export interface IAPIError {
errMsg: string
}
export interface IAPISuccessParam {
errMsg: string
}
export type IAPICompleteParam = IAPISuccessParam | IAPIError
export type IAPIFunction<T, P> = (param: P) => Promise<T> | any
export interface ICloudConfig {
env?: string | {
database?: string
functions?: string
storage?: string
}
traceUser?: boolean
database: {
realtime: {
// max reconnect retries
maxReconnect: number
// interval between reconnection attempt, does not apply to the case of network offline, unit: ms
reconnectInterval: number
// maximum tolerance on the duration of websocket connection lost, unit: s
totalConnectionTimeout: number
}
}
}
export type ICloudInitOptions = Partial<ICloudConfig>
export interface ICommonAPIConfig {
env?: string
}
export interface IICloudAPI {
init: (config?: ICloudConfig) => void
[api: string]: AnyFunction | IAPIFunction<any, any>
}
export interface ICloudService {
name: string
context: IServiceContext
getAPIs: () => { [name: string]: IAPIFunction<any, any> }
}
export interface IServiceContext {
name: string
identifiers: IRuntimeIdentifiers
request: any
debug: boolean
env?: string
}
export interface ICloudServices {
[serviceName: string]: ICloudService
}
export interface ICloudMetaData {
session_id: string
sdk_version?: string
}
export interface ICloudClass {
apiPermissions: object
config: ICloudConfig
registerService(service: ICloudService): void
}
export interface IRuntimeIdentifiers {
pluginId?: string
[key: string]: any
}
export type AnyObject = {
[x: string]: any
}
export type AnyArray = any[]
export type AnyFunction = (...args: any[]) => any
/**
* cloud
*/
// init
export function init(config?: ICloudInitOptions): void
// functions
export function callFunction(param: ICloud.CallFunctionParam): Promise<ICloud.CallFunctionResult> | void
// storage
export function uploadFile(param: ICloud.UploadFileParam): Promise<ICloud.UploadFileResult>
export function downloadFile(param: ICloud.DownloadFileParam): Promise<ICloud.DownloadFileResult>
export function getTempFileURL(param: ICloud.GetTempFileURLParam): Promise<ICloud.GetTempFileURLResult> | void
export function deleteFile(param: ICloud.DeleteFileParam): Promise<ICloud.DeleteFileResult> | void
// database
export function database(config?: DB.IDatabaseConfig): DB.Database
// open
export const openapi: Record<string, any>
export function getOpenData(param: ICloud.GetOpenDataParam): ICloud.GetOpenDataResult
export function getOpenData(param: ICloud.GetOpenDataParam): ICloud.GetOpenDataResult
// utils
export function getWXContext(): ICloud.WXContext
export function logger(): ICloud.Logger
// constants
export const DYNAMIC_CURRENT_ENV: symbol
declare namespace ICloud {
// === API: getWXContext ===
export interface BaseWXContext {
OPENID?: string
APPID?: string
UNIONID?: string
ENV?: string
SOURCE?: string
CLIENTIP?: string
CLIENTIPV6?: string
}
// === API: logger ===
export class Logger {
log(object: Record<string, any>): void
info(object: Record<string, any>): void
warn(object: Record<string, any>): void
error(object: Record<string, any>): void
}
export type WXContext = BaseWXContext & Record<string, any>
// === API: getOpenData ===
export interface GetOpenDataParam {
list: string[]
}
export interface GetOpenDataResult extends IAPISuccessParam {
list: Record<string, any>[]
}
// === API: getVoIPSign ===
export interface GetVoIPSignParam {
groupId: string
nonce: string
timestamp: number
}
export interface GetVoIPSignResult extends IAPISuccessParam {
signature: string
}
// === API: callFunction ===
export type CallFunctionData = AnyObject
export interface CallFunctionResult extends IAPISuccessParam {
result: AnyObject | string | undefined
requestID?: string
}
export interface CallFunctionParam {
name: string
data?: CallFunctionData
slow?: boolean
version?: number
config?: {
env?: string
}
}
// === end ===
// === API: uploadFile ===
export interface UploadFileResult extends IAPISuccessParam {
fileID: string
statusCode: number
}
export interface UploadFileParam {
cloudPath: string
fileContent: Buffer | ReadStream
}
// === end ===
// === API: downloadFile ===
export interface DownloadFileResult extends IAPISuccessParam {
fileContent: Buffer
statusCode: number
}
export interface DownloadFileParam {
fileID: string
}
// === end ===
// === API: getTempFileURL ===
export interface GetTempFileURLResult extends IAPISuccessParam {
fileList: GetTempFileURLResultItem[]
}
export interface GetTempFileURLResultItem {
fileID: string
tempFileURL: string
maxAge: number
status: number
errMsg: string
}
export interface GetTempFileURLParam {
fileList: (string | {
fileID: string
maxAge?: number
})[]
}
// === end ===
// === API: deleteFile ===
interface DeleteFileResult extends IAPISuccessParam {
fileList: DeleteFileResultItem[]
}
interface DeleteFileResultItem {
fileID: string
status: number
errMsg: string
}
interface DeleteFileParam {
fileList: string[]
}
// === end ===
// === API: CloudID ===
abstract class CloudID {
constructor(cloudID: string)
}
// === end ===
}
// === Functions ===
declare namespace Functions {
export interface IFunctionsServiceContext extends IServiceContext {
appConfig: {
maxReqDataSize: number
maxPollRetry: number
maxStartRetryGap: number
clientPollTimeout: number
}
}
}
// === Storage ===
declare namespace Storage {
export interface IStorageServiceContext extends IServiceContext {
appConfig: {
uploadMaxFileSize: number
getTempFileURLMaxReq: number
}
}
}
// === Utils ===
declare namespace Utils {
export interface IUtilsServiceContext extends IServiceContext {
}
}
// === Database ===
declare namespace DB {
/**
* The class of all exposed cloud database instances
*/
export class Database {
public readonly identifiers: IRuntimeIdentifiers
public config: IDatabaseConfig
public readonly command: DatabaseCommand
public readonly Geo: IGeo
public readonly serverDate: () => ServerDate
public readonly RegExp: IRegExpConstructor
public readonly debug?: boolean
private constructor(options: IDatabaseConstructorOptions)
collection(collectionName: string): CollectionReference
createCollection(collectionName: string): Promise<any>
runTransaction(run: any, retry?: number): Promise<any>
startTransaction(): Promise<any>
}
export interface IDatabaseInstanceContext {
database: Database
serviceContext: IDatabaseServiceContext
}
export class CollectionReference extends Query {
public readonly collectionName: string
constructor(name: string)
doc(docId: string | number): DocumentReference
add(options: IAddDocumentOptions): Promise<IAddResult> | void | string
aggregate(): Aggregate
}
export class DocumentReference {
constructor(collection: CollectionReference, docId: string | number)
_id: string | number
collection: CollectionReference
field(object: object): this
get(options?: IGetDocumentOptions): Promise<IQuerySingleResult> | void | string
set(options?: ISetSingleDocumentOptions): Promise<ISetResult> | void | string
update(options?: IUpdateSingleDocumentOptions): Promise<IUpdateResult> | void | string
remove(options?: IRemoveSingleDocumentOptions): Promise<IRemoveResult> | void | string
}
export class Query {
constructor(name: string)
public readonly collectionName: string
where(condition: IQueryCondition): Query
orderBy(fieldPath: string, order: string): Query
limit(max: number): Query
skip(offset: number): Query
field(object: object): Query
get(options?: IGetDocumentOptions): Promise<IQueryResult> | void | string
update(options?: IUpdateDocumentOptions): Promise<IUpdateResult> | void
remove(options?: IRemoveDocumentOptions): Promise<IRemoveResult> | void
count(options?: ICountDocumentOptions): Promise<ICountResult> | void | string
}
export class PipelineBase<T> {
addFields(val: any): T
bucket(val: any): T
bucketAuto(val: any): T
collStats(val: any): T
count(val: any): T
facet(val: any): T
geoNear(val: any): T
graphLookup(val: any): T
group(val: any): T
indexStats(val: any): T
limit(val: any): T
lookup(val: any): T
match(val: any): T
out(val: any): T
project(val: any): T
redact(val: any): T
replaceRoot(val: any): T
sample(val: any): T
skip(val: any): T
sort(val: any): T
sortByCount(val: any): T
unwind(val: any): T
end(): void
}
export class Pipeline extends PipelineBase<Pipeline> {
}
export class PipelineStage {
stage: string
val: any
}
export class Aggregate extends PipelineBase<Aggregate> {
constructor(collection: CollectionReference, stages: PipelineStage[])
collection: CollectionReference
end(): Promise<IAggregateResult> | void
}
export interface DatabaseCommand {
eq(val: any): DatabaseQueryCommand
neq(val: any): DatabaseQueryCommand
gt(val: any): DatabaseQueryCommand
gte(val: any): DatabaseQueryCommand
lt(val: any): DatabaseQueryCommand
lte(val: any): DatabaseQueryCommand
in(val: any[]): DatabaseQueryCommand
nin(val: any[]): DatabaseQueryCommand
geoNear(options: IGeoNearCommandOptions): DatabaseQueryCommand
geoWithin(options: IGeoWithinCommandOptions): DatabaseQueryCommand
geoIntersects(options: IGeoIntersectsCommandOptions): DatabaseQueryCommand
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
nor(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
not(expression: DatabaseLogicCommand): DatabaseLogicCommand
exists(val: boolean): DatabaseQueryCommand
mod(divisor: number, remainder: number): DatabaseQueryCommand
all(val: any[]): DatabaseQueryCommand
elemMatch(val: any): DatabaseQueryCommand
size(val: number): DatabaseQueryCommand
set(val: any): DatabaseUpdateCommand
remove(): DatabaseUpdateCommand
inc(val: number): DatabaseUpdateCommand
mul(val: number): DatabaseUpdateCommand
min(val: number): DatabaseUpdateCommand
max(val: number): DatabaseUpdateCommand
rename(val: string): DatabaseUpdateCommand
bit(val: number): DatabaseUpdateCommand
push(...values: any[]): DatabaseUpdateCommand
pop(): DatabaseUpdateCommand
shift(): DatabaseUpdateCommand
unshift(...values: any[]): DatabaseUpdateCommand
addToSet(val: any): DatabaseUpdateCommand
pull(val: any): DatabaseUpdateCommand
pullAll(val: any): DatabaseUpdateCommand
project: {
slice(val: number | [number, number]): DatabaseProjectionCommand
}
aggregate: {
abs(val: any): DatabaseAggregateCommand
add(val: any): DatabaseAggregateCommand
addToSet(val: any): DatabaseAggregateCommand
allElementsTrue(val: any): DatabaseAggregateCommand
and(val: any): DatabaseAggregateCommand
anyElementTrue(val: any): DatabaseAggregateCommand
arrayElemAt(val: any): DatabaseAggregateCommand
arrayToObject(val: any): DatabaseAggregateCommand
avg(val: any): DatabaseAggregateCommand
ceil(val: any): DatabaseAggregateCommand
cmp(val: any): DatabaseAggregateCommand
concat(val: any): DatabaseAggregateCommand
concatArrays(val: any): DatabaseAggregateCommand
cond(val: any): DatabaseAggregateCommand
convert(val: any): DatabaseAggregateCommand
dateFromParts(val: any): DatabaseAggregateCommand
dateToParts(val: any): DatabaseAggregateCommand
dateFromString(val: any): DatabaseAggregateCommand
dateToString(val: any): DatabaseAggregateCommand
dayOfMonth(val: any): DatabaseAggregateCommand
dayOfWeek(val: any): DatabaseAggregateCommand
dayOfYear(val: any): DatabaseAggregateCommand
divide(val: any): DatabaseAggregateCommand
eq(val: any): DatabaseAggregateCommand
exp(val: any): DatabaseAggregateCommand
filter(val: any): DatabaseAggregateCommand
first(val: any): DatabaseAggregateCommand
floor(val: any): DatabaseAggregateCommand
gt(val: any): DatabaseAggregateCommand
gte(val: any): DatabaseAggregateCommand
hour(val: any): DatabaseAggregateCommand
ifNull(val: any): DatabaseAggregateCommand
in(val: any): DatabaseAggregateCommand
indexOfArray(val: any): DatabaseAggregateCommand
indexOfBytes(val: any): DatabaseAggregateCommand
indexOfCP(val: any): DatabaseAggregateCommand
isArray(val: any): DatabaseAggregateCommand
isoDayOfWeek(val: any): DatabaseAggregateCommand
isoWeek(val: any): DatabaseAggregateCommand
isoWeekYear(val: any): DatabaseAggregateCommand
last(val: any): DatabaseAggregateCommand
let(val: any): DatabaseAggregateCommand
literal(val: any): DatabaseAggregateCommand
ln(val: any): DatabaseAggregateCommand
log(val: any): DatabaseAggregateCommand
log10(val: any): DatabaseAggregateCommand
lt(val: any): DatabaseAggregateCommand
lte(val: any): DatabaseAggregateCommand
ltrim(val: any): DatabaseAggregateCommand
map(val: any): DatabaseAggregateCommand
max(val: any): DatabaseAggregateCommand
mergeObjects(val: any): DatabaseAggregateCommand
meta(val: any): DatabaseAggregateCommand
min(val: any): DatabaseAggregateCommand
millisecond(val: any): DatabaseAggregateCommand
minute(val: any): DatabaseAggregateCommand
mod(val: any): DatabaseAggregateCommand
month(val: any): DatabaseAggregateCommand
multiply(val: any): DatabaseAggregateCommand
neq(val: any): DatabaseAggregateCommand
not(val: any): DatabaseAggregateCommand
objectToArray(val: any): DatabaseAggregateCommand
or(val: any): DatabaseAggregateCommand
pow(val: any): DatabaseAggregateCommand
push(val: any): DatabaseAggregateCommand
range(val: any): DatabaseAggregateCommand
reduce(val: any): DatabaseAggregateCommand
reverseArray(val: any): DatabaseAggregateCommand
rtrim(val: any): DatabaseAggregateCommand
second(val: any): DatabaseAggregateCommand
setDifference(val: any): DatabaseAggregateCommand
setEquals(val: any): DatabaseAggregateCommand
setIntersection(val: any): DatabaseAggregateCommand
setIsSubset(val: any): DatabaseAggregateCommand
setUnion(val: any): DatabaseAggregateCommand
size(val: any): DatabaseAggregateCommand
slice(val: any): DatabaseAggregateCommand
split(val: any): DatabaseAggregateCommand
sqrt(val: any): DatabaseAggregateCommand
stdDevPop(val: any): DatabaseAggregateCommand
stdDevSamp(val: any): DatabaseAggregateCommand
strcasecmp(val: any): DatabaseAggregateCommand
strLenBytes(val: any): DatabaseAggregateCommand
strLenCP(val: any): DatabaseAggregateCommand
substr(val: any): DatabaseAggregateCommand
substrBytes(val: any): DatabaseAggregateCommand
substrCP(val: any): DatabaseAggregateCommand
subtract(val: any): DatabaseAggregateCommand
sum(val: any): DatabaseAggregateCommand
switch(val: any): DatabaseAggregateCommand
toBool(val: any): DatabaseAggregateCommand
toDate(val: any): DatabaseAggregateCommand
toDecimal(val: any): DatabaseAggregateCommand
toDouble(val: any): DatabaseAggregateCommand
toInt(val: any): DatabaseAggregateCommand
toLong(val: any): DatabaseAggregateCommand
toObjectId(val: any): DatabaseAggregateCommand
toString(val: any): DatabaseAggregateCommand
toLower(val: any): DatabaseAggregateCommand
toUpper(val: any): DatabaseAggregateCommand
trim(val: any): DatabaseAggregateCommand
trunc(val: any): DatabaseAggregateCommand
type(val: any): DatabaseAggregateCommand
week(val: any): DatabaseAggregateCommand
year(val: any): DatabaseAggregateCommand
zip(val: any): DatabaseAggregateCommand
}
}
export enum AGGREGATE_COMMANDS_LITERAL {
AVG = 'avg',
MULTIPLY = 'multiply',
SUM = 'sum',
}
export class DatabaseAggregateCommand {
}
export enum LOGIC_COMMANDS_LITERAL {
AND = 'and',
OR = 'or',
NOT = 'not',
NOR = 'nor',
}
export class DatabaseLogicCommand {
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
nor(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
not(expression: DatabaseLogicCommand): DatabaseLogicCommand
}
export enum QUERY_COMMANDS_LITERAL {
// comparison
EQ = 'eq',
NEQ = 'neq',
GT = 'gt',
GTE = 'gte',
LT = 'lt',
LTE = 'lte',
IN = 'in',
NIN = 'nin',
// geo
GEO_NEAR = 'geoNear',
GEO_WITHIN = 'geoWithin',
GEO_INTERSECTS = 'geoIntersects',
// element
EXISTS = 'exists',
// evaluation
MOD = 'mod',
// array
ALL = 'all',
ELEM_MATCH = 'elemMatch',
SIZE = 'size',
}
export class DatabaseQueryCommand extends DatabaseLogicCommand {
eq(val: any): DatabaseLogicCommand
neq(val: any): DatabaseLogicCommand
gt(val: any): DatabaseLogicCommand
gte(val: any): DatabaseLogicCommand
lt(val: any): DatabaseLogicCommand
lte(val: any): DatabaseLogicCommand
in(val: any[]): DatabaseLogicCommand
nin(val: any[]): DatabaseLogicCommand
exists(val: boolean): DatabaseLogicCommand
mod(divisor: number, remainder: number): DatabaseLogicCommand
all(val: any[]): DatabaseLogicCommand
elemMatch(val: any): DatabaseLogicCommand
size(val: number): DatabaseLogicCommand
geoNear(options: IGeoNearCommandOptions): DatabaseLogicCommand
geoWithin(options: IGeoWithinCommandOptions): DatabaseLogicCommand
geoIntersects(options: IGeoIntersectsCommandOptions): DatabaseLogicCommand
}
export enum PROJECTION_COMMANDS_LITERAL {
SLICE = 'slice',
}
export class DatabaseProjectionCommand {
}
export enum UPDATE_COMMANDS_LITERAL {
// field
SET = 'set',
REMOVE = 'remove',
INC = 'inc',
MUL = 'mul',
MIN = 'min',
MAX = 'max',
RENAME = 'rename',
// bitwise
BIT = 'bit',
// array
PUSH = 'push',
POP = 'pop',
SHIFT = 'shift',
UNSHIFT = 'unshift',
ADD_TO_SET = 'addToSet',
PULL = 'pull',
PULL_ALL = 'pullAll',
}
export class DatabaseUpdateCommand {
}
export enum UPDATE_COMMAND_MODIFIERS_LITERAL {
EACH = 'each',
POSITION = 'position',
SLICE = 'slice',
SORT = 'sort',
}
export class DatabaseUpdateCommandModifier {
}
export class Batch {
}
export interface IDatabaseConfig {
env?: string
}
export interface IDatabaseConstructorOptions {
config?: IDatabaseConfig
context: IDatabaseServiceContext
}
export interface IAppConfig {
docSizeLimit: number
realtimePingInterval: number
realtimePongWaitTimeout: number
realtimeMaxReconnect: number
realtimeReconnectInterval: number
realtimeTotalConnectionTimeout: number
realtimeQueryEventCacheTimeout: number
}
export interface IDatabaseServiceContext extends IServiceContext {
appConfig: IAppConfig
ws?: any
}
export interface IGeoPointConstructor {
new (longitude: number, latitide: number): GeoPoint
new (geojson: IGeoJSONPoint): GeoPoint
(longitude: number, latitide: number): GeoPoint
(geojson: IGeoJSONPoint): GeoPoint
}
export interface IGeoMultiPointConstructor {
new (points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint
(points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint
}
export interface IGeoLineStringConstructor {
new (points: GeoPoint[] | IGeoJSONLineString): GeoLineString
(points: GeoPoint[] | IGeoJSONLineString): GeoLineString
}
export interface IGeoMultiLineStringConstructor {
new (lineStrings: GeoLineString[] | IGeoJSONMultiLineString): GeoMultiLineString
(lineStrings: GeoLineString[] | IGeoJSONMultiLineString): GeoMultiLineString
}
export interface IGeoPolygonConstructor {
new (lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon
(lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon
}
export interface IGeoMultiPolygonConstructor {
new (polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon
(polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon
}
export interface IGeo {
Point: IGeoPointConstructor
MultiPoint: IGeoMultiPointConstructor
LineString: IGeoLineStringConstructor
MultiLineString: IGeoMultiLineStringConstructor
Polygon: IGeoPolygonConstructor
MultiPolygon: IGeoMultiPolygonConstructor
}
export interface IGeoJSONPoint {
type: 'Point'
coordinates: [number, number]
}
export interface IGeoJSONMultiPoint {
type: 'MultiPoint'
coordinates: [number, number][]
}
export interface IGeoJSONLineString {
type: 'LineString'
coordinates: [number, number][]
}
export interface IGeoJSONMultiLineString {
type: 'MultiLineString'
coordinates: [number, number][][]
}
export interface IGeoJSONPolygon {
type: 'Polygon'
coordinates: [number, number][][]
}
export interface IGeoJSONMultiPolygon {
type: 'MultiPolygon'
coordinates: [number, number][][][]
}
export type IGeoJSONObject = IGeoJSONPoint | IGeoJSONMultiPoint | IGeoJSONLineString | IGeoJSONMultiLineString | IGeoJSONPolygon | IGeoJSONMultiPolygon
export abstract class GeoPoint {
public longitude: number
public latitude: number
constructor(longitude: number, latitude: number)
toJSON(): IGeoJSONPoint
toString(): string
}
export abstract class GeoMultiPoint {
public points: GeoPoint[]
constructor(points: GeoPoint[])
toJSON(): IGeoJSONMultiPoint
toString(): string
}
export abstract class GeoLineString {
public points: GeoPoint[]
constructor(points: GeoPoint[])
toJSON(): IGeoJSONLineString
toString(): string
}
export abstract class GeoMultiLineString {
public lines: GeoLineString[]
constructor(lines: GeoLineString[])
toJSON(): IGeoJSONMultiLineString
toString(): string
}
export abstract class GeoPolygon {
public lines: GeoLineString[]
constructor(lines: GeoLineString[])
toJSON(): IGeoJSONPolygon
toString(): string
}
export abstract class GeoMultiPolygon {
public polygons: GeoPolygon[]
constructor(polygons: GeoPolygon[])
toJSON(): IGeoJSONMultiPolygon
toString(): string
}
export type GeoInstance = GeoPoint | GeoMultiPoint | GeoLineString | GeoMultiLineString | GeoPolygon | GeoMultiPolygon
export interface IGeoNearCommandOptions {
geometry: GeoPoint
maxDistance?: number
minDistance?: number
}
export interface IGeoWithinCommandOptions {
geometry: GeoPolygon | GeoMultiPolygon
}
export interface IGeoIntersectsCommandOptions {
geometry: GeoPoint | GeoMultiPoint | GeoLineString | GeoMultiLineString | GeoPolygon | GeoMultiPolygon
}
export interface IServerDateOptions {
offset: number
}
export abstract class ServerDate {
public readonly options: IServerDateOptions
constructor(options?: IServerDateOptions)
}
export interface IRegExpOptions {
regexp: string
options?: string
}
export interface IRegExpConstructor {
new (options: IRegExpOptions): RegExp
(options: IRegExpOptions): RegExp
}
export abstract class RegExp {
public readonly regexp: string
public readonly options: string
constructor(options: IRegExpOptions)
}
export type DocumentId = string | number
export interface IDocumentData {
_id?: DocumentId
[key: string]: any
}
export interface IDBAPIParam {
}
export interface IAddDocumentOptions extends IDBAPIParam {
data: IDocumentData
}
export interface IGetDocumentOptions extends IDBAPIParam {
stringifyTest?: boolean
}
export interface ICountDocumentOptions extends IDBAPIParam {
stringifyTest?: boolean
}
export interface IUpdateDocumentOptions extends IDBAPIParam {
data: IUpdateCondition
stringifyTest?: boolean
}
export interface IUpdateSingleDocumentOptions extends IDBAPIParam {
data: IUpdateCondition
stringifyTest?: boolean
}
export interface ISetDocumentOptions extends IDBAPIParam {
data: IUpdateCondition
stringifyTest?: boolean
}
export interface ISetSingleDocumentOptions extends IDBAPIParam {
data: IUpdateCondition
stringifyTest?: boolean
}
export interface IRemoveDocumentOptions extends IDBAPIParam {
query: IQueryCondition
stringifyTest?: boolean
}
export interface IRemoveSingleDocumentOptions extends IDBAPIParam {
stringifyTest?: boolean
}
export type IQueryCondition = Record<string, any> | DatabaseLogicCommand
export interface ConditionRecord {
[key: string]: IQueryCondition
}
// export interface IQueryCondition {
// [key: string]: any
// }
export type IStringQueryCondition = string
export interface IQueryResult extends IAPISuccessParam {
data: IDocumentData[]
}
export interface IQuerySingleResult extends IAPISuccessParam {
data: IDocumentData
}
export interface IUpdateCondition {
[key: string]: any
}
export type IStringUpdateCondition = string
export interface ISetCondition {
}
export interface IAddResult extends IAPISuccessParam {
_id: DocumentId
}
export interface IUpdateResult extends IAPISuccessParam {
stats: {
updated: number
// created: number
}
}
export interface ISetResult extends IAPISuccessParam {
_id: DocumentId
stats: {
updated: number
created: number
}
}
export interface IRemoveResult extends IAPISuccessParam {
stats: {
removed: number
}
}
export interface ICountResult extends IAPISuccessParam {
total: number
}
export interface IAggregateResult extends IAPISuccessParam {
list: any[]
}
}
type Optional<T> = { [K in keyof T]+?: T[K] }
type OQ<
T extends Optional<
Record<'complete' | 'success' | 'fail', (...args: any[]) => any>
>
> =
| (RQ<T> & Required<Pick<T, 'success'>>)
| (RQ<T> & Required<Pick<T, 'fail'>>)
| (RQ<T> & Required<Pick<T, 'complete'>>)
| (RQ<T> & Required<Pick<T, 'success' | 'fail'>>)
| (RQ<T> & Required<Pick<T, 'success' | 'complete'>>)
| (RQ<T> & Required<Pick<T, 'fail' | 'complete'>>)
| (RQ<T> & Required<Pick<T, 'fail' | 'complete' | 'success'>>)
type RQ<
T extends Optional<