siar-client 0.1.1 → 0.1.2
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/dist/client/data/DataService.cjs +135 -0
- package/dist/client/data/DataService.d.ts.map +1 -1
- package/dist/client/data/DataService.js +2 -3
- package/dist/client/data/DataService.js.map +1 -1
- package/dist/client/information/InformationService.cjs +125 -0
- package/dist/client/information/InformationService.js +2 -3
- package/dist/client/information/InformationService.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/internal/Models.cjs +2 -0
- package/dist/internal/data/Models.cjs +2 -0
- package/dist/internal/information/Models.cjs +2 -0
- package/dist/mappers/Mappers.cjs +160 -0
- package/dist/public/Models.cjs +2 -0
- package/dist/public/SIARClient.cjs +70 -0
- package/dist/public/SIARClient.js +0 -3
- package/dist/public/SIARClient.js.map +1 -1
- package/dist/public/data/Models.cjs +20 -0
- package/dist/public/information/Models.cjs +11 -0
- package/package.json +4 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const { mapDatoHorarioToHourlyData, mapDatoDiarioToDailyData, mapDatoSemanalToWeeklyData, mapDatoMensualToMonthlyData, } = require('../../mappers/Mappers.js');
|
|
2
|
+
const { Scope, DataType, } = require('../../public/data/Models.js');
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para realizar peticiones de datos a la Web API SIAR
|
|
5
|
+
*/
|
|
6
|
+
exports.DataPetitionService = {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor del servicio
|
|
9
|
+
* @param apiKey Clave de cliente API de 50 caracteres
|
|
10
|
+
*/
|
|
11
|
+
constructor(apiKey) {
|
|
12
|
+
this.baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Datos";
|
|
13
|
+
this.apiKey = apiKey;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Construye la URL completa para una petición de datos
|
|
17
|
+
* @param tipoDatos Tipo de datos a solicitar
|
|
18
|
+
* @param ambito Ámbito de la petición
|
|
19
|
+
* @param params Parámetros de la petición
|
|
20
|
+
* @returns URL completa para la petición
|
|
21
|
+
*/
|
|
22
|
+
buildUrl(tipoDatos, ambito, params) {
|
|
23
|
+
const { ids, startDate, endDate, lastModifiedDate } = params;
|
|
24
|
+
// Construir la URL base con tipo de datos y ámbito
|
|
25
|
+
let url = `${this.baseUrl}/${tipoDatos}/${ambito}?`;
|
|
26
|
+
// Agregar los identificadores
|
|
27
|
+
const idParams = ids.map((id) => `Id=${encodeURIComponent(id)}`).join("&");
|
|
28
|
+
url += idParams;
|
|
29
|
+
// Agregar fechas y clave API
|
|
30
|
+
url += `&FechaInicial=${startDate}`;
|
|
31
|
+
url += `&FechaFinal=${endDate}`;
|
|
32
|
+
url += `&ClaveAPI=${this.apiKey}`;
|
|
33
|
+
// Agregar fecha de última modificación si está presente
|
|
34
|
+
if (lastModifiedDate) {
|
|
35
|
+
url += `&FechaUltModificacion=${lastModifiedDate}`;
|
|
36
|
+
}
|
|
37
|
+
return url;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Realiza una petición de datos a la API
|
|
41
|
+
* @param tipoDatos Tipo de datos a solicitar
|
|
42
|
+
* @param ambito Ámbito de la petición
|
|
43
|
+
* @param params Parámetros de la petición
|
|
44
|
+
* @returns Promesa con la respuesta de la API
|
|
45
|
+
*/
|
|
46
|
+
async fetchData(tipoDatos, ambito, params) {
|
|
47
|
+
const url = this.buildUrl(tipoDatos, ambito, params);
|
|
48
|
+
try {
|
|
49
|
+
const response = await fetch(url, {
|
|
50
|
+
method: "GET",
|
|
51
|
+
headers: {
|
|
52
|
+
Accept: "application/json",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
return {
|
|
57
|
+
MensajeRespuesta: null,
|
|
58
|
+
error: {
|
|
59
|
+
type: "http",
|
|
60
|
+
statusCode: response.status,
|
|
61
|
+
details: `HTTP error! status: ${response.status}`,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const data = (await response.json());
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return {
|
|
70
|
+
MensajeRespuesta: null,
|
|
71
|
+
error: {
|
|
72
|
+
type: error instanceof TypeError ? "network" : "parse",
|
|
73
|
+
details: error instanceof Error ? error.message : String(error),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Obtiene datos horarios (se registra cada media hora, 48 datos por día)
|
|
80
|
+
* @param scope Ámbito de la petición (CCAA, Provincia, Estacion)
|
|
81
|
+
* @param params Parámetros de la petición
|
|
82
|
+
* @returns Promesa con los datos horarios
|
|
83
|
+
*/
|
|
84
|
+
async fetchHourlyData(scope, params) {
|
|
85
|
+
const response = await this.fetchData(DataType.Hourly, scope, params);
|
|
86
|
+
const mappedData = response.Datos?.map(mapDatoHorarioToHourlyData) ?? [];
|
|
87
|
+
return {
|
|
88
|
+
data: mappedData,
|
|
89
|
+
message: response.MensajeRespuesta,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Obtiene datos diarios
|
|
94
|
+
* @param ambito Ámbito de la petición (CCAA, Provincia, Estacion)
|
|
95
|
+
* @param params Parámetros de la petición
|
|
96
|
+
* @returns Promesa con los datos diarios
|
|
97
|
+
*/
|
|
98
|
+
async fetchDailyData(ambito, params) {
|
|
99
|
+
const response = await this.fetchData(DataType.Daily, ambito, params);
|
|
100
|
+
const mappedData = response.Datos?.map(mapDatoDiarioToDailyData) ?? [];
|
|
101
|
+
return {
|
|
102
|
+
data: mappedData,
|
|
103
|
+
message: response.MensajeRespuesta,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Obtiene datos semanales
|
|
108
|
+
* @param ambito Ámbito de la petición (CCAA, Provincia, Estacion)
|
|
109
|
+
* @param params Parámetros de la petición
|
|
110
|
+
* @returns Promesa con los datos semanales
|
|
111
|
+
*/
|
|
112
|
+
async fetchWeeklyData(ambito, params) {
|
|
113
|
+
const response = await this.fetchData(DataType.Weekly, ambito, params);
|
|
114
|
+
const mappedData = response.Datos?.map(mapDatoSemanalToWeeklyData) ?? [];
|
|
115
|
+
return {
|
|
116
|
+
data: mappedData,
|
|
117
|
+
message: response.MensajeRespuesta,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Obtiene datos mensuales
|
|
122
|
+
* @param ambito Ámbito de la petición (CCAA, Provincia, Estacion)
|
|
123
|
+
* @param params Parámetros de la petición
|
|
124
|
+
* @returns Promesa con los datos mensuales
|
|
125
|
+
*/
|
|
126
|
+
async fetchMonthlyData(ambito, params) {
|
|
127
|
+
const response = await this.fetchData(DataType.Monthly, ambito, params);
|
|
128
|
+
const mappedData = response.Datos?.map(mapDatoMensualToMonthlyData) ?? [];
|
|
129
|
+
return {
|
|
130
|
+
data: mappedData,
|
|
131
|
+
message: response.MensajeRespuesta,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=DataService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataService.d.ts","sourceRoot":"","sources":["../../../src/client/data/DataService.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,EAEL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CACyC;IACxD,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IA2BhB;;;;;;OAMG;YACW,SAAS;
|
|
1
|
+
{"version":3,"file":"DataService.d.ts","sourceRoot":"","sources":["../../../src/client/data/DataService.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,EAEL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CACyC;IACxD,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IA2BhB;;;;;;OAMG;YACW,SAAS;IAwCvB;;;;;OAKG;IACG,eAAe,CACnB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;IAezC;;;;;OAKG;IACG,cAAc,CAClB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC;IAexC;;;;;OAKG;IACG,eAAe,CACnB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;IAezC;;;;;OAKG;IACG,gBAAgB,CACpB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC;CAc3C"}
|
|
@@ -4,13 +4,12 @@ import { Scope, DataType, } from "../../public/data/Models.js";
|
|
|
4
4
|
* Servicio para realizar peticiones de datos a la Web API SIAR
|
|
5
5
|
*/
|
|
6
6
|
export class DataPetitionService {
|
|
7
|
-
baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Datos";
|
|
8
|
-
apiKey;
|
|
9
7
|
/**
|
|
10
8
|
* Constructor del servicio
|
|
11
9
|
* @param apiKey Clave de cliente API de 50 caracteres
|
|
12
10
|
*/
|
|
13
11
|
constructor(apiKey) {
|
|
12
|
+
this.baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Datos";
|
|
14
13
|
this.apiKey = apiKey;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
@@ -63,7 +62,7 @@ export class DataPetitionService {
|
|
|
63
62
|
},
|
|
64
63
|
};
|
|
65
64
|
}
|
|
66
|
-
const data = await response.json();
|
|
65
|
+
const data = (await response.json());
|
|
67
66
|
return data;
|
|
68
67
|
}
|
|
69
68
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataService.js","sourceRoot":"","sources":["../../../src/client/data/DataService.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,EACL,QAAQ,GAKT,MAAM,6BAA6B,CAAC;AAiBrC;;GAEG;AACH,MAAM,OAAO,mBAAmB;
|
|
1
|
+
{"version":3,"file":"DataService.js","sourceRoot":"","sources":["../../../src/client/data/DataService.ts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|
2
|
+
const { TipoInformacion, } = require('../../public/information/Models.js');
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para obtener información de permisos y accesos en la Web API SIAR
|
|
5
|
+
*/
|
|
6
|
+
exports.InformationService = {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor del servicio
|
|
9
|
+
* @param apiKey Clave de cliente API de 50 caracteres
|
|
10
|
+
*/
|
|
11
|
+
constructor(apiKey) {
|
|
12
|
+
this.baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Info";
|
|
13
|
+
this.apiKey = apiKey;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Construye la URL completa para una petición de información
|
|
17
|
+
* @param tipoInformacion Tipo de información a solicitar
|
|
18
|
+
* @returns URL completa para la petición
|
|
19
|
+
*/
|
|
20
|
+
buildUrl(tipoInformacion) {
|
|
21
|
+
return `${this.baseUrl}/${tipoInformacion}?ClaveAPI=${this.apiKey}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Realiza una petición de información a la API
|
|
25
|
+
* @param tipoInformacion Tipo de información a solicitar
|
|
26
|
+
* @returns Promesa con la respuesta de la API
|
|
27
|
+
*/
|
|
28
|
+
async fetchInformation(tipoInformacion) {
|
|
29
|
+
const url = this.buildUrl(tipoInformacion);
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(url, {
|
|
32
|
+
method: "GET",
|
|
33
|
+
headers: {
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
return {
|
|
39
|
+
MensajeRespuesta: null,
|
|
40
|
+
error: {
|
|
41
|
+
type: "http",
|
|
42
|
+
statusCode: response.status,
|
|
43
|
+
details: `HTTP error! status: ${response.status}`,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const data = (await response.json());
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
MensajeRespuesta: null,
|
|
53
|
+
error: {
|
|
54
|
+
type: error instanceof TypeError ? "network" : "parse",
|
|
55
|
+
details: error instanceof Error ? error.message : String(error),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Obtiene los identificadores y descripciones de las comunidades autónomas
|
|
62
|
+
* sobre cuyos datos tiene autorización el cliente
|
|
63
|
+
* @returns Promesa con la lista de comunidades autónomas
|
|
64
|
+
*/
|
|
65
|
+
async fetchAutonomousCommunities() {
|
|
66
|
+
const response = await this.fetchInformation(TipoInformacion.CCAA);
|
|
67
|
+
const mappedData = response.Datos?.map(mapCCAA) ?? [];
|
|
68
|
+
return {
|
|
69
|
+
data: mappedData,
|
|
70
|
+
message: response.MensajeRespuesta,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Obtiene los identificadores y descripciones de las provincias
|
|
75
|
+
* sobre cuyos datos tiene autorización el cliente
|
|
76
|
+
* @returns Promesa con la lista de provincias
|
|
77
|
+
*/
|
|
78
|
+
async fetchProvinces() {
|
|
79
|
+
const response = await this.fetchInformation(TipoInformacion.Provincias);
|
|
80
|
+
const mappedData = response.Datos?.map(mapProvincia) ?? [];
|
|
81
|
+
return {
|
|
82
|
+
data: mappedData,
|
|
83
|
+
message: response.MensajeRespuesta,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Obtiene los identificadores y descripciones de las estaciones
|
|
88
|
+
* sobre cuyos datos tiene autorización el cliente
|
|
89
|
+
* @returns Promesa con la lista de estaciones
|
|
90
|
+
*/
|
|
91
|
+
async fetchStations() {
|
|
92
|
+
const response = await this.fetchInformation(TipoInformacion.Estaciones);
|
|
93
|
+
const mappedData = response.Datos?.map(mapEstacion) ?? [];
|
|
94
|
+
return {
|
|
95
|
+
data: mappedData,
|
|
96
|
+
message: response.MensajeRespuesta,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Obtiene información acerca de las limitaciones en el número de accesos
|
|
101
|
+
* máximos a realizar por minuto y por día así como la cifra real de accesos
|
|
102
|
+
* realizados por el cliente
|
|
103
|
+
* @returns Promesa con la información de accesos
|
|
104
|
+
*/
|
|
105
|
+
async fetchAccessData() {
|
|
106
|
+
const response = await this.fetchInformation(TipoInformacion.Accesos);
|
|
107
|
+
const mappedData = response.Datos
|
|
108
|
+
? mapInformacionAccesos(response.Datos)
|
|
109
|
+
: {
|
|
110
|
+
accessesCurrentMinute: 0,
|
|
111
|
+
maxAccessesPerMinute: 0,
|
|
112
|
+
accessesCurrentDay: 0,
|
|
113
|
+
maxAccessesPerDay: 0,
|
|
114
|
+
recordsCurrentMinute: 0,
|
|
115
|
+
maxRecordsPerMinute: 0,
|
|
116
|
+
recordsCurrentDay: 0,
|
|
117
|
+
maxRecordsPerDay: 0,
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
data: mappedData,
|
|
121
|
+
message: response.MensajeRespuesta,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=InformationService.js.map
|
|
@@ -4,13 +4,12 @@ import { TipoInformacion, } from "../../public/information/Models.js";
|
|
|
4
4
|
* Servicio para obtener información de permisos y accesos en la Web API SIAR
|
|
5
5
|
*/
|
|
6
6
|
export class InformationService {
|
|
7
|
-
baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Info";
|
|
8
|
-
apiKey;
|
|
9
7
|
/**
|
|
10
8
|
* Constructor del servicio
|
|
11
9
|
* @param apiKey Clave de cliente API de 50 caracteres
|
|
12
10
|
*/
|
|
13
11
|
constructor(apiKey) {
|
|
12
|
+
this.baseUrl = "https://servicio.mapama.gob.es/apisiar/API/v1/Info";
|
|
14
13
|
this.apiKey = apiKey;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
@@ -45,7 +44,7 @@ export class InformationService {
|
|
|
45
44
|
},
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
const data = await response.json();
|
|
47
|
+
const data = (await response.json());
|
|
49
48
|
return data;
|
|
50
49
|
}
|
|
51
50
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InformationService.js","sourceRoot":"","sources":["../../../src/client/information/InformationService.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,GAKhB,MAAM,oCAAoC,CAAC;AAG5C;;GAEG;AACH,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"InformationService.js","sourceRoot":"","sources":["../../../src/client/information/InformationService.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,GAKhB,MAAM,oCAAoC,CAAC;AAG5C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAK7B;;;OAGG;IACH,YAAY,MAAc;QARlB,YAAO,GACb,oDAAoD,CAAC;QAQrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,eAAgC;QAC/C,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,eAAe,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,gBAAgB,CAC5B,eAAgC;QAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,MAAM,EAAE,kBAAkB;iBAC3B;aACF,CAAC,CAAC;YAEH,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|
8
|
+
avgHumidity: dato.HumedadMedia,
|
|
9
|
+
windSpeed: dato.VelViento,
|
|
10
|
+
windDirection: dato.DirViento,
|
|
11
|
+
radiation: dato.Radiacion,
|
|
12
|
+
precipitation: dato.Precipitacion,
|
|
13
|
+
soilTemperature1: dato.TempSuelo1,
|
|
14
|
+
soilTemperature2: dato.TempSuelo2,
|
|
15
|
+
station: dato.Estacion,
|
|
16
|
+
date: dato.Fecha,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Maps DatoDiario to DailyData
|
|
21
|
+
*/
|
|
22
|
+
exports.mapDatoDiarioToDailyData =(dato) {
|
|
23
|
+
return {
|
|
24
|
+
avgTemperature: dato.TempMedia,
|
|
25
|
+
maxTemperature: dato.TempMax,
|
|
26
|
+
timeMaxTemperature: dato.HorMinTempMax,
|
|
27
|
+
minTemperature: dato.TempMin,
|
|
28
|
+
timeMinTemperature: dato.HorMinTempMin,
|
|
29
|
+
avgHumidity: dato.HumedadMedia,
|
|
30
|
+
maxHumidity: dato.HumedadMax,
|
|
31
|
+
timeMaxHumidity: dato.HorMinHumMax,
|
|
32
|
+
minHumidity: dato.HumedadMin,
|
|
33
|
+
timeMinHumidity: dato.HorMinHumMin,
|
|
34
|
+
avgWindSpeed: dato.VelViento,
|
|
35
|
+
avgWindDirection: dato.DirViento,
|
|
36
|
+
maxWindSpeed: dato.VelVientoMax,
|
|
37
|
+
timeMaxWindSpeed: dato.HorMinVelMax,
|
|
38
|
+
windDirectionAtMaxSpeed: dato.DirVientoVelMax,
|
|
39
|
+
radiation: dato.Radiacion,
|
|
40
|
+
precipitation: dato.Precipitacion,
|
|
41
|
+
soilTemperature1: dato.TempSuelo1,
|
|
42
|
+
soilTemperature2: dato.TempSuelo2,
|
|
43
|
+
etPenmanMonteith: dato.EtPMon,
|
|
44
|
+
pePenmanMonteith: dato.PePMon,
|
|
45
|
+
station: dato.Estacion,
|
|
46
|
+
date: dato.Fecha,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Maps DatoSemanal to WeeklyData
|
|
51
|
+
*/
|
|
52
|
+
exports.mapDatoSemanalToWeeklyData =(dato) {
|
|
53
|
+
return {
|
|
54
|
+
year: dato.Año,
|
|
55
|
+
week: dato.Semana,
|
|
56
|
+
avgTemperature: dato.TempMedia,
|
|
57
|
+
maxTemperature: dato.TempMax,
|
|
58
|
+
timeMaxTemperature: dato.DiaHorMinTempMax,
|
|
59
|
+
minTemperature: dato.TempMin,
|
|
60
|
+
timeMinTemperature: dato.DiaHorMinTempMin,
|
|
61
|
+
avgHumidity: dato.HumedadMedia,
|
|
62
|
+
maxHumidity: dato.HumedadMax,
|
|
63
|
+
timeMaxHumidity: dato.DiaHorMinHumMax,
|
|
64
|
+
minHumidity: dato.HumedadMin,
|
|
65
|
+
timeMinHumidity: dato.DiaHorMinHumMin,
|
|
66
|
+
avgWindSpeed: dato.VelViento,
|
|
67
|
+
avgWindDirection: dato.DirViento,
|
|
68
|
+
maxWindSpeed: dato.VelVientoMax,
|
|
69
|
+
timeMaxWindSpeed: dato.DiaHorMinVelMax,
|
|
70
|
+
windDirectionAtMaxSpeed: dato.DirVientoVelMax,
|
|
71
|
+
radiation: dato.Radiacion,
|
|
72
|
+
precipitation: dato.Precipitacion,
|
|
73
|
+
etPenmanMonteith: dato.EtPMon,
|
|
74
|
+
pePenmanMonteith: dato.PePMon,
|
|
75
|
+
station: dato.Estacion,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Maps DatoMensual to MonthlyData
|
|
80
|
+
*/
|
|
81
|
+
exports.mapDatoMensualToMonthlyData =(dato) {
|
|
82
|
+
return {
|
|
83
|
+
year: dato.Año,
|
|
84
|
+
month: dato.Mes,
|
|
85
|
+
numDays: dato.NumDias,
|
|
86
|
+
avgTemperature: dato.TempMedia,
|
|
87
|
+
maxTemperature: dato.TempMax,
|
|
88
|
+
timeMaxTemperature: dato.DiaHorMinTempMax,
|
|
89
|
+
minTemperature: dato.TempMin,
|
|
90
|
+
timeMinTemperature: dato.DiaHorMinTempMin,
|
|
91
|
+
avgHumidity: dato.HumedadMedia,
|
|
92
|
+
maxHumidity: dato.HumedadMax,
|
|
93
|
+
timeMaxHumidity: dato.DiaHorMinHumMax,
|
|
94
|
+
minHumidity: dato.HumedadMin,
|
|
95
|
+
timeMinHumidity: dato.DiaHorMinHumMin,
|
|
96
|
+
avgWindSpeed: dato.VelViento,
|
|
97
|
+
avgWindDirection: dato.DirViento,
|
|
98
|
+
maxWindSpeed: dato.VelVientoMax,
|
|
99
|
+
timeMaxWindSpeed: dato.DiaHorMinVelMax,
|
|
100
|
+
windDirectionAtMaxSpeed: dato.DirVientoVelMax,
|
|
101
|
+
radiation: dato.Radiacion,
|
|
102
|
+
precipitation: dato.Precipitacion,
|
|
103
|
+
etPenmanMonteith: dato.EtPMon,
|
|
104
|
+
pePenmanMonteith: dato.PePMon,
|
|
105
|
+
station: dato.Estacion,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Maps CCAA to AutonomousCommunity
|
|
110
|
+
*/
|
|
111
|
+
exports.mapCCAA =(ccaa) {
|
|
112
|
+
return {
|
|
113
|
+
id: ccaa.Identificador,
|
|
114
|
+
description: ccaa.Descripcion,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Maps Provincia to ProvinceInfo
|
|
119
|
+
*/
|
|
120
|
+
exports.mapProvincia =(provincia) {
|
|
121
|
+
return {
|
|
122
|
+
name: provincia.Provincia,
|
|
123
|
+
code: provincia.Codigo,
|
|
124
|
+
ccaaCode: provincia.Codigo_CCAA,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Maps Estacion to StationInfo
|
|
129
|
+
*/
|
|
130
|
+
exports.mapEstacion =(estacion) {
|
|
131
|
+
return {
|
|
132
|
+
code: estacion.Codigo,
|
|
133
|
+
description: estacion.Estacion,
|
|
134
|
+
altitude: estacion.Altitud,
|
|
135
|
+
installationDate: estacion.Fecha_Instalacion,
|
|
136
|
+
deactivationDate: estacion.Fecha_Baja,
|
|
137
|
+
timezone: estacion.Huso,
|
|
138
|
+
latitude: estacion.Latitud,
|
|
139
|
+
longitude: estacion.Longitud,
|
|
140
|
+
municipality: estacion.Termino,
|
|
141
|
+
utmX: estacion.XUTM,
|
|
142
|
+
utmY: estacion.YUTM,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Maps InformacionAccesos to AccessInformation
|
|
147
|
+
*/
|
|
148
|
+
exports.mapInformacionAccesos =(info) {
|
|
149
|
+
return {
|
|
150
|
+
accessesCurrentMinute: info.NumAccesosMinutoActual,
|
|
151
|
+
maxAccessesPerMinute: info.MaxAccesosMinuto,
|
|
152
|
+
accessesCurrentDay: info.NumAccesosDiaActual,
|
|
153
|
+
maxAccessesPerDay: info.MaxAccesosDia,
|
|
154
|
+
recordsCurrentMinute: info.RegistrosAcumuladosMinuto,
|
|
155
|
+
maxRecordsPerMinute: info.MaxRegistrosMinuto,
|
|
156
|
+
recordsCurrentDay: info.RegistrosAcumuladosDia,
|
|
157
|
+
maxRecordsPerDay: info.MaxRegistrosDia,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=Mappers.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const { DataPetitionService, } = require('../client/data/DataService.js');
|
|
2
|
+
const { InformationService } = require('../client/information/InformationService.js');
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around the SIAR API services.
|
|
5
|
+
*/
|
|
6
|
+
exports.SIARClient = {
|
|
7
|
+
constructor(apiKey) {
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
this.dataPetitionService = new DataPetitionService(this.apiKey);
|
|
10
|
+
this.informationService = new InformationService(this.apiKey);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fetch hourly data (recorded every 30 minutes, 48 data points per day).
|
|
14
|
+
* @param ambito — Scope of the petition (CCAA, Province, Station)
|
|
15
|
+
* @param params — Petition parameters
|
|
16
|
+
* @returns — Promise resolving to hourly data
|
|
17
|
+
*/
|
|
18
|
+
fetchHourlyData(scope, params) {
|
|
19
|
+
return this.dataPetitionService.fetchHourlyData(scope, params);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch daily data.
|
|
23
|
+
* @param ambito Scope of the petition (CCAA, Province, Station)
|
|
24
|
+
* @param params Petition parameters
|
|
25
|
+
* @returns Promise resolving to daily data
|
|
26
|
+
*/
|
|
27
|
+
fetchDailyData(scope, params) {
|
|
28
|
+
return this.dataPetitionService.fetchDailyData(scope, params);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetch weekly data.
|
|
32
|
+
* @param ambito Scope of the petition (CCAA, Province, Station)
|
|
33
|
+
* @param params Petition parameters
|
|
34
|
+
* @returns Promise resolving to weekly data
|
|
35
|
+
*/
|
|
36
|
+
fetchWeeklyData(scope, params) {
|
|
37
|
+
return this.dataPetitionService.fetchWeeklyData(scope, params);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch monthly data.
|
|
41
|
+
* @param ambito Scope of the petition (CCAA, Province, Station)
|
|
42
|
+
* @param params Petition parameters
|
|
43
|
+
* @returns Promise resolving to monthly data
|
|
44
|
+
*/
|
|
45
|
+
fetchMonthlyData(scope, params) {
|
|
46
|
+
return this.dataPetitionService.fetchMonthlyData(scope, params);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Fetch identifiers and descriptions of authorized autonomous communities.
|
|
50
|
+
* @returns Promise resolving to the list of autonomous communities
|
|
51
|
+
*/
|
|
52
|
+
fetchAutonomousCommunities() {
|
|
53
|
+
return this.informationService.fetchAutonomousCommunities();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fetch identifiers and descriptions of authorized provinces.
|
|
57
|
+
* @returns Promise resolving to the list of provinces
|
|
58
|
+
*/
|
|
59
|
+
fetchProvinces() {
|
|
60
|
+
return this.informationService.fetchProvinces();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Fetch identifiers and descriptions of authorized stations.
|
|
64
|
+
* @returns Promise resolving to the list of stations
|
|
65
|
+
*/
|
|
66
|
+
fetchStations() {
|
|
67
|
+
return this.informationService.fetchStations();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=SIARClient.js.map
|
|
@@ -4,9 +4,6 @@ import { InformationService } from "../client/information/InformationService.js"
|
|
|
4
4
|
* Wrapper around the SIAR API services.
|
|
5
5
|
*/
|
|
6
6
|
export class SIARClient {
|
|
7
|
-
apiKey;
|
|
8
|
-
dataPetitionService;
|
|
9
|
-
informationService;
|
|
10
7
|
constructor(apiKey) {
|
|
11
8
|
this.apiKey = apiKey;
|
|
12
9
|
this.dataPetitionService = new DataPetitionService(this.apiKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SIARClient.js","sourceRoot":"","sources":["../../src/public/SIARClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGjF;;GAEG;AACH,MAAM,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"SIARClient.js","sourceRoot":"","sources":["../../src/public/SIARClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGjF;;GAEG;AACH,MAAM,OAAO,UAAU;IAKrB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,KAAY,EAAE,MAA0B;QAC7D,OAAO,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,KAAY,EAAE,MAA0B;QAC5D,OAAO,IAAI,CAAC,mBAAmB,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,KAAY,EAAE,MAA0B;QAC7D,OAAO,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,KAAY,EAAE,MAA0B;QAC9D,OAAO,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACI,0BAA0B;QAC/B,OAAO,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,EAAE,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,aAAa;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos de datos disponibles en la API SIAR
|
|
3
|
+
*/
|
|
4
|
+
export var DataType;
|
|
5
|
+
(function (DataType) {
|
|
6
|
+
DataType["Hourly"] = "Horarios";
|
|
7
|
+
DataType["Daily"] = "Diarios";
|
|
8
|
+
DataType["Weekly"] = "Semanales";
|
|
9
|
+
DataType["Monthly"] = "Mensuales";
|
|
10
|
+
})(DataType || (DataType = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Ámbitos de petición disponibles
|
|
13
|
+
*/
|
|
14
|
+
export var Scope;
|
|
15
|
+
(function (Scope) {
|
|
16
|
+
Scope["AutonomousCommunity"] = "CCAA";
|
|
17
|
+
Scope["Province"] = "Provincia";
|
|
18
|
+
Scope["Station"] = "Estacion";
|
|
19
|
+
})(Scope || (Scope = {}));
|
|
20
|
+
//# sourceMappingURL=Models.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos de información disponibles en la API SIAR
|
|
3
|
+
*/
|
|
4
|
+
export var TipoInformacion;
|
|
5
|
+
(function (TipoInformacion) {
|
|
6
|
+
TipoInformacion["CCAA"] = "CCAA";
|
|
7
|
+
TipoInformacion["Provincias"] = "Provincias";
|
|
8
|
+
TipoInformacion["Estaciones"] = "Estaciones";
|
|
9
|
+
TipoInformacion["Accesos"] = "Accesos";
|
|
10
|
+
})(TipoInformacion || (TipoInformacion = {}));
|
|
11
|
+
//# sourceMappingURL=Models.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "siar-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A client for SIAR system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"SIAR"
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
|
-
"import": "./dist/index.js"
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"README.md"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|
|
27
|
-
"build": "tsc",
|
|
28
|
+
"build": "tsc && node scripts/build-cjs.js",
|
|
28
29
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand",
|
|
29
30
|
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --watch",
|
|
30
31
|
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage"
|