-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathtypes.ts
More file actions
269 lines (236 loc) · 6.23 KB
/
types.ts
File metadata and controls
269 lines (236 loc) · 6.23 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
// This can be removed if at any point we get to generate a correct TypeScript schema from the Platform API
// HyperSchema, but that's not easy due to API variants and some other header-selectable serialization expansion
// options like `Accept-Inclusion` and `Accept-Expansion`.
export type DeepRequired<T> = T extends object
? { [K in keyof T]-?: DeepRequired<T[K]> }
: T;
type ResourceReference = {
id: string
name: string
}
type AppReference = ResourceReference
type AddonReference = ResourceReference
type CommonRuntimeRegion = 'eu' | 'us'
type PrivateSpaceRegion =
'california' | 'dublin' | 'frankfurt' | 'london' | 'montreal' | 'mumbai'
| 'ohio' | 'oregon' | 'paris' | 'singapore' | 'sydney' | 'tokyo' | 'virginia'
export type InfoResponse = {
addon: AddonReference
app: AppReference
created_at: string
features: {
continuous_protection: {
enabled: boolean
}
credentials: {
current_count: number
enabled: boolean
}
data_encryption: {
enabled: boolean
}
fork: {
enabled: boolean
}
highly_available: {
enabled: boolean
}
rollback: {
earliest_time: null | string
enabled: boolean
latest_time: null | string
}
}
forked_from: AddonReference | null
plan_limits: Array<PlanLimit>
pools: Array<PoolInfoResponse>
quotas: Array<Quota>
region: CommonRuntimeRegion | PrivateSpaceRegion
status: 'available' | 'migrating' | 'modifying' | 'provisioning' | 'unavailable'
tier: 'advanced'
version: string
}
export type Quotas = { items: Array<Quota> }
export type Quota = {
critical_gb: null | number
current_gb: null | number
enforcement_action: 'none' | 'notify' | 'restrict'
enforcement_active: boolean
type: string
warning_gb: null | number
}
type TableLimit = {
current: number
limit: number
name: 'table-limit'
}
type ConnectionLimit = {
current: number
limit: number
name: 'connection-limit'
}
type StorageLimitInGb = {
current: number
limit: number
name: 'storage-limit-in-gb'
}
export type PlanLimit = ConnectionLimit | StorageLimitInGb | TableLimit
export type PostgresLevelInfo = {
memory_in_gb: number
name: string
vcpu: number
}
export type PostgresLevelsResponse = {
items: Array<PostgresLevelInfo>
}
type BaseChange = {
current: boolean | null | number | string
name: string
previous: boolean | null | number | string
}
type PoolChange = {
pool: string
} & BaseChange
export type ScaleResponse = {
changes: Array<PoolChange>
}
type SettingsChange = BaseChange
export type SettingsChangeResponse = {
changes: Array<SettingsChange>
}
export type SettingsResponse = {
items: Array<{
current: boolean | null | number | string
default: boolean | null | number | string
name: string
reboot_required: boolean
}>
}
export type CreatePoolParameters = {
count: number
level: string
name?: string
}
export type ComputeInstance = {
id: string
level: string
name: string
role: string // will be good to have an enum for the valid roles
status: string // will be good to have an enum for the valid statuses
updated_at: string
}
export type ConnectionEndpoint = {
host: string
port: number
status: 'available' | 'degraded' | 'deprovisioning' | 'modifying'
}
export type PoolInfoResponse = {
compute_instances: Array<ComputeInstance>
connections_used: null | number
endpoints: Array<ConnectionEndpoint>
expected_connection_limit: number
expected_count: number
expected_level: string
id: string
metrics_sources: {
cluster: null | string
database: null | string
leader: null | string
}
name: string
status: 'available' | 'modifying' | 'provisioning' | 'unknown'
wait_status: {
message: null | string
waiting: boolean
}
}
export type CredentialsInfo = { items: Array<AdvancedCredentialInfo> }
export type CredentialInfo = AdvancedCredentialInfo | NonAdvancedCredentialInfo
export interface AdvancedCredentialInfo extends Record<string, unknown> {
database: string
host: string
id: string
name: string
port: string
roles: Array<{
password: string
state: string
user: string
}>
state: string
type: 'additional' | 'owner'
}
export function isAdvancedCredentialInfo(credential: CredentialInfo): credential is AdvancedCredentialInfo {
return 'type' in credential
}
export type PricingInfo = {
billing_period: 'month'
billing_unit: 'compute' | 'gigabyte'
included_units?: number
product_description: string
rate: number // in cents
}
export type TierPricingInfo = Record<string, PricingInfo>
export type PricingInfoResponse = Record<string, TierPricingInfo>
type NonAdvancedCredentialState = 'active' | 'archived' | 'enabling' | 'revoked' | 'revoking'
type NonAdvancedCredential = {
connections?: null | number
password: string
state: NonAdvancedCredentialState
user: string
}
type NonAdvancedCredentialStoreState = 'active' | 'archived' | 'provisioning' | 'revoking' | 'rotating' | 'rotation_completed' | 'wait_for_provisioning'
export interface NonAdvancedCredentialInfo extends Record<string, unknown> {
credentials: Array<NonAdvancedCredential>
database: string
host: string
name: string
port: string
state: NonAdvancedCredentialStoreState
uuid: string
}
export type ExtendedPostgresLevelInfo = {
pricing: PricingInfo | undefined
} & PostgresLevelInfo
export type Maintenance = {
'addon': {
'attachments': string[];
'kind': string;
'name': string;
'plan': string;
'uuid'?: string;
'window': string | null;
};
'app': {
'name': string;
'uuid'?: string;
};
'completed_at': string | null;
'duration_seconds': string | null;
'method': string;
'previously_scheduled_for': string | null;
'reason': string;
'required_by': string | null;
'scheduled_for': string | null;
'server_created_at': string;
'started_at': string | null;
'status': MaintenanceStatus;
'window': string | null;
}
export type Window = {
previous_window: string | null;
previously_scheduled_at: string | null;
scheduled_at: string | null;
window: string | null;
}
export enum MaintenanceStatus {
completed = 'completed',
none = 'none',
pending = 'pending',
preparing = 'preparing',
ready = 'ready',
running = 'running',
}
export type UpgradeResponse = {
message: string
}