raain-model 0.2.7 → 0.3.1

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.
Files changed (100) hide show
  1. package/EventNode.d.ts +10 -0
  2. package/EventNode.js +17 -0
  3. package/EventNode.js.map +1 -0
  4. package/GaugeMeasure.d.ts +7 -0
  5. package/GaugeMeasure.js +31 -0
  6. package/GaugeMeasure.js.map +1 -0
  7. package/GaugeMeasureValue.d.ts +16 -0
  8. package/GaugeMeasureValue.js +66 -0
  9. package/GaugeMeasureValue.js.map +1 -0
  10. package/GaugeNode.d.ts +19 -0
  11. package/GaugeNode.js +48 -0
  12. package/GaugeNode.js.map +1 -0
  13. package/GaugeNodeMap.d.ts +22 -0
  14. package/GaugeNodeMap.js +61 -0
  15. package/GaugeNodeMap.js.map +1 -0
  16. package/{src/IMeasureValue.ts → IMeasureValue.d.ts} +4 -13
  17. package/IMeasureValue.js +3 -0
  18. package/IMeasureValue.js.map +1 -0
  19. package/IVersion.d.ts +3 -0
  20. package/IVersion.js +3 -0
  21. package/IVersion.js.map +1 -0
  22. package/Link.d.ts +17 -0
  23. package/Link.js +36 -0
  24. package/Link.js.map +1 -0
  25. package/Measure.d.ts +9 -0
  26. package/Measure.js +43 -0
  27. package/Measure.js.map +1 -0
  28. package/MeasureValuePolarContainer.d.ts +7 -0
  29. package/{src/MeasureValuePolarContainer.ts → MeasureValuePolarContainer.js} +11 -17
  30. package/MeasureValuePolarContainer.js.map +1 -0
  31. package/PeopleNode.d.ts +7 -0
  32. package/PeopleNode.js +14 -0
  33. package/PeopleNode.js.map +1 -0
  34. package/PolarValue.d.ts +6 -0
  35. package/PolarValue.js +12 -0
  36. package/PolarValue.js.map +1 -0
  37. package/README.md +2 -3
  38. package/RELEASE.md +6 -0
  39. package/RaainNode.d.ts +18 -0
  40. package/RaainNode.js +103 -0
  41. package/RaainNode.js.map +1 -0
  42. package/RadarMeasure.d.ts +7 -0
  43. package/RadarMeasure.js +31 -0
  44. package/RadarMeasure.js.map +1 -0
  45. package/RadarMeasureValue.d.ts +19 -0
  46. package/RadarMeasureValue.js +75 -0
  47. package/RadarMeasureValue.js.map +1 -0
  48. package/RadarNode.d.ts +14 -0
  49. package/RadarNode.js +49 -0
  50. package/RadarNode.js.map +1 -0
  51. package/RadarNodeMap.d.ts +11 -0
  52. package/RadarNodeMap.js +56 -0
  53. package/RadarNodeMap.js.map +1 -0
  54. package/RainComputationMap.d.ts +11 -0
  55. package/RainComputationMap.js +59 -0
  56. package/RainComputationMap.js.map +1 -0
  57. package/RainComputationNode.d.ts +42 -0
  58. package/RainComputationNode.js +148 -0
  59. package/RainComputationNode.js.map +1 -0
  60. package/RainMeasure.d.ts +5 -0
  61. package/RainMeasure.js +29 -0
  62. package/RainMeasure.js.map +1 -0
  63. package/RainMeasureValue.d.ts +21 -0
  64. package/RainMeasureValue.js +74 -0
  65. package/RainMeasureValue.js.map +1 -0
  66. package/RainNode.d.ts +21 -0
  67. package/RainNode.js +107 -0
  68. package/RainNode.js.map +1 -0
  69. package/{src/index.ts → index.d.ts} +0 -0
  70. package/index.js +26 -0
  71. package/index.js.map +1 -0
  72. package/package.json +6 -7
  73. package/tools/PolarValues.d.ts +16 -0
  74. package/{src/tools/PolarValues.ts → tools/PolarValues.js} +46 -49
  75. package/tools/PolarValues.js.map +1 -0
  76. package/.travis.deploy.sh +0 -49
  77. package/.travis.yml +0 -20
  78. package/examples/creation.example.ts +0 -17
  79. package/examples/helper.js +0 -113
  80. package/examples/v1/asCustomer.spec.js +0 -656
  81. package/src/EventNode.ts +0 -17
  82. package/src/GaugeMeasure.ts +0 -13
  83. package/src/GaugeMeasureValue.ts +0 -77
  84. package/src/GaugeNode.ts +0 -46
  85. package/src/GaugeNodeMap.ts +0 -57
  86. package/src/Link.ts +0 -28
  87. package/src/Measure.ts +0 -36
  88. package/src/PeopleNode.ts +0 -12
  89. package/src/PolarValue.ts +0 -9
  90. package/src/RaainNode.ts +0 -92
  91. package/src/RadarMeasure.ts +0 -13
  92. package/src/RadarMeasureValue.ts +0 -93
  93. package/src/RadarNode.ts +0 -46
  94. package/src/RadarNodeMap.ts +0 -53
  95. package/src/RainComputationMap.ts +0 -60
  96. package/src/RainComputationNode.ts +0 -175
  97. package/src/RainMeasure.ts +0 -9
  98. package/src/RainMeasureValue.ts +0 -83
  99. package/src/RainNode.ts +0 -104
  100. package/tsconfig.json +0 -14
@@ -1,175 +0,0 @@
1
- import {RaainNode} from "./RaainNode";
2
- import {Link} from "./Link";
3
- import {RadarNode} from "./RadarNode";
4
- import {RainNode} from "./RainNode";
5
- import {RadarMeasure} from "./RadarMeasure";
6
- import {RainMeasureValue} from "./RainMeasureValue";
7
-
8
- export class RainComputationNode extends RaainNode {
9
-
10
- public quality: number;
11
- public progressIngest: number;
12
- public progressComputing: number;
13
- public timeSpentInMs: number;
14
-
15
- public periodBegin: Date;
16
- public periodEnd: Date;
17
- public isReady: Boolean;
18
- public isDoneDate: Date;
19
- public launchedBy: String;
20
-
21
- public results: RainMeasureValue[]; // why array ? because you can have different angle for Radar (same as Measure)
22
-
23
- constructor(
24
- idOrObjectToCopy: string | {
25
- id?: string,
26
- periodBegin?: Date,
27
- periodEnd?: Date,
28
- links?: Link[] | any[],
29
- quality?: number,
30
- progressIngest?: number,
31
- progressComputing?: number,
32
- timeSpentInMs?: number,
33
- isReady?: Boolean,
34
- isDoneDate?: Date,
35
- results?: RainMeasureValue[],
36
- launchedBy?: string,
37
- rain?: Link[],
38
- radars?: Link[]
39
- },
40
- periodBegin?: Date,
41
- periodEnd?: Date,
42
- links?: Link[] | any[],
43
- quality?: number,
44
- progressIngest?: number,
45
- progressComputing?: number,
46
- timeSpentInMs?: number,
47
- isReady?: Boolean,
48
- isDoneDate?: Date,
49
- results?: RainMeasureValue[],
50
- launchedBy?: string
51
- ) {
52
- super(idOrObjectToCopy, links);
53
- if (typeof idOrObjectToCopy !== 'string') {
54
- this.periodBegin = idOrObjectToCopy.periodBegin;
55
- this.periodEnd = idOrObjectToCopy.periodEnd;
56
- this.quality = idOrObjectToCopy.quality;
57
- this.progressIngest = idOrObjectToCopy.progressIngest;
58
- this.progressComputing = idOrObjectToCopy.progressComputing;
59
- this.timeSpentInMs = idOrObjectToCopy.timeSpentInMs;
60
- this.isReady = idOrObjectToCopy.isReady;
61
- this.isDoneDate = idOrObjectToCopy.isDoneDate;
62
- this.setResults(idOrObjectToCopy.results);
63
- this.launchedBy = idOrObjectToCopy.launchedBy;
64
- this.replaceRainLink(idOrObjectToCopy.links);
65
- this.replaceRainLink(idOrObjectToCopy.rain);
66
- this.addRadarLinks(idOrObjectToCopy.links);
67
- this.addRadarLinks(idOrObjectToCopy.radars);
68
- return;
69
- }
70
- this.periodBegin = periodBegin;
71
- this.periodEnd = periodEnd;
72
- this.quality = quality;
73
- this.progressIngest = progressIngest;
74
- this.progressComputing = progressComputing;
75
- this.timeSpentInMs = timeSpentInMs;
76
- this.isReady = isReady;
77
- this.isDoneDate = isDoneDate;
78
- this.setResults(results);
79
- this.launchedBy = launchedBy;
80
- this.replaceRainLink(links);
81
- this.addRadarLinks(links);
82
- }
83
-
84
- public toJSON(): Object {
85
- let json = super.toJSON();
86
- json['periodBegin'] = this.periodBegin;
87
- json['periodEnd'] = this.periodEnd;
88
- json['quality'] = this.quality;
89
- json['progressIngest'] = this.progressIngest;
90
- json['progressComputing'] = this.progressComputing;
91
- json['timeSpentInMs'] = this.timeSpentInMs;
92
- json['isReady'] = this.isReady;
93
- json['isDoneDate'] = this.isDoneDate;
94
- json['results'] = JSON.stringify(this.results.map(r => r.toJSON()));
95
- json['launchedBy'] = this.launchedBy;
96
- return json;
97
- }
98
-
99
- protected getLinkType(): string {
100
- return 'rain-computation';
101
- }
102
-
103
- public addRadarLinks(linksToAdd: Link[] | any[]): void {
104
- this.addLinks(RainComputationNode._getRadarLinks(linksToAdd));
105
- }
106
-
107
- public replaceRainLink(linksToAdd: Link[] | any[] | any): void {
108
- this.addLinks([RainComputationNode._getRainLink(linksToAdd)]);
109
- }
110
-
111
- public addRadarMeasureLinks(linksToAdd: Link[] | any[]): void {
112
- this.addLinks(RainComputationNode._getRadarMeasureLinks(linksToAdd));
113
- }
114
-
115
- private setResults(results) {
116
- if (typeof results === 'string') {
117
- results = JSON.parse(results);
118
- }
119
-
120
- if (!results || results.length === 0) {
121
- this.results = [];
122
- return;
123
- }
124
-
125
- this.results = results.map(r => {
126
- if (typeof r === 'string') {
127
- return new RainMeasureValue(r);
128
- } else if (r.getPolarsStringified) {
129
- return new RainMeasureValue(r.getPolarsStringified());
130
- } else if (r.polars) {
131
- return new RainMeasureValue(r);
132
- } else {
133
- return r;
134
- }
135
- });
136
- }
137
-
138
- private static _getRadarLinks(linksToPurify: any[]): any[] {
139
- if (!linksToPurify || linksToPurify.length === 0) {
140
- return [];
141
- }
142
-
143
- return linksToPurify.map(l => {
144
- if (l instanceof Link) {
145
- return l;
146
- } else if (l && l.id) {
147
- return new RadarNode(l.id.toString('hex'));
148
- }
149
- });
150
- }
151
-
152
- private static _getRadarMeasureLinks(linksToPurify: any[]): any[] {
153
- if (!linksToPurify || linksToPurify.length === 0) {
154
- return [];
155
- }
156
-
157
- return linksToPurify.map(l => {
158
- if (l instanceof Link) {
159
- return l;
160
- } else if (l && l.id) {
161
- return new RadarMeasure(l.id.toString('hex'));
162
- }
163
- });
164
- }
165
-
166
- private static _getRainLink(linkToPurify: any): RainNode {
167
- if (!linkToPurify || !linkToPurify.id) {
168
- return null;
169
- }
170
-
171
- return new RainNode(linkToPurify.id.toString('hex'));
172
- }
173
-
174
- }
175
-
@@ -1,9 +0,0 @@
1
- import {Measure} from "./Measure";
2
-
3
- export class RainMeasure extends Measure {
4
-
5
- protected getLinkType(): string {
6
- return 'rain-measure';
7
- }
8
- }
9
-
@@ -1,83 +0,0 @@
1
- import {MeasureValuePolarContainer} from "./MeasureValuePolarContainer";
2
- import {IMeasureValue} from "./IMeasureValue";
3
- import {PolarValues} from "./tools/PolarValues";
4
- import {PolarValue} from "./PolarValue";
5
-
6
- export class RainMeasureValue implements IMeasureValue {
7
-
8
- private polars: PolarValues;
9
-
10
- constructor(
11
- polars: any | MeasureValuePolarContainer[]
12
- ) {
13
- if (!polars) {
14
- throw 'RainMeasureValue needs a valid Object';
15
- }
16
- if (polars.polars) {
17
- if (typeof polars.polars === 'string') {
18
- this.setPolarsAsString(polars.polars);
19
- } else {
20
- this.setPolarsAsContainer(polars.polars);
21
- }
22
- return;
23
- }
24
-
25
- if (typeof polars === 'string') {
26
- this.setPolarsAsString(polars);
27
- } else {
28
- this.setPolarsAsContainer(polars);
29
- }
30
- }
31
-
32
- getPolarsStringified(): string {
33
- return this.polars.getPolarsStringified();
34
- }
35
-
36
- getPolars(): MeasureValuePolarContainer[] {
37
- return this.polars.getPolars();
38
- }
39
-
40
- setPolarsAsString(s: string): void {
41
- this.polars = new PolarValues(s);
42
- }
43
-
44
- setPolarsAsContainer(s: MeasureValuePolarContainer[]): void {
45
- this.polars = new PolarValues(s);
46
- }
47
-
48
- getPolarValue(azimuthIndex: number, edgeIndex: number): PolarValue {
49
- return this.polars.getPolarValue(azimuthIndex, edgeIndex);
50
- }
51
-
52
- setPolarValue(azimuthIndex: number, edgeIndex: number, value: number): void {
53
- return this.polars.setPolarValue(azimuthIndex, edgeIndex, value);
54
- }
55
-
56
- getAzimuthsCount(): number {
57
- return this.polars.getPolars().length;
58
- }
59
-
60
- getPolarEdgesCount(): number {
61
- const polars = this.polars.getPolars();
62
- if (polars.length > 0) {
63
- return polars[0].polarEdges.length;
64
- }
65
- return 0;
66
- }
67
-
68
- getDistance() : number {
69
- const polars = this.polars.getPolars();
70
- if (polars.length > 0) {
71
- return polars[0].distance;
72
- }
73
- return 1;
74
- }
75
-
76
- public toJSON(): Object {
77
- return this.polars.toJSON();
78
- }
79
-
80
- public toJSONWithPolarStringified(): Object {
81
- return this.polars.toJSONWithPolarStringified();
82
- }
83
- }
package/src/RainNode.ts DELETED
@@ -1,104 +0,0 @@
1
- import {RaainNode} from './RaainNode';
2
- import {Link} from "./Link";
3
- import {RadarNode} from "./RadarNode";
4
- import {RainComputationNode} from "./RainComputationNode";
5
-
6
- /**
7
- * api/rains/:id
8
- */
9
- export class RainNode extends RaainNode {
10
-
11
- public name: string;
12
- public status: number;
13
- public quality: number;
14
- public latitude: number;
15
- public longitude: number;
16
- public radius: number;
17
-
18
- constructor(
19
- idOrObjectToCopy: any | string,
20
- name?: string,
21
- links?: Link[] | any[],
22
- status?: number,
23
- quality?: number,
24
- latitude?: number,
25
- longitude?: number,
26
- radius?: number
27
- ) {
28
- super(idOrObjectToCopy, links);
29
-
30
- if (typeof(idOrObjectToCopy) === 'object') {
31
- this.name = idOrObjectToCopy.name;
32
- this.status = idOrObjectToCopy.status;
33
- this.quality = idOrObjectToCopy.quality;
34
- this.latitude = idOrObjectToCopy.latitude;
35
- this.longitude = idOrObjectToCopy.longitude;
36
- this.radius = idOrObjectToCopy.radius;
37
- this.addRadars(idOrObjectToCopy.links);
38
- this.addRadars(idOrObjectToCopy.radars);
39
- this.addCompletedComputations(idOrObjectToCopy.links);
40
- this.addCompletedComputations(idOrObjectToCopy.lastCompletedComputations);
41
- return;
42
- }
43
- this.name = name;
44
- this.status = status;
45
- this.quality = quality;
46
- this.latitude = latitude;
47
- this.longitude = longitude;
48
- this.radius = radius;
49
- this.addRadars(links);
50
- this.addCompletedComputations(links);
51
- }
52
-
53
- public toJSON(): Object {
54
- let json = super.toJSON();
55
- json['name'] = this.name;
56
- json['status'] = this.status;
57
- json['quality'] = this.quality;
58
- json['latitude'] = this.latitude;
59
- json['longitude'] = this.longitude;
60
- json['radius'] = this.radius;
61
- return json;
62
- }
63
-
64
- protected getLinkType(): string {
65
- return 'rain';
66
- }
67
-
68
- public addRadars(linksToAdd: Link[] | any[]): void {
69
- this.addLinks(RainNode._getRadarLinks(linksToAdd));
70
- }
71
-
72
- public addCompletedComputations(linksToAdd: Link[] | any[]): void {
73
- this.addLinks(RainNode._getRainComputationLinks(linksToAdd));
74
- }
75
-
76
- private static _getRadarLinks(linksToPurify: any[]): any[] {
77
- if (!linksToPurify || linksToPurify.length === 0) {
78
- return [];
79
- }
80
-
81
- return linksToPurify.map(l => {
82
- if (l instanceof Link) {
83
- return l;
84
- } else if (l.id) {
85
- return new RadarNode(l.id.toString('hex'));
86
- }
87
- });
88
- }
89
-
90
- private static _getRainComputationLinks(linksToPurify: any[]): any[] {
91
- if (!linksToPurify || linksToPurify.length === 0) {
92
- return [];
93
- }
94
-
95
- return linksToPurify.map(l => {
96
- if (l instanceof Link) {
97
- return l;
98
- } else if (l.id) {
99
- return new RainComputationNode(l.id.toString('hex'));
100
- }
101
- });
102
- }
103
- }
104
-
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES5",
4
- "module": "commonjs",
5
- "declaration": true,
6
- "sourceMap": true,
7
- "outDir": "dist"
8
- },
9
- "exclude": [
10
- "node_modules",
11
- "dist",
12
- "examples"
13
- ]
14
- }