@dnv-plant/typescriptpws 1.0.95 → 1.0.96-alpha.2289077
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/index.ts +2 -2
- package/package.json +1 -1
- package/src/calculations/applicationTools.ts +36 -47
- package/src/calculations/calculationBase.ts +27 -61
- package/src/calculations/discharge.ts +274 -364
- package/src/calculations/dispersion.ts +80 -88
- package/src/calculations/dispersionView.ts +360 -439
- package/src/calculations/fireball.ts +64 -70
- package/src/calculations/jetFire.ts +104 -118
- package/src/calculations/lateExplosion.ts +150 -154
- package/src/calculations/linkedRunners.ts +1025 -1095
- package/src/calculations/poolFire.ts +64 -70
- package/src/calculations/properties.ts +37 -50
- package/src/calculations/radiation.ts +467 -575
- package/src/calculations/standalones.ts +55 -66
- package/src/calculations/toxics.ts +65 -77
- package/src/calculations/utilities.ts +322 -479
- package/src/constants.ts +14 -14
- package/src/entities.ts +752 -1000
- package/src/entity-schemas.ts +1279 -1286
- package/src/enums.ts +11 -11
- package/src/materials.ts +86 -256
- package/src/utilities.ts +41 -50
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/***********************************************************************
|
|
2
|
-
* This file has been auto-generated by a code generation tool.
|
|
3
|
-
*
|
|
4
|
-
* DO NOT MODIFY THIS FILE
|
|
5
|
-
* This file is maintained by DNV.
|
|
6
|
-
* Editing it may lead to inconsistent results and limit DNV's ability to provide support.
|
|
7
|
-
* Please contact DNV if you believe changes are required.
|
|
8
|
-
*
|
|
9
|
-
* Version: 1.0.
|
|
10
|
-
* Date/time:
|
|
11
|
-
* Template: templates/typescriptpws/calculations.razor.
|
|
12
|
-
***********************************************************************/
|
|
13
|
-
|
|
14
|
-
import * as Enums from
|
|
15
|
-
import * as Entities from
|
|
16
|
-
import * as EntitySchemas from
|
|
17
|
-
import { getAnalyticsApiTarget, getClientAliasId } from
|
|
18
|
-
import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from
|
|
19
|
-
|
|
20
|
-
import Joi from
|
|
2
|
+
* This file has been auto-generated by a code generation tool.
|
|
3
|
+
*
|
|
4
|
+
* DO NOT MODIFY THIS FILE
|
|
5
|
+
* This file is maintained by DNV.
|
|
6
|
+
* Editing it may lead to inconsistent results and limit DNV's ability to provide support.
|
|
7
|
+
* Please contact DNV if you believe changes are required.
|
|
8
|
+
*
|
|
9
|
+
* Version: 1.0.96
|
|
10
|
+
* Date/time: 4 Apr 2026 08:17:52
|
|
11
|
+
* Template: templates/typescriptpws/calculations.razor.
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
|
|
14
|
+
import * as Enums from '../enums';
|
|
15
|
+
import * as Entities from '../entities';
|
|
16
|
+
import * as EntitySchemas from '../entity-schemas';
|
|
17
|
+
import { getAnalyticsApiTarget, getClientAliasId } from '../utilities';
|
|
18
|
+
import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from './calculationBase';
|
|
19
|
+
|
|
20
|
+
import Joi from 'joi';
|
|
21
21
|
|
|
22
22
|
export interface TankFireCalculationRequestSchemaData {
|
|
23
23
|
atmosphericStorageTank: Entities.AtmosphericStorageTank;
|
|
@@ -36,12 +36,7 @@ class TankFireCalculationRequest extends CalculationRequestBase {
|
|
|
36
36
|
* TankFire calculation request class.
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
constructor(data: {
|
|
40
|
-
atmosphericStorageTank: Entities.AtmosphericStorageTank,
|
|
41
|
-
weather: Entities.Weather,
|
|
42
|
-
substrate: Entities.Substrate,
|
|
43
|
-
flammableParameters: Entities.FlammableParameters
|
|
44
|
-
}) {
|
|
39
|
+
constructor(data: { atmosphericStorageTank: Entities.AtmosphericStorageTank; weather: Entities.Weather; substrate: Entities.Substrate; flammableParameters: Entities.FlammableParameters }) {
|
|
45
40
|
super();
|
|
46
41
|
this.atmosphericStorageTank = data.atmosphericStorageTank;
|
|
47
42
|
this.weather = data.weather;
|
|
@@ -66,17 +61,17 @@ export class TankFireCalculationRequestSchema {
|
|
|
66
61
|
}).unknown(true);
|
|
67
62
|
|
|
68
63
|
this.propertyTypes = {
|
|
69
|
-
atmosphericStorageTank:
|
|
70
|
-
weather:
|
|
71
|
-
substrate:
|
|
72
|
-
flammableParameters:
|
|
64
|
+
atmosphericStorageTank: 'Entities.AtmosphericStorageTank',
|
|
65
|
+
weather: 'Entities.Weather',
|
|
66
|
+
substrate: 'Entities.Substrate',
|
|
67
|
+
flammableParameters: 'Entities.FlammableParameters',
|
|
73
68
|
};
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
validate(data: TankFireCalculationRequestSchemaData): TankFireCalculationRequest {
|
|
77
72
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
78
73
|
if (error) {
|
|
79
|
-
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(
|
|
74
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
80
75
|
}
|
|
81
76
|
return this.makeCalculationRequest(value);
|
|
82
77
|
}
|
|
@@ -99,10 +94,10 @@ export class TankFireCalculation extends CalculationBase {
|
|
|
99
94
|
*
|
|
100
95
|
*/
|
|
101
96
|
constructor(data: {
|
|
102
|
-
atmosphericStorageTank: Entities.AtmosphericStorageTank
|
|
103
|
-
weather: Entities.Weather
|
|
104
|
-
substrate: Entities.Substrate
|
|
105
|
-
flammableParameters: Entities.FlammableParameters
|
|
97
|
+
atmosphericStorageTank: Entities.AtmosphericStorageTank;
|
|
98
|
+
weather: Entities.Weather;
|
|
99
|
+
substrate: Entities.Substrate;
|
|
100
|
+
flammableParameters: Entities.FlammableParameters;
|
|
106
101
|
controller?: AbortController;
|
|
107
102
|
}) {
|
|
108
103
|
super(data.controller);
|
|
@@ -118,7 +113,7 @@ export class TankFireCalculation extends CalculationBase {
|
|
|
118
113
|
atmosphericStorageTank: this.atmosphericStorageTank,
|
|
119
114
|
weather: this.weather,
|
|
120
115
|
substrate: this.substrate,
|
|
121
|
-
flammableParameters: this.flammableParameters
|
|
116
|
+
flammableParameters: this.flammableParameters,
|
|
122
117
|
});
|
|
123
118
|
|
|
124
119
|
const schema = new TankFireCalculationRequestSchema();
|
|
@@ -160,22 +155,18 @@ export class TankFireCalculation extends CalculationBase {
|
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
toString() {
|
|
163
|
-
const parts = [
|
|
158
|
+
const parts = ['* TankFire'];
|
|
164
159
|
|
|
165
160
|
parts.push(`poolFireFlameResult: ${String(this.poolFireFlameResult)}`);
|
|
166
|
-
parts.push(
|
|
167
|
-
parts.push(
|
|
168
|
-
this.flameRecords && this.flameRecords.length > 0
|
|
169
|
-
? this.flameRecords.map((point) => `flameRecordsElement: ${point}`).join("\n")
|
|
170
|
-
: "flameRecords does not contain any elements"
|
|
171
|
-
);
|
|
161
|
+
parts.push('*** flameRecords:');
|
|
162
|
+
parts.push(this.flameRecords && this.flameRecords.length > 0 ? this.flameRecords.map((point) => `flameRecordsElement: ${point}`).join('\n') : 'flameRecords does not contain any elements');
|
|
172
163
|
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
173
|
-
parts.push(
|
|
174
|
-
parts.push(`messages: ${this.messages !== undefined ? this.messages :
|
|
175
|
-
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime :
|
|
176
|
-
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId :
|
|
164
|
+
parts.push('*** messages:');
|
|
165
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
166
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
|
|
167
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
|
|
177
168
|
|
|
178
|
-
return parts.join(
|
|
169
|
+
return parts.join('\n');
|
|
179
170
|
}
|
|
180
171
|
}
|
|
181
172
|
|
|
@@ -188,12 +179,12 @@ export class TankFireCalculationResponse extends CalculationResponseBase {
|
|
|
188
179
|
*
|
|
189
180
|
*/
|
|
190
181
|
constructor(data: {
|
|
191
|
-
poolFireFlameResult: Entities.PoolFireFlameResult
|
|
192
|
-
flameRecords: Entities.FlameRecord[]
|
|
193
|
-
resultCode: Enums.ResultCode
|
|
194
|
-
messages: string[]
|
|
195
|
-
calculationElapsedTime: number
|
|
196
|
-
operationId: string
|
|
182
|
+
poolFireFlameResult: Entities.PoolFireFlameResult;
|
|
183
|
+
flameRecords: Entities.FlameRecord[];
|
|
184
|
+
resultCode: Enums.ResultCode;
|
|
185
|
+
messages: string[];
|
|
186
|
+
calculationElapsedTime: number;
|
|
187
|
+
operationId: string;
|
|
197
188
|
}) {
|
|
198
189
|
super();
|
|
199
190
|
this.poolFireFlameResult = data.poolFireFlameResult;
|
|
@@ -210,25 +201,23 @@ export class TankFireCalculationResponse extends CalculationResponseBase {
|
|
|
210
201
|
this.poolFireFlameResult.initialiseFromDictionary(data.poolFireFlameResult as { [key: string]: unknown });
|
|
211
202
|
}
|
|
212
203
|
if (data.flameRecords && Array.isArray(data.flameRecords)) {
|
|
213
|
-
this.flameRecords = data.flameRecords.map(
|
|
214
|
-
(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
);
|
|
204
|
+
this.flameRecords = data.flameRecords.map((item) => {
|
|
205
|
+
const record = new Entities.FlameRecord();
|
|
206
|
+
record.initialiseFromDictionary(item);
|
|
207
|
+
return record;
|
|
208
|
+
});
|
|
220
209
|
}
|
|
221
|
-
if (data.resultCode !== undefined && (typeof data.resultCode ===
|
|
210
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
222
211
|
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
223
212
|
}
|
|
224
213
|
this.messages = this.messages ?? [];
|
|
225
214
|
if (data.messages && Array.isArray(data.messages)) {
|
|
226
215
|
this.messages.push(...data.messages);
|
|
227
216
|
}
|
|
228
|
-
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime ===
|
|
217
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
|
|
229
218
|
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
230
219
|
}
|
|
231
|
-
if (data.operationId !== undefined && typeof data.operationId ===
|
|
220
|
+
if (data.operationId !== undefined && typeof data.operationId === 'string') {
|
|
232
221
|
this.operationId = data.operationId as string;
|
|
233
222
|
}
|
|
234
223
|
}
|
|
@@ -261,15 +250,15 @@ export class TankFireCalculationResponseSchema {
|
|
|
261
250
|
}).unknown(true);
|
|
262
251
|
|
|
263
252
|
this.propertyTypes = {
|
|
264
|
-
poolFireFlameResult:
|
|
265
|
-
flameRecords:
|
|
253
|
+
poolFireFlameResult: 'Entities.PoolFireFlameResult',
|
|
254
|
+
flameRecords: 'Entities.FlameRecord[]',
|
|
266
255
|
};
|
|
267
256
|
}
|
|
268
257
|
|
|
269
258
|
validate(data: TankFireCalculationResponseSchemaData): TankFireCalculationResponse {
|
|
270
259
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
271
260
|
if (error) {
|
|
272
|
-
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(
|
|
261
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
273
262
|
}
|
|
274
263
|
return this.makeCalculationResponse(value);
|
|
275
264
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/***********************************************************************
|
|
2
|
-
* This file has been auto-generated by a code generation tool.
|
|
3
|
-
*
|
|
4
|
-
* DO NOT MODIFY THIS FILE
|
|
5
|
-
* This file is maintained by DNV.
|
|
6
|
-
* Editing it may lead to inconsistent results and limit DNV's ability to provide support.
|
|
7
|
-
* Please contact DNV if you believe changes are required.
|
|
8
|
-
*
|
|
9
|
-
* Version: 1.0.
|
|
10
|
-
* Date/time:
|
|
11
|
-
* Template: templates/typescriptpws/calculations.razor.
|
|
12
|
-
***********************************************************************/
|
|
13
|
-
|
|
14
|
-
import * as Enums from
|
|
15
|
-
import * as Entities from
|
|
16
|
-
import * as EntitySchemas from
|
|
17
|
-
import { getAnalyticsApiTarget, getClientAliasId } from
|
|
18
|
-
import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from
|
|
19
|
-
|
|
20
|
-
import Joi from
|
|
2
|
+
* This file has been auto-generated by a code generation tool.
|
|
3
|
+
*
|
|
4
|
+
* DO NOT MODIFY THIS FILE
|
|
5
|
+
* This file is maintained by DNV.
|
|
6
|
+
* Editing it may lead to inconsistent results and limit DNV's ability to provide support.
|
|
7
|
+
* Please contact DNV if you believe changes are required.
|
|
8
|
+
*
|
|
9
|
+
* Version: 1.0.96
|
|
10
|
+
* Date/time: 4 Apr 2026 08:17:52
|
|
11
|
+
* Template: templates/typescriptpws/calculations.razor.
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
|
|
14
|
+
import * as Enums from '../enums';
|
|
15
|
+
import * as Entities from '../entities';
|
|
16
|
+
import * as EntitySchemas from '../entity-schemas';
|
|
17
|
+
import { getAnalyticsApiTarget, getClientAliasId } from '../utilities';
|
|
18
|
+
import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from './calculationBase';
|
|
19
|
+
|
|
20
|
+
import Joi from 'joi';
|
|
21
21
|
|
|
22
22
|
export interface LethalityDistanceCalculationRequestSchemaData {
|
|
23
23
|
material: Entities.Material;
|
|
@@ -45,14 +45,14 @@ class LethalityDistanceCalculationRequest extends CalculationRequestBase {
|
|
|
45
45
|
*
|
|
46
46
|
*/
|
|
47
47
|
constructor(data: {
|
|
48
|
-
material: Entities.Material
|
|
49
|
-
scalarUdmOutputs: Entities.ScalarUdmOutputs
|
|
50
|
-
weather: Entities.Weather
|
|
51
|
-
dispersionRecords: Entities.DispersionRecord[]
|
|
52
|
-
dispersionRecordCount: number
|
|
53
|
-
substrate: Entities.Substrate
|
|
54
|
-
dispersionOutputConfig: Entities.DispersionOutputConfig
|
|
55
|
-
dispersionParameters: Entities.DispersionParameters
|
|
48
|
+
material: Entities.Material;
|
|
49
|
+
scalarUdmOutputs: Entities.ScalarUdmOutputs;
|
|
50
|
+
weather: Entities.Weather;
|
|
51
|
+
dispersionRecords: Entities.DispersionRecord[];
|
|
52
|
+
dispersionRecordCount: number;
|
|
53
|
+
substrate: Entities.Substrate;
|
|
54
|
+
dispersionOutputConfig: Entities.DispersionOutputConfig;
|
|
55
|
+
dispersionParameters: Entities.DispersionParameters;
|
|
56
56
|
}) {
|
|
57
57
|
super();
|
|
58
58
|
this.material = data.material;
|
|
@@ -86,21 +86,21 @@ export class LethalityDistanceCalculationRequestSchema {
|
|
|
86
86
|
}).unknown(true);
|
|
87
87
|
|
|
88
88
|
this.propertyTypes = {
|
|
89
|
-
material:
|
|
90
|
-
scalarUdmOutputs:
|
|
91
|
-
weather:
|
|
92
|
-
dispersionRecords:
|
|
93
|
-
dispersionRecordCount:
|
|
94
|
-
substrate:
|
|
95
|
-
dispersionOutputConfig:
|
|
96
|
-
dispersionParameters:
|
|
89
|
+
material: 'Entities.Material',
|
|
90
|
+
scalarUdmOutputs: 'Entities.ScalarUdmOutputs',
|
|
91
|
+
weather: 'Entities.Weather',
|
|
92
|
+
dispersionRecords: 'Entities.DispersionRecord[]',
|
|
93
|
+
dispersionRecordCount: 'number',
|
|
94
|
+
substrate: 'Entities.Substrate',
|
|
95
|
+
dispersionOutputConfig: 'Entities.DispersionOutputConfig',
|
|
96
|
+
dispersionParameters: 'Entities.DispersionParameters',
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
validate(data: LethalityDistanceCalculationRequestSchemaData): LethalityDistanceCalculationRequest {
|
|
101
101
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
102
102
|
if (error) {
|
|
103
|
-
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(
|
|
103
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
104
104
|
}
|
|
105
105
|
return this.makeCalculationRequest(value);
|
|
106
106
|
}
|
|
@@ -126,14 +126,14 @@ export class LethalityDistanceCalculation extends CalculationBase {
|
|
|
126
126
|
*
|
|
127
127
|
*/
|
|
128
128
|
constructor(data: {
|
|
129
|
-
material: Entities.Material
|
|
130
|
-
scalarUdmOutputs: Entities.ScalarUdmOutputs
|
|
131
|
-
weather: Entities.Weather
|
|
132
|
-
dispersionRecords: Entities.DispersionRecord[]
|
|
133
|
-
dispersionRecordCount: number
|
|
134
|
-
substrate: Entities.Substrate
|
|
135
|
-
dispersionOutputConfig: Entities.DispersionOutputConfig
|
|
136
|
-
dispersionParameters: Entities.DispersionParameters
|
|
129
|
+
material: Entities.Material;
|
|
130
|
+
scalarUdmOutputs: Entities.ScalarUdmOutputs;
|
|
131
|
+
weather: Entities.Weather;
|
|
132
|
+
dispersionRecords: Entities.DispersionRecord[];
|
|
133
|
+
dispersionRecordCount: number;
|
|
134
|
+
substrate: Entities.Substrate;
|
|
135
|
+
dispersionOutputConfig: Entities.DispersionOutputConfig;
|
|
136
|
+
dispersionParameters: Entities.DispersionParameters;
|
|
137
137
|
controller?: AbortController;
|
|
138
138
|
}) {
|
|
139
139
|
super(data.controller);
|
|
@@ -157,7 +157,7 @@ export class LethalityDistanceCalculation extends CalculationBase {
|
|
|
157
157
|
dispersionRecordCount: this.dispersionRecordCount,
|
|
158
158
|
substrate: this.substrate,
|
|
159
159
|
dispersionOutputConfig: this.dispersionOutputConfig,
|
|
160
|
-
dispersionParameters: this.dispersionParameters
|
|
160
|
+
dispersionParameters: this.dispersionParameters,
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
const schema = new LethalityDistanceCalculationRequestSchema();
|
|
@@ -198,21 +198,17 @@ export class LethalityDistanceCalculation extends CalculationBase {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
toString() {
|
|
201
|
-
const parts = [
|
|
202
|
-
|
|
203
|
-
parts.push(
|
|
204
|
-
parts.push(
|
|
205
|
-
this.toxicRecords && this.toxicRecords.length > 0
|
|
206
|
-
? this.toxicRecords.map((point) => `toxicRecordsElement: ${point}`).join("\n")
|
|
207
|
-
: "toxicRecords does not contain any elements"
|
|
208
|
-
);
|
|
201
|
+
const parts = ['* LethalityDistance'];
|
|
202
|
+
|
|
203
|
+
parts.push('*** toxicRecords:');
|
|
204
|
+
parts.push(this.toxicRecords && this.toxicRecords.length > 0 ? this.toxicRecords.map((point) => `toxicRecordsElement: ${point}`).join('\n') : 'toxicRecords does not contain any elements');
|
|
209
205
|
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
210
|
-
parts.push(
|
|
211
|
-
parts.push(`messages: ${this.messages !== undefined ? this.messages :
|
|
212
|
-
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime :
|
|
213
|
-
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId :
|
|
206
|
+
parts.push('*** messages:');
|
|
207
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
208
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
|
|
209
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
|
|
214
210
|
|
|
215
|
-
return parts.join(
|
|
211
|
+
return parts.join('\n');
|
|
216
212
|
}
|
|
217
213
|
}
|
|
218
214
|
|
|
@@ -223,13 +219,7 @@ export class LethalityDistanceCalculationResponse extends CalculationResponseBas
|
|
|
223
219
|
* LethalityDistance calculation response class.
|
|
224
220
|
*
|
|
225
221
|
*/
|
|
226
|
-
constructor(data: {
|
|
227
|
-
toxicRecords: Entities.ToxicRecord[],
|
|
228
|
-
resultCode: Enums.ResultCode,
|
|
229
|
-
messages: string[],
|
|
230
|
-
calculationElapsedTime: number,
|
|
231
|
-
operationId: string
|
|
232
|
-
}) {
|
|
222
|
+
constructor(data: { toxicRecords: Entities.ToxicRecord[]; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
|
|
233
223
|
super();
|
|
234
224
|
this.toxicRecords = data.toxicRecords;
|
|
235
225
|
this.resultCode = data.resultCode;
|
|
@@ -240,25 +230,23 @@ export class LethalityDistanceCalculationResponse extends CalculationResponseBas
|
|
|
240
230
|
|
|
241
231
|
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
242
232
|
if (data.toxicRecords && Array.isArray(data.toxicRecords)) {
|
|
243
|
-
this.toxicRecords = data.toxicRecords.map(
|
|
244
|
-
(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
);
|
|
233
|
+
this.toxicRecords = data.toxicRecords.map((item) => {
|
|
234
|
+
const record = new Entities.ToxicRecord();
|
|
235
|
+
record.initialiseFromDictionary(item);
|
|
236
|
+
return record;
|
|
237
|
+
});
|
|
250
238
|
}
|
|
251
|
-
if (data.resultCode !== undefined && (typeof data.resultCode ===
|
|
239
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
252
240
|
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
253
241
|
}
|
|
254
242
|
this.messages = this.messages ?? [];
|
|
255
243
|
if (data.messages && Array.isArray(data.messages)) {
|
|
256
244
|
this.messages.push(...data.messages);
|
|
257
245
|
}
|
|
258
|
-
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime ===
|
|
246
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
|
|
259
247
|
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
260
248
|
}
|
|
261
|
-
if (data.operationId !== undefined && typeof data.operationId ===
|
|
249
|
+
if (data.operationId !== undefined && typeof data.operationId === 'string') {
|
|
262
250
|
this.operationId = data.operationId as string;
|
|
263
251
|
}
|
|
264
252
|
}
|
|
@@ -289,14 +277,14 @@ export class LethalityDistanceCalculationResponseSchema {
|
|
|
289
277
|
}).unknown(true);
|
|
290
278
|
|
|
291
279
|
this.propertyTypes = {
|
|
292
|
-
toxicRecords:
|
|
280
|
+
toxicRecords: 'Entities.ToxicRecord[]',
|
|
293
281
|
};
|
|
294
282
|
}
|
|
295
283
|
|
|
296
284
|
validate(data: LethalityDistanceCalculationResponseSchemaData): LethalityDistanceCalculationResponse {
|
|
297
285
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
298
286
|
if (error) {
|
|
299
|
-
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(
|
|
287
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
300
288
|
}
|
|
301
289
|
return this.makeCalculationResponse(value);
|
|
302
290
|
}
|