We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba1119f commit e985f34Copy full SHA for e985f34
packages/client/src/scw/locality.ts
@@ -13,3 +13,27 @@ export type Zone =
13
| 'pl-waw-3'
14
| (string & {})
15
/* eslint-enable @typescript-eslint/ban-types */
16
+
17
+export type ApiLocality =
18
+ | { type: 'zone'; zones: Zone[] }
19
+ | { type: 'region'; regions: Region[] }
20
+ | { type: 'global' }
21
+ | { type: 'unspecified' }
22
23
24
+export function toApiLocality(
25
+ legacy?: { zones?: Zone[]; regions?: Region[] }
26
+): ApiLocality {
27
+ if (!legacy) {
28
+ return { type: 'unspecified' }
29
+ }
30
+ const { zones, regions } = legacy
31
+ if (zones && zones.length > 0) {
32
+ return { type: 'zone', zones }
33
34
+ if (regions && regions.length > 0) {
35
+ return { type: 'region', regions }
36
37
38
+ return { type: 'global' }
39
+}
0 commit comments