/
buckets.types.ts
128 lines (117 loc) · 2.64 KB
/
buckets.types.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
import { GenericID, TagsObj, Query } from "../../common/common.types";
type ExportBucket = {
id: string;
origin: string;
variables: string[];
}[];
interface ExportBucketOption {
start_date?: Date;
end_date?: Date;
}
interface BucketCreateInfo {
/**
* A name for the bucket.
*/
name: string;
/**
* Description for the bucket.
*/
description?: string | void;
/**
* Set if the bucket will be visible or not. Default True.
*/
visible?: boolean;
/**
* An array of tags.
*/
tags?: TagsObj[];
}
/**
* Type of data storage for a device (bucket).
*/
type DataStorageType = "immutable" | "mutable" | "legacy";
type ChunkPeriod = "day" | "week" | "month" | "quarter";
interface BucketInfoBasic extends BucketCreateInfo {
id: GenericID;
/**
* Data storage type for the bucket.
*/
profile: GenericID;
last_retention: string | void;
created_at: Date;
updated_at: Date;
chunk_period?: ChunkPeriod;
chunk_retention?: number;
data_retention?: string;
data_retention_ignore?: [];
}
type BucketInfoImmutable = Omit<BucketInfoBasic, "data_retention" | "data_retention_ignore"> & {
type: "immutable";
/**
* Chunk division to retain data in the device.
*
* Always returned for Immutable devices.
*/
chunk_period: ChunkPeriod;
/**
* Amount of chunks to retain data according to the `chunk_period`.
*
* Always returned for Immutable devices.
*/
chunk_retention: number;
};
type BucketInfoMutable = Omit<
BucketInfoBasic,
"chunk_period" | "chunk_retention" | "data_retention" | "data_retention_ignore"
> & {
type: "mutable";
};
/**
* @deprecated
*/
type BucketInfoLegacy = Omit<BucketInfoBasic, "chunk_period" | "chunk_retention"> & {
type: "legacy";
data_retention: string;
data_retention_ignore: [];
};
type BucketInfo = BucketInfoImmutable | BucketInfoMutable | BucketInfoLegacy;
interface BucketDeviceInfo {
id: GenericID;
name: string;
}
interface VariablesInfo {
variable: string;
origin: GenericID;
origin_name?: string;
amount?: number;
deleted?: {
origin: string;
created_at: string;
}[];
}
interface ListVariablesOptions {
/**
* return amount of each variable
*/
showAmount?: boolean;
/**
* return array of async deleted
*/
showDeleted?: boolean;
/**
* Change origins to array of object with id and name
*/
resolveOriginName?: boolean;
}
type BucketQuery = Query<BucketInfo, "name" | "visible" | "data_retention" | "created_at" | "updated_at">;
export {
BucketInfo,
BucketCreateInfo,
VariablesInfo,
BucketDeviceInfo,
ExportBucket,
ExportBucketOption,
BucketQuery,
ListVariablesOptions,
DataStorageType,
};