-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.ts
More file actions
55 lines (48 loc) · 1.67 KB
/
Copy pathinterfaces.ts
File metadata and controls
55 lines (48 loc) · 1.67 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
import type { DateTime } from 'luxon'
import type { Attributes } from '../types.ts'
import { type Mode, Product } from '../enums.ts'
export interface IBaseDeviceModel {
readonly derogationEndDate: DateTime | null
readonly id: string
readonly name: string
readonly previousMode: PreviousMode
readonly product: Product
readonly update: (data: Partial<Attributes>) => void
}
export interface IDeviceModel extends IBaseDeviceModel {
readonly data: Attributes
readonly productKey: string
readonly productName: string
}
export type PreviousMode = Exclude<Mode, Mode.stop>
const productMapping: Record<string, Product> = {
/* eslint-disable @typescript-eslint/naming-convention, unicorn/no-unused-properties */
// V1
'9420ae048da545c88fc6274d204dd25f': Product.v1,
// V2
'4fc968a21e7243b390e9ede6f1c6465d': Product.v2,
'51d16c22a5f74280bc3cfe9ebcdc6402': Product.v2,
// V3
b8c6657b66c34148b4dee64d615cefc7: Product.v2,
b9a67b6ce24b437d9794103fd317e627: Product.v2,
// V4
'46409c7f29d4411c85a3a46e5ee3703e': Product.v4,
'9dacde7ef459421eaf8dc4bea9385634': Product.v4,
// Glow
'2fd622e45283470f9e27e8e6167d7533': Product.glow,
cffa0df68a52449085c5d1e72c2f6bb0: Product.glow,
// Onyx
bb10d064f8de409db633b750faa22a52: Product.glow,
// Shine
'2884feb88e0b4f30b75ea5572276a102': Product.glow,
// Pro
a77a929fcf0d4631bc4f669080376891: Product.pro,
/* eslint-enable @typescript-eslint/naming-convention, unicorn/no-unused-properties */
}
export const getProduct = (productKey: string): Product => {
const { [productKey]: product } = productMapping
if (product === undefined) {
throw new Error(`Invalid product: ${productKey}`)
}
return product
}