@vixoniccom/aqi 0.0.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ export interface AirQuality {
2
+ status: 'ok' | 'error' | number
3
+ data: Data
4
+ }
5
+
6
+ export interface StorageData {
7
+ item: AirQuality
8
+ date: Date
9
+ }
10
+
11
+ export interface Data {
12
+ aqi: number
13
+ idx: number
14
+ attributions: Attribution[]
15
+ city: City
16
+ dominentpol: string
17
+ iaqi: Iaqi
18
+ time: Time
19
+ forecast: Forecast
20
+ debug: Debug
21
+ }
22
+
23
+ export interface Attribution {
24
+ url: string
25
+ name: string
26
+ logo?: string
27
+ }
28
+
29
+ export interface City {
30
+ geo: number[]
31
+ name: string
32
+ url: string
33
+ location: string
34
+ }
35
+
36
+ export interface Debug {
37
+ sync: Date
38
+ }
39
+
40
+ export interface Forecast {
41
+ daily: Daily
42
+ }
43
+
44
+ export interface Daily {
45
+ o3: O3[]
46
+ pm10: O3[]
47
+ pm25: O3[]
48
+ uvi: O3[]
49
+ }
50
+
51
+ export interface O3 {
52
+ avg: number
53
+ day: Date
54
+ max: number
55
+ min: number
56
+ }
57
+
58
+ export interface Iaqi {
59
+ co: Co
60
+ dew: Co
61
+ h: Co
62
+ no2: Co
63
+ o3: Co
64
+ p: Co
65
+ pm10: Co
66
+ pm25: Co
67
+ t: Co
68
+ w: Co
69
+ }
70
+
71
+ export interface Co {
72
+ v: number
73
+ }
74
+
75
+ export interface Time {
76
+ s: Date
77
+ tz: string
78
+ v: number
79
+ iso: Date
80
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,31 @@
1
+ const API_RESPONSE_STATUS = {
2
+ OK: "ok",
3
+ ERROR: "error"
4
+ }
5
+
6
+ const assingAirQuality = (magnitude: number): { color: string, quality: string } => {
7
+ let color
8
+ let quality
9
+ if (0 <= magnitude && magnitude <= 50) {
10
+ color = '#009966'
11
+ quality = "Buena"
12
+ } else if (51 <= magnitude && magnitude <= 100) {
13
+ color = '#FFDE33'
14
+ quality = "Moderada"
15
+ } else if (101 <= magnitude && magnitude <= 150) {
16
+ color = '#FF9933'
17
+ quality = "Dañina a grupos sensibles"
18
+ } else if (151 <= magnitude && magnitude <= 200) {
19
+ color = '#CC0033'
20
+ quality = "Dañina a la salud"
21
+ } else if (201 <= magnitude && magnitude <= 300) {
22
+ color = '#660099'
23
+ quality = "Muy dañina a la salud"
24
+ } else {
25
+ color = '#7E0023'
26
+ quality = "Arriesgado"
27
+ }
28
+ return { color, quality }
29
+ }
30
+
31
+ export { API_RESPONSE_STATUS, assingAirQuality }
package/tsconfig.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2015",
4
+ "module": "es2015",
5
+ "moduleResolution": "node",
6
+ "jsx": "preserve",
7
+ "allowJs": true,
8
+ "checkJs": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "emitDecoratorMetadata": true,
11
+ "experimentalDecorators": true,
12
+ "downlevelIteration": true,
13
+ "strict": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noImplicitReturns": true,
17
+ "noImplicitAny": true,
18
+ "noImplicitThis": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "sourceMap": true,
22
+ "types": [
23
+ "node"
24
+ ],
25
+ "typeRoots": [
26
+ "./node_modules/@types",
27
+ "./src",
28
+ "./src/global.d.ts"
29
+ ]
30
+ },
31
+ "include": [
32
+ "./src/**/*"
33
+ ],
34
+ "exclude": [
35
+ "./node_modules/**/*"
36
+ ]
37
+ }