raain-model 2.6.8 → 2.6.10
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/.cursorignore +10 -0
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +166 -0
- package/LICENSE +21 -0
- package/README.md +5 -3
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +1 -1
- package/specs/REQUIREMENTS.md +42 -0
- package/specs/TECHNICAL.md +57 -0
- package/specs/cartesian/Cartesian.spec.ts +82 -0
- package/specs/cartesian/CartesianTools.spec.ts +121 -0
- package/specs/gauge/Gauge.spec.ts +39 -0
- package/specs/organization/Organization.spec.ts +38 -0
- package/specs/polar/Polar.spec.ts +267 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
- package/specs/quality/QualityTools.spec.ts +67 -0
- package/specs/quality/SpeedMatrix.spec.ts +214 -0
- package/specs/radar/Radar.spec.ts +129 -0
- package/specs/rain/Rain.spec.ts +334 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
- package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
- package/src/cartesian/CartesianValue.ts +26 -0
- package/src/cartesian/EarthMap.ts +5 -0
- package/src/cartesian/ICartesianMeasureValue.ts +22 -0
- package/src/cartesian/LatLng.ts +43 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
- package/src/gauge/GaugeMeasure.ts +42 -0
- package/{gauge/GaugeNode.js → src/gauge/GaugeNode.ts} +48 -20
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +15 -15
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/{organization/RaainNode.js → src/organization/RaainNode.ts} +91 -58
- package/{organization/TeamNode.js → src/organization/TeamNode.ts} +36 -13
- package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
- package/src/polar/PolarFilter.ts +46 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
- package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
- package/src/polar/PolarValue.ts +16 -0
- package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +15 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/{quality/index.d.ts → src/quality/index.ts} +3 -0
- package/src/quality/position/Position.ts +59 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
- package/src/radar/RadarMeasure.ts +41 -0
- package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
- package/src/radar/RadarNodeMap.ts +61 -0
- package/src/rain/MergeStrategy.ts +15 -0
- package/src/rain/RainComputation.ts +96 -0
- package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
- package/{rain/RainComputationMap.js → src/rain/RainComputationMap.ts} +55 -22
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
- package/src/rain/RainMeasure.ts +25 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/typedoc.json +31 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -40
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianTools.d.ts +0 -32
- package/cartesian/CartesianTools.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -14
- package/cartesian/CartesianValue.js +0 -17
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/EarthMap.d.ts +0 -5
- package/cartesian/EarthMap.js +0 -3
- package/cartesian/EarthMap.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -23
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -16
- package/cartesian/LatLng.js +0 -34
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RadarCartesianMeasureValue.js +0 -22
- package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
- package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RainCartesianMeasureValue.js +0 -23
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/cartesian/index.js +0 -25
- package/cartesian/index.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -30
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -85
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -24
- package/gauge/GaugeNodeMap.js +0 -40
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/gauge/index.js +0 -20
- package/gauge/index.js.map +0 -1
- package/index.js +0 -24
- package/index.js.map +0 -1
- package/organization/EventNode.d.ts +0 -22
- package/organization/EventNode.js +0 -30
- package/organization/EventNode.js.map +0 -1
- package/organization/IVersion.js +0 -3
- package/organization/IVersion.js.map +0 -1
- package/organization/Link.d.ts +0 -16
- package/organization/Link.js.map +0 -1
- package/organization/Measure.d.ts +0 -22
- package/organization/Measure.js +0 -45
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -96
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -63
- package/organization/TeamNode.js.map +0 -1
- package/organization/index.js +0 -24
- package/organization/index.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.js.map +0 -1
- package/polar/IPolarMeasureValue.d.ts +0 -19
- package/polar/IPolarMeasureValue.js +0 -3
- package/polar/IPolarMeasureValue.js.map +0 -1
- package/polar/MeasureValuePolarContainer.d.ts +0 -19
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarFilter.d.ts +0 -16
- package/polar/PolarFilter.js +0 -45
- package/polar/PolarFilter.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -51
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarMeasureValueMap.d.ts +0 -45
- package/polar/PolarMeasureValueMap.js.map +0 -1
- package/polar/PolarValue.d.ts +0 -10
- package/polar/PolarValue.js +0 -12
- package/polar/PolarValue.js.map +0 -1
- package/polar/RadarPolarMeasureValue.d.ts +0 -27
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -20
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/polar/index.js +0 -25
- package/polar/index.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -37
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -83
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -102
- package/quality/SpeedMatrixContainer.js.map +0 -1
- package/quality/history/CartesianGaugeHistory.d.ts +0 -15
- package/quality/history/CartesianGaugeHistory.js +0 -14
- package/quality/history/CartesianGaugeHistory.js.map +0 -1
- package/quality/history/CartesianRainHistory.d.ts +0 -9
- package/quality/history/CartesianRainHistory.js +0 -11
- package/quality/history/CartesianRainHistory.js.map +0 -1
- package/quality/history/PositionHistory.d.ts +0 -20
- package/quality/history/PositionHistory.js +0 -17
- package/quality/history/PositionHistory.js.map +0 -1
- package/quality/index.js +0 -26
- package/quality/index.js.map +0 -1
- package/quality/position/Position.d.ts +0 -22
- package/quality/position/Position.js +0 -50
- package/quality/position/Position.js.map +0 -1
- package/quality/position/PositionValue.d.ts +0 -9
- package/quality/position/PositionValue.js +0 -12
- package/quality/position/PositionValue.js.map +0 -1
- package/quality/tools/QualityTools.d.ts +0 -9
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -19
- package/radar/RadarMeasure.js +0 -30
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -30
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -26
- package/radar/RadarNodeMap.js +0 -44
- package/radar/RadarNodeMap.js.map +0 -1
- package/radar/index.js +0 -20
- package/radar/index.js.map +0 -1
- package/rain/MergeStrategy.d.ts +0 -13
- package/rain/MergeStrategy.js +0 -11
- package/rain/MergeStrategy.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -42
- package/rain/RainComputation.js +0 -65
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -73
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -97
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -40
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -17
- package/rain/RainMeasure.js +0 -18
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -46
- package/rain/RainNode.js.map +0 -1
- package/rain/index.js +0 -23
- package/rain/index.js.map +0 -1
- /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
- /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
- /package/{index.d.ts → src/index.ts} +0 -0
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
- /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
- /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
- /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
- /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GaugeNode = void 0;
|
|
4
|
-
const organization_1 = require("../organization");
|
|
1
|
+
import {Link, RaainNode, TeamNode} from '../organization';
|
|
2
|
+
|
|
5
3
|
/**
|
|
6
4
|
* Represents a rain gauge station in the RAAIN system.
|
|
7
5
|
* This class manages gauge data collection and configuration.
|
|
@@ -21,7 +19,29 @@ const organization_1 = require("../organization");
|
|
|
21
19
|
* });
|
|
22
20
|
* ```
|
|
23
21
|
*/
|
|
24
|
-
class GaugeNode extends
|
|
22
|
+
export class GaugeNode extends RaainNode {
|
|
23
|
+
|
|
24
|
+
/** Type identifier for gauge nodes */
|
|
25
|
+
public static TYPE = 'gauge';
|
|
26
|
+
|
|
27
|
+
/** Name of the gauge station */
|
|
28
|
+
public name: string;
|
|
29
|
+
|
|
30
|
+
/** Description of the gauge station */
|
|
31
|
+
public description: string;
|
|
32
|
+
|
|
33
|
+
/** Latitude of the gauge station */
|
|
34
|
+
public latitude: number;
|
|
35
|
+
|
|
36
|
+
/** Longitude of the gauge station */
|
|
37
|
+
public longitude: number;
|
|
38
|
+
|
|
39
|
+
/** Associated team */
|
|
40
|
+
public team: TeamNode;
|
|
41
|
+
|
|
42
|
+
/** Internal configuration storage */
|
|
43
|
+
private configurationAsJSON: string;
|
|
44
|
+
|
|
25
45
|
/**
|
|
26
46
|
* Creates a new GaugeNode instance.
|
|
27
47
|
*
|
|
@@ -36,7 +56,17 @@ class GaugeNode extends organization_1.RaainNode {
|
|
|
36
56
|
* @param json.version - Optional version string
|
|
37
57
|
* @param json.configurationAsJSON - Optional configuration object
|
|
38
58
|
*/
|
|
39
|
-
constructor(json
|
|
59
|
+
constructor(json: {
|
|
60
|
+
id: string,
|
|
61
|
+
latitude: number,
|
|
62
|
+
longitude: number,
|
|
63
|
+
name: string,
|
|
64
|
+
team: TeamNode,
|
|
65
|
+
description?: string,
|
|
66
|
+
links?: Link[] | RaainNode[],
|
|
67
|
+
version?: string,
|
|
68
|
+
configurationAsJSON?: any,
|
|
69
|
+
}) {
|
|
40
70
|
super(json);
|
|
41
71
|
this.latitude = json.latitude;
|
|
42
72
|
this.longitude = json.longitude;
|
|
@@ -45,61 +75,59 @@ class GaugeNode extends organization_1.RaainNode {
|
|
|
45
75
|
this.team = json.team;
|
|
46
76
|
this.setConfiguration(json.configurationAsJSON);
|
|
47
77
|
}
|
|
78
|
+
|
|
48
79
|
/**
|
|
49
80
|
* Sets the configuration for the gauge node.
|
|
50
81
|
*
|
|
51
82
|
* @param configuration - Configuration object or JSON string
|
|
52
83
|
*/
|
|
53
|
-
setConfiguration(configuration) {
|
|
84
|
+
public setConfiguration(configuration: string | any) {
|
|
54
85
|
let conf = configuration;
|
|
55
86
|
try {
|
|
56
87
|
conf = JSON.parse(configuration);
|
|
88
|
+
} catch (ignored) {
|
|
57
89
|
}
|
|
58
|
-
|
|
59
|
-
}
|
|
90
|
+
|
|
60
91
|
if (conf) {
|
|
61
92
|
this.configurationAsJSON = JSON.stringify(conf);
|
|
62
93
|
}
|
|
63
94
|
}
|
|
95
|
+
|
|
64
96
|
/**
|
|
65
97
|
* Gets the configuration of the gauge node.
|
|
66
98
|
*
|
|
67
99
|
* @returns The configuration object or null if not set
|
|
68
100
|
*/
|
|
69
|
-
getConfiguration() {
|
|
101
|
+
public getConfiguration(): any {
|
|
70
102
|
try {
|
|
71
103
|
return JSON.parse(this.configurationAsJSON);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
104
|
+
} catch (e) {
|
|
74
105
|
}
|
|
75
106
|
return null;
|
|
76
107
|
}
|
|
108
|
+
|
|
77
109
|
/**
|
|
78
110
|
* Converts the gauge node to a JSON object.
|
|
79
111
|
*
|
|
80
112
|
* @returns A JSON object containing the gauge node's data
|
|
81
113
|
*/
|
|
82
|
-
toJSON() {
|
|
83
|
-
var _a;
|
|
114
|
+
public toJSON(): any {
|
|
84
115
|
const json = super.toJSON();
|
|
85
116
|
json['name'] = this.name;
|
|
86
117
|
json['description'] = this.description;
|
|
87
118
|
json['latitude'] = this.latitude;
|
|
88
119
|
json['longitude'] = this.longitude;
|
|
89
|
-
json['team'] =
|
|
120
|
+
json['team'] = this.team?.id || this.team;
|
|
90
121
|
json['configurationAsJSON'] = this.configurationAsJSON;
|
|
91
122
|
return json;
|
|
92
123
|
}
|
|
124
|
+
|
|
93
125
|
/**
|
|
94
126
|
* Returns the link type for gauge nodes.
|
|
95
127
|
*
|
|
96
128
|
* @returns The string 'gauge'
|
|
97
129
|
*/
|
|
98
|
-
getLinkType() {
|
|
130
|
+
protected getLinkType(): string {
|
|
99
131
|
return GaugeNode.TYPE;
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
|
-
exports.GaugeNode = GaugeNode;
|
|
103
|
-
/** Type identifier for gauge nodes */
|
|
104
|
-
GaugeNode.TYPE = 'gauge';
|
|
105
|
-
//# sourceMappingURL=GaugeNode.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {Link, RaainNode, TeamNode} from '../organization';
|
|
2
|
+
import {GaugeNode} from './GaugeNode';
|
|
3
|
+
import {GaugeMeasure} from './GaugeMeasure';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* api/gauges/:id?format=map&begin=...
|
|
7
|
+
*/
|
|
8
|
+
export class GaugeNodeMap extends GaugeNode {
|
|
9
|
+
|
|
10
|
+
private map: string; // GaugeMeasure[]; stringified
|
|
11
|
+
|
|
12
|
+
constructor(json: {
|
|
13
|
+
id: string,
|
|
14
|
+
latitude: number,
|
|
15
|
+
longitude: number,
|
|
16
|
+
name: string,
|
|
17
|
+
description: string,
|
|
18
|
+
team: TeamNode,
|
|
19
|
+
configurationAsJSON?: any,
|
|
20
|
+
map?: string,
|
|
21
|
+
links?: Link[] | RaainNode[],
|
|
22
|
+
version?: string,
|
|
23
|
+
}) {
|
|
24
|
+
super(json);
|
|
25
|
+
this.setMapData(json.map);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public toJSON(): any {
|
|
29
|
+
const json = super.toJSON();
|
|
30
|
+
json.map = this.map;
|
|
31
|
+
return json;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public setMapData(mapData: GaugeMeasure[] | string) {
|
|
35
|
+
if (!mapData) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let map = mapData;
|
|
40
|
+
try {
|
|
41
|
+
if (typeof (mapData) !== 'string') {
|
|
42
|
+
map = JSON.stringify(mapData);
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
}
|
|
46
|
+
this.map = map.toString();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public getMapData(): GaugeMeasure[] {
|
|
50
|
+
if (!this.map) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
return JSON.parse(this.map);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api/notifications/:id
|
|
3
|
+
*/
|
|
4
|
+
export class EventNode {
|
|
5
|
+
public id: string;
|
|
6
|
+
public title: string;
|
|
7
|
+
public status: number;
|
|
8
|
+
public red: boolean;
|
|
9
|
+
public description: string;
|
|
10
|
+
public created: Date;
|
|
11
|
+
public modified: Date;
|
|
12
|
+
|
|
13
|
+
constructor(json: {
|
|
14
|
+
id: string,
|
|
15
|
+
title: string,
|
|
16
|
+
status: number,
|
|
17
|
+
red: boolean,
|
|
18
|
+
description: string,
|
|
19
|
+
created: Date,
|
|
20
|
+
modified: Date
|
|
21
|
+
}
|
|
22
|
+
) {
|
|
23
|
+
this.id = json.id;
|
|
24
|
+
this.title = json.title;
|
|
25
|
+
this.status = json.status;
|
|
26
|
+
this.red = json.red;
|
|
27
|
+
this.description = json.description;
|
|
28
|
+
this.created = json.created;
|
|
29
|
+
this.modified = json.modified;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public toJSON(): any {
|
|
33
|
+
return {
|
|
34
|
+
id: this.id,
|
|
35
|
+
title: this.title,
|
|
36
|
+
status: this.status,
|
|
37
|
+
red: this.red,
|
|
38
|
+
description: this.description,
|
|
39
|
+
created: this.created,
|
|
40
|
+
modified: this.modified,
|
|
41
|
+
} as any;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Link = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Hateoas Links :
|
|
6
3
|
* [ {
|
|
@@ -8,31 +5,34 @@ exports.Link = void 0;
|
|
|
8
5
|
* href: string // like "https://../rains/2"
|
|
9
6
|
* },...]
|
|
10
7
|
*/
|
|
11
|
-
class Link {
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export class Link {
|
|
9
|
+
constructor(
|
|
10
|
+
public rel: string,
|
|
11
|
+
public href: string
|
|
12
|
+
) {
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
public static isCloneable(object: any): boolean {
|
|
16
|
+
return object?.rel && object?.href;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
|
|
19
|
+
public static clone(object: any): Link | null {
|
|
20
|
+
if (!object?.rel || !object?.href) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
return new Link(object.rel, object.href);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
public getId(): string {
|
|
26
27
|
const urls = this.href.split('/');
|
|
27
28
|
// can be enforced : verify rel in -2 urls ?...
|
|
28
29
|
return urls[urls.length - 1];
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
public getLinkType(): string {
|
|
31
33
|
// const urls = this.href.split('/');
|
|
32
34
|
// can be enforced : verify rel in -2 urls ?...
|
|
33
35
|
// return urls[1].substring(0, urls[1].length - 1);
|
|
34
36
|
return this.rel;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
exports.Link = Link;
|
|
38
|
-
//# sourceMappingURL=Link.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {IPolarMeasureValue} from '../polar';
|
|
2
|
+
import {RaainNode} from './RaainNode';
|
|
3
|
+
import {ICartesianMeasureValue} from '../cartesian';
|
|
4
|
+
|
|
5
|
+
export class Measure extends RaainNode {
|
|
6
|
+
public date: Date;
|
|
7
|
+
// -> why array ? because you have different angle/axis from the Radar
|
|
8
|
+
public values: IPolarMeasureValue[] | ICartesianMeasureValue[] | number[];
|
|
9
|
+
public validity: number;
|
|
10
|
+
|
|
11
|
+
// internal
|
|
12
|
+
private configurationAsJSON: string;
|
|
13
|
+
|
|
14
|
+
constructor(json: {
|
|
15
|
+
id: string,
|
|
16
|
+
values: IPolarMeasureValue[] | ICartesianMeasureValue[] | number[],
|
|
17
|
+
date?: Date,
|
|
18
|
+
validity?: number,
|
|
19
|
+
configurationAsJSON?: string,
|
|
20
|
+
version?: string,
|
|
21
|
+
}
|
|
22
|
+
) {
|
|
23
|
+
super(json);
|
|
24
|
+
this.values = json.values ? json.values : [];
|
|
25
|
+
this.date = json.date ? new Date(json.date) : undefined;
|
|
26
|
+
this.validity = json.validity >= 0 ? json.validity : -1;
|
|
27
|
+
this.setConfiguration(json.configurationAsJSON);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public setConfiguration(configuration: string | any) {
|
|
31
|
+
let conf = configuration;
|
|
32
|
+
try {
|
|
33
|
+
conf = JSON.parse(configuration);
|
|
34
|
+
} catch (ignored) {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (conf) {
|
|
38
|
+
this.configurationAsJSON = JSON.stringify(conf);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public toJSON(options: { removeValues?: boolean } = {}): any {
|
|
43
|
+
const json = super.toJSON();
|
|
44
|
+
json['date'] = this.date?.toISOString();
|
|
45
|
+
json['validity'] = this.validity;
|
|
46
|
+
json['configurationAsJSON'] = this.configurationAsJSON;
|
|
47
|
+
|
|
48
|
+
if (!options?.removeValues) {
|
|
49
|
+
json['values'] = this.values;
|
|
50
|
+
}
|
|
51
|
+
return json;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public getConfiguration(): any {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(this.configurationAsJSON);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PeopleNode = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* api/teams/:id => contacts
|
|
6
3
|
*/
|
|
7
|
-
class PeopleNode {
|
|
8
|
-
|
|
4
|
+
export class PeopleNode {
|
|
5
|
+
|
|
6
|
+
public id: string;
|
|
7
|
+
public roles: string[];
|
|
8
|
+
public email: string;
|
|
9
|
+
public name: string;
|
|
10
|
+
|
|
11
|
+
constructor(json: {
|
|
12
|
+
id: string,
|
|
13
|
+
roles: string[],
|
|
14
|
+
email: string,
|
|
15
|
+
name: string,
|
|
16
|
+
}
|
|
17
|
+
) {
|
|
9
18
|
this.id = json.id;
|
|
10
19
|
this.roles = json.roles;
|
|
11
20
|
this.email = json.email;
|
|
12
21
|
this.name = json.name;
|
|
13
22
|
}
|
|
14
|
-
|
|
23
|
+
|
|
24
|
+
public toJSON(): any {
|
|
15
25
|
return {
|
|
16
26
|
id: this.id,
|
|
17
27
|
roles: this.roles,
|
|
@@ -19,14 +29,14 @@ class PeopleNode {
|
|
|
19
29
|
name: this.name,
|
|
20
30
|
};
|
|
21
31
|
}
|
|
22
|
-
|
|
32
|
+
|
|
33
|
+
hasRole(role: string): boolean {
|
|
23
34
|
return this.roles.indexOf(role) >= 0;
|
|
24
35
|
}
|
|
25
|
-
|
|
36
|
+
|
|
37
|
+
addRole(role: string) {
|
|
26
38
|
if (!this.hasRole(role)) {
|
|
27
39
|
this.roles.push(role);
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
|
-
exports.PeopleNode = PeopleNode;
|
|
32
|
-
//# sourceMappingURL=PeopleNode.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Link_1 = require("./Link");
|
|
1
|
+
import {Link} from './Link';
|
|
2
|
+
import {IVersion} from './IVersion';
|
|
3
|
+
|
|
5
4
|
/**
|
|
6
5
|
* Base class for all RAAIN nodes in the system.
|
|
7
6
|
* Implements versioning and link management functionality.
|
|
@@ -24,7 +23,12 @@ const Link_1 = require("./Link");
|
|
|
24
23
|
* });
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
class RaainNode {
|
|
26
|
+
export class RaainNode implements IVersion {
|
|
27
|
+
/** Unique identifier for the node */
|
|
28
|
+
public id: string;
|
|
29
|
+
/** Version string of the node */
|
|
30
|
+
public version: string;
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* Creates a new RaainNode instance.
|
|
30
34
|
*
|
|
@@ -33,42 +37,69 @@ class RaainNode {
|
|
|
33
37
|
* @param json.links - Array of HATEOAS links
|
|
34
38
|
* @param json.version - Version string
|
|
35
39
|
*/
|
|
36
|
-
constructor(json
|
|
37
|
-
|
|
40
|
+
constructor(json: {
|
|
41
|
+
id: string,
|
|
42
|
+
links?: Link[] | RaainNode[],
|
|
43
|
+
version?: string,
|
|
44
|
+
}) {
|
|
45
|
+
if (!json?.id) {
|
|
38
46
|
throw new Error('RaainNode needs a valid Object or ID');
|
|
39
47
|
}
|
|
48
|
+
|
|
40
49
|
this.id = json.id;
|
|
41
50
|
this.links = json.links ? json.links : [];
|
|
42
51
|
this.version = json.version ? json.version : undefined;
|
|
43
52
|
}
|
|
44
|
-
|
|
53
|
+
|
|
54
|
+
/** Array of HATEOAS links associated with the node */
|
|
55
|
+
protected _links: Link[];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Gets all links associated with the node.
|
|
59
|
+
*
|
|
60
|
+
* @returns Array of HATEOAS links
|
|
61
|
+
*/
|
|
62
|
+
public get links(): Link[] {
|
|
63
|
+
return this._links;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sets the links for the node.
|
|
68
|
+
*
|
|
69
|
+
* @param links - Array of links to set
|
|
70
|
+
*/
|
|
71
|
+
public set links(links: Link[] | RaainNode[]) {
|
|
72
|
+
this._links = RaainNode._getPurifiedLinks(links);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private static _getPurifiedLinks(linksToPurify: any[]): Link[] {
|
|
45
76
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
46
77
|
return [];
|
|
47
78
|
}
|
|
79
|
+
|
|
48
80
|
const linksPurified = linksToPurify
|
|
49
81
|
.filter(l => l !== null && l !== undefined)
|
|
50
82
|
.map(l => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
href += '/' + l2.version;
|
|
83
|
+
if (l instanceof Link || Link.isCloneable(l)) {
|
|
84
|
+
return Link.clone(l);
|
|
85
|
+
} else if (l && typeof l.getLinkType === 'function' && l.id) {
|
|
86
|
+
const linkType = l.getLinkType();
|
|
87
|
+
let href = '../' + linkType + 's';
|
|
88
|
+
const l2 = l;
|
|
89
|
+
if (l2.date?.toISOString) {
|
|
90
|
+
href += '/' + l2.date.toISOString();
|
|
91
|
+
if (l2.version) {
|
|
92
|
+
href += '/' + l2.version;
|
|
93
|
+
}
|
|
63
94
|
}
|
|
95
|
+
href += '/' + l2.id;
|
|
96
|
+
return new Link(linkType, href);
|
|
64
97
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
69
|
-
})
|
|
98
|
+
return null;
|
|
99
|
+
})
|
|
70
100
|
.filter(l => l !== null);
|
|
71
|
-
|
|
101
|
+
|
|
102
|
+
function uniqBy(a: Link[], key: (a: any) => string) {
|
|
72
103
|
const seen = {};
|
|
73
104
|
return a.filter((item) => {
|
|
74
105
|
if (!item) {
|
|
@@ -82,64 +113,65 @@ class RaainNode {
|
|
|
82
113
|
return true;
|
|
83
114
|
});
|
|
84
115
|
}
|
|
116
|
+
|
|
85
117
|
return uniqBy(linksPurified, JSON.stringify);
|
|
86
118
|
}
|
|
119
|
+
|
|
87
120
|
/**
|
|
88
121
|
* Converts the node to a JSON object.
|
|
89
122
|
*
|
|
90
123
|
* @returns A JSON object containing the node's data
|
|
91
124
|
*/
|
|
92
|
-
toJSON() {
|
|
93
|
-
const json = {
|
|
125
|
+
public toJSON(): any {
|
|
126
|
+
const json: any = {
|
|
94
127
|
id: this.id,
|
|
95
128
|
links: this.links
|
|
96
129
|
};
|
|
130
|
+
|
|
97
131
|
if (this.version) {
|
|
98
132
|
json.version = this.version;
|
|
99
133
|
}
|
|
134
|
+
|
|
100
135
|
return json;
|
|
101
136
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @param links - Array of links to set
|
|
114
|
-
*/
|
|
115
|
-
set links(links) {
|
|
116
|
-
this._links = RaainNode._getPurifiedLinks(links);
|
|
137
|
+
|
|
138
|
+
public getLinks(linkType?: string): Link[] {
|
|
139
|
+
if (!this._links) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
if (!linkType) {
|
|
143
|
+
return this._links;
|
|
144
|
+
}
|
|
145
|
+
// return this.links.filter(l => l && l.rel && linkType === l.rel);
|
|
146
|
+
return this._links.filter(l => l.getLinkType() === linkType);
|
|
147
|
+
|
|
117
148
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return link ? link.getId() : undefined;
|
|
149
|
+
|
|
150
|
+
public getLink(linkType: string, index?: number): Link {
|
|
151
|
+
index = !index ? 0 : index;
|
|
152
|
+
const linksFound = this.getLinks(linkType);
|
|
153
|
+
if (linksFound.length <= index) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return linksFound[index];
|
|
127
157
|
}
|
|
158
|
+
|
|
128
159
|
/**
|
|
129
160
|
* Gets all link IDs associated with the node.
|
|
130
161
|
*
|
|
131
162
|
* @returns Array of link IDs
|
|
132
163
|
*/
|
|
133
|
-
getLinkIds() {
|
|
164
|
+
public getLinkIds(): string[] {
|
|
134
165
|
return this._links.map(l => l.getId());
|
|
135
166
|
}
|
|
167
|
+
|
|
136
168
|
/**
|
|
137
169
|
* Gets the count of links, optionally filtered by type.
|
|
138
170
|
*
|
|
139
171
|
* @param linkType - Optional type of links to count
|
|
140
172
|
* @returns The number of links
|
|
141
173
|
*/
|
|
142
|
-
getLinksCount(linkType) {
|
|
174
|
+
public getLinksCount(linkType?: string): number {
|
|
143
175
|
if (!this._links) {
|
|
144
176
|
return 0;
|
|
145
177
|
}
|
|
@@ -148,25 +180,26 @@ class RaainNode {
|
|
|
148
180
|
}
|
|
149
181
|
return this._links.filter(l => l.getLinkType() === linkType).length;
|
|
150
182
|
}
|
|
183
|
+
|
|
151
184
|
/**
|
|
152
185
|
* Adds new links to the node.
|
|
153
186
|
*
|
|
154
187
|
* @param links - Array of links to add
|
|
155
188
|
*/
|
|
156
|
-
addLinks(links) {
|
|
189
|
+
public addLinks(links: Link[] | RaainNode[]) {
|
|
157
190
|
if (!links) {
|
|
158
191
|
return;
|
|
159
192
|
}
|
|
193
|
+
|
|
160
194
|
this._links = RaainNode._getPurifiedLinks([...this._links, ...links]);
|
|
161
195
|
}
|
|
196
|
+
|
|
162
197
|
/**
|
|
163
198
|
* Gets the version string of the node.
|
|
164
199
|
*
|
|
165
200
|
* @returns The version string
|
|
166
201
|
*/
|
|
167
|
-
getVersion() {
|
|
202
|
+
public getVersion(): string | undefined {
|
|
168
203
|
return this.version;
|
|
169
204
|
}
|
|
170
205
|
}
|
|
171
|
-
exports.RaainNode = RaainNode;
|
|
172
|
-
//# sourceMappingURL=RaainNode.js.map
|