-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathindex.d.ts
130 lines (124 loc) · 3.64 KB
/
index.d.ts
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
import type { DataService } from 'mongodb-data-service';
type CollectionMetadata = {
/**
* Collection namespace (<database>.<collection>)
*/
namespace: string;
/**
* Indicates that colleciton is read only
*/
isReadonly: boolean;
/**
* Indicates that colleciton is a time series collection
*/
isTimeSeries: boolean;
/**
* Indicates that collection is clustered / has a clustered index
*/
isClustered: boolean;
/**
* Indicates that collection has encrypted fields in it
*/
isFLE: boolean;
/**
* Indicates that MongoDB server supports search indexes (property is exposed
* on collection because the check is relevant for collection tab and requires
* collection namespace to perform the check)
*/
isSearchIndexesSupported: boolean;
/**
* View source namespace (<database>.<collection>)
*/
sourceName?: string;
/**
* View source pipeline definition
*/
sourcePipeline?: unknown[];
/**
* Instance metadata: whether or not we are connected to the ADF
*/
isDataLake: boolean;
/**
* Instance metadata: whether or not we are connected to Atlas Cloud
*/
isAtlas: boolean;
/**
* Instance metadata: current connection server version
*/
serverVersion: string;
};
interface CollectionProps {
_id: string;
type: 'collection' | 'view' | 'timeseries';
status: 'initial' | 'fetching' | 'refreshing' | 'ready' | 'error';
statusError: string | null;
ns: string;
name: string;
database: string;
system: boolean;
oplog: boolean;
command: boolean;
special: boolean;
specialish: boolean;
normal: boolean;
readonly: boolean;
view_on: string | null;
collation: unknown;
pipeline: unknown[];
validation: unknown;
is_capped: boolean | undefined;
document_count: number | undefined;
document_size: number | undefined;
avg_document_size: number | undefined;
storage_size: number | undefined;
free_storage_size: number | undefined;
index_count: number | undefined;
index_size: number | undefined;
isTimeSeries: boolean;
isView: boolean;
/** Only relevant for a view and identifies collection/view from which this view was created. */
sourceName: string | null;
source: Collection;
properties: { id: string; options?: Record<string, unknown> }[];
is_non_existent: boolean;
}
type CollectionDataService = Pick<
DataService,
| 'collectionStats'
| 'collectionInfo'
| 'listCollections'
| 'isListSearchIndexesSupported'
>;
interface Collection extends CollectionProps {
fetch(opts: {
dataService: CollectionDataService;
fetchInfo?: boolean;
force?: boolean;
}): Promise<void>;
fetchMetadata(opts: {
dataService: CollectionDataService;
}): Promise<CollectionMetadata>;
on(evt: string, fn: (...args: any) => void);
off(evt: string, fn: (...args: any) => void);
removeListener(evt: string, fn: (...args: any) => void);
toJSON(opts?: { derived: boolean }): CollectionProps;
previousAttributes(): CollectionProps;
set(val: Partial<CollectionProps>): this;
modelType: 'Collection';
}
interface CollectionCollection extends Array<Collection> {
fetch(opts: {
dataService: CollectionDataService;
fetchInfo?: boolean;
}): Promise<void>;
toJSON(opts?: { derived: boolean }): Array<CollectionProps>;
at(index: number): Collection | undefined;
get(id: string, key?: '_id' | 'name'): Collection | undefined;
add(props: Partial<CollectionProps>): Collection;
remove(
models: string | [string] | Collection | [Collection]
): Collection | undefined;
remove(models: string[] | Collection[]): (Collection | undefined)[];
}
export default Collection;
export { CollectionCollection, CollectionMetadata, CollectionProps };