Changeset View
Changeset View
Standalone View
Standalone View
lib/types/device-types.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
export type DeviceType = 'ios' | 'android'; | export type DeviceType = 'ios' | 'android'; | ||||
export type Platform = DeviceType | 'web'; | export type Platform = DeviceType | 'web' | 'windows' | 'macos'; | ||||
export function isDeviceType(platform: ?string): boolean { | export function isDeviceType(platform: ?string): boolean { | ||||
return platform === 'ios' || platform === 'android'; | return platform === 'ios' || platform === 'android'; | ||||
} | } | ||||
export function assertDeviceType(deviceType: ?string): DeviceType { | export function assertDeviceType(deviceType: ?string): DeviceType { | ||||
invariant( | invariant( | ||||
deviceType === 'ios' || deviceType === 'android', | deviceType === 'ios' || deviceType === 'android', | ||||
'string is not DeviceType enum', | 'string is not DeviceType enum', | ||||
); | ); | ||||
return deviceType; | return deviceType; | ||||
} | } | ||||
export function isWebPlatform(platform: ?string): boolean { | export function isWebPlatform(platform: ?string): boolean { | ||||
return platform === 'web'; | return platform === 'web' || platform === 'windows' || platform === 'macos'; | ||||
} | } | ||||
export type DeviceTokenUpdateRequest = { | export type DeviceTokenUpdateRequest = { | ||||
+deviceToken: string, | +deviceToken: string, | ||||
+deviceType?: DeviceType, | +deviceType?: DeviceType, | ||||
+platformDetails?: PlatformDetails, | +platformDetails?: PlatformDetails, | ||||
}; | }; | ||||
export type PlatformDetails = { | export type PlatformDetails = { | ||||
+platform: Platform, | +platform: Platform, | ||||
+codeVersion?: number, | +codeVersion?: number, | ||||
+stateVersion?: number, | +stateVersion?: number, | ||||
}; | }; |