@dnv-plant/typescriptpws 1.0.27 → 1.0.38
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 +17 -4
- package/package.json +1 -1
- package/src/calculations/applicationTools.ts +368 -0
- package/src/calculations/discharge.ts +1817 -0
- package/src/calculations/dispersion.ts +511 -0
- package/src/calculations/dispersionView.ts +2544 -0
- package/src/calculations/fireball.ts +458 -0
- package/src/calculations/jetFire.ts +760 -0
- package/src/calculations/lateExplosion.ts +937 -0
- package/src/calculations/linkedRunners.ts +3724 -0
- package/src/calculations/poolFire.ts +458 -0
- package/src/calculations/properties.ts +382 -0
- package/src/calculations/radiation.ts +3521 -0
- package/src/calculations/standalones.ts +432 -0
- package/src/calculations/toxics.ts +469 -0
- package/src/calculations/utilities.ts +3320 -0
- package/src/constants.ts +2 -2
- package/src/entities.ts +2 -2
- package/src/entity-schemas.ts +2 -2
- package/src/enums.ts +2 -2
- package/src/materials.ts +2 -2
- package/src/utilities.ts +2 -2
- package/src/calculations.ts +0 -17774
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* This file has been auto-generated by a code generation tool.
|
|
3
|
+
* Version: 1.0.38
|
|
4
|
+
* Date/time: 24 Mar 2025 16:46:20
|
|
5
|
+
* Template: templates/typescriptpws/calculations.razor.
|
|
6
|
+
***********************************************************************/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import * as Enums from "../enums";
|
|
11
|
+
import * as Entities from "../entities";
|
|
12
|
+
import * as EntitySchemas from "../entity-schemas";
|
|
13
|
+
import { getAnalyticsApiTarget, getClientAliasId, postRequest } from "../utilities";
|
|
14
|
+
|
|
15
|
+
import Joi from "joi";
|
|
16
|
+
import { AxiosResponse } from "axios";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CalculationRequestBase {
|
|
20
|
+
/**
|
|
21
|
+
* Calculation request base class.
|
|
22
|
+
*/
|
|
23
|
+
constructor() {
|
|
24
|
+
// Base class initialization code
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class CalculationBase {
|
|
29
|
+
resultCode?: Enums.ResultCode = Enums.ResultCode.SUCCESS;
|
|
30
|
+
messages: string[] = [];
|
|
31
|
+
calculationElapsedTime?: number = 0.0;
|
|
32
|
+
operationId?: string = "";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Post JSON to URL and time the call
|
|
36
|
+
*/
|
|
37
|
+
async postRequest(url: string, data: string): Promise<AxiosResponse> {
|
|
38
|
+
return postRequest(url, data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Utility method to print the messages returned by the calculation.
|
|
43
|
+
*/
|
|
44
|
+
printMessages(): void {
|
|
45
|
+
if (this.messages && this.messages.length > 0) {
|
|
46
|
+
this.messages.forEach((message) => console.log(message));
|
|
47
|
+
} else {
|
|
48
|
+
console.log("No messages");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Utility method to handle a failed response.
|
|
54
|
+
*/
|
|
55
|
+
handleFailedResponse(response: AxiosResponse): void {
|
|
56
|
+
try {
|
|
57
|
+
const validatedFailedResponse = new CalculationFailedResponseSchema().validate(response.data);
|
|
58
|
+
|
|
59
|
+
this.resultCode = validatedFailedResponse.resultCode;
|
|
60
|
+
this.messages.push(...(validatedFailedResponse.messages ?? []));
|
|
61
|
+
this.calculationElapsedTime = validatedFailedResponse.calculationElapsedTime;
|
|
62
|
+
this.operationId = validatedFailedResponse.operationId;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
this.messages.push(`Failed to parse response: ${error.message}`);
|
|
66
|
+
} else {
|
|
67
|
+
this.messages.push("An unknown error occurred during response parsing.");
|
|
68
|
+
}
|
|
69
|
+
console.error("Failed to parse response:", error);
|
|
70
|
+
} finally {
|
|
71
|
+
this.messages.push(`${response.statusText} (Status code: ${response.status})`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
class CalculationResponseBase {
|
|
77
|
+
resultCode?: Enums.ResultCode;
|
|
78
|
+
messages?: string[];
|
|
79
|
+
calculationElapsedTime?: number;
|
|
80
|
+
operationId?: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Calculation response base class.
|
|
84
|
+
*/
|
|
85
|
+
constructor(
|
|
86
|
+
resultCode?: Enums.ResultCode,
|
|
87
|
+
messages?: string[],
|
|
88
|
+
calculationElapsedTime?: number,
|
|
89
|
+
operationId?: string
|
|
90
|
+
) {
|
|
91
|
+
this.resultCode = resultCode;
|
|
92
|
+
this.messages = messages;
|
|
93
|
+
this.calculationElapsedTime = calculationElapsedTime;
|
|
94
|
+
this.operationId = operationId;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class CalculationFailedResponse extends CalculationResponseBase {
|
|
99
|
+
/**
|
|
100
|
+
* Calculation failed response class.
|
|
101
|
+
*/
|
|
102
|
+
constructor(
|
|
103
|
+
resultCode?: Enums.ResultCode,
|
|
104
|
+
messages: string[] = [],
|
|
105
|
+
calculationElapsedTime: number = 0,
|
|
106
|
+
operationId: string = ""
|
|
107
|
+
) {
|
|
108
|
+
super(resultCode, messages, calculationElapsedTime, operationId);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
class CalculationFailedResponseSchema {
|
|
113
|
+
schema: Joi.ObjectSchema;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Calculation failed response schema.
|
|
117
|
+
*/
|
|
118
|
+
constructor() {
|
|
119
|
+
this.schema = Joi.object({
|
|
120
|
+
resultCode: Joi.string()
|
|
121
|
+
.valid(...Object.values(Enums.ResultCode))
|
|
122
|
+
.required(),
|
|
123
|
+
messages: Joi.array().items(Joi.string()).required(),
|
|
124
|
+
calculationElapsedTime: Joi.number().required(),
|
|
125
|
+
operationId: Joi.string().required(),
|
|
126
|
+
}).unknown(true);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
validate(data: {
|
|
130
|
+
resultCode: Enums.ResultCode;
|
|
131
|
+
messages: string[];
|
|
132
|
+
calculationElapsedTime: number;
|
|
133
|
+
operationId: string;
|
|
134
|
+
}) {
|
|
135
|
+
const { error, value } = this.schema.validate(data);
|
|
136
|
+
if (error) throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
|
|
137
|
+
return this.makeCalculationFailedResponse(value);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
makeCalculationFailedResponse(data: {
|
|
141
|
+
resultCode: Enums.ResultCode;
|
|
142
|
+
messages: string[];
|
|
143
|
+
calculationElapsedTime: number;
|
|
144
|
+
operationId: string;
|
|
145
|
+
}) {
|
|
146
|
+
return new CalculationFailedResponse(data.resultCode, data.messages, data.calculationElapsedTime, data.operationId);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface FireballCalculationRequestSchemaData {
|
|
151
|
+
material: Entities.Material;
|
|
152
|
+
state: Entities.State;
|
|
153
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
154
|
+
dischargeRecordCount: number;
|
|
155
|
+
dischargeResult: Entities.DischargeResult;
|
|
156
|
+
weather: Entities.Weather;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class FireballCalculationRequest extends CalculationRequestBase {
|
|
160
|
+
material: Entities.Material;
|
|
161
|
+
state: Entities.State;
|
|
162
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
163
|
+
dischargeRecordCount: number;
|
|
164
|
+
dischargeResult: Entities.DischargeResult;
|
|
165
|
+
weather: Entities.Weather;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Fireball calculation request class.
|
|
169
|
+
*
|
|
170
|
+
* @param {Entities.Material} material - A Material entity with post-discharge composition.
|
|
171
|
+
* @param {Entities.State} state - A State entity.
|
|
172
|
+
* @param {Entities.DischargeRecord[]} dischargeRecords - An Array of Discharge Records.
|
|
173
|
+
* @param {number} dischargeRecordCount - Number of Discharge Records.
|
|
174
|
+
* @param {Entities.DischargeResult} dischargeResult - Discharge / source term definition.
|
|
175
|
+
* @param {Entities.Weather} weather - A Weather entity.
|
|
176
|
+
*/
|
|
177
|
+
constructor(
|
|
178
|
+
material: Entities.Material,
|
|
179
|
+
state: Entities.State,
|
|
180
|
+
dischargeRecords: Entities.DischargeRecord[],
|
|
181
|
+
dischargeRecordCount: number,
|
|
182
|
+
dischargeResult: Entities.DischargeResult,
|
|
183
|
+
weather: Entities.Weather
|
|
184
|
+
) {
|
|
185
|
+
super();
|
|
186
|
+
this.material = material;
|
|
187
|
+
this.state = state;
|
|
188
|
+
this.dischargeRecords = dischargeRecords;
|
|
189
|
+
this.dischargeRecordCount = dischargeRecordCount;
|
|
190
|
+
this.dischargeResult = dischargeResult;
|
|
191
|
+
this.weather = weather;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export class FireballCalculationRequestSchema {
|
|
196
|
+
schema: Joi.ObjectSchema;
|
|
197
|
+
propertyTypes: Record<string, string>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Schema for the Fireball calculation request.
|
|
201
|
+
*/
|
|
202
|
+
constructor() {
|
|
203
|
+
this.schema = Joi.object({
|
|
204
|
+
material: new EntitySchemas.MaterialSchema().schema,
|
|
205
|
+
state: new EntitySchemas.StateSchema().schema,
|
|
206
|
+
dischargeRecords: Joi.array().items(new EntitySchemas.DischargeRecordSchema().schema).allow(null),
|
|
207
|
+
dischargeRecordCount: Joi.number().integer(),
|
|
208
|
+
dischargeResult: new EntitySchemas.DischargeResultSchema().schema,
|
|
209
|
+
weather: new EntitySchemas.WeatherSchema().schema,
|
|
210
|
+
}).unknown(true);
|
|
211
|
+
|
|
212
|
+
this.propertyTypes = {
|
|
213
|
+
material: "Entities.Material",
|
|
214
|
+
state: "Entities.State",
|
|
215
|
+
dischargeRecords: "Entities.DischargeRecord[]",
|
|
216
|
+
dischargeRecordCount: "number",
|
|
217
|
+
dischargeResult: "Entities.DischargeResult",
|
|
218
|
+
weather: "Entities.Weather",
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
validate(data: FireballCalculationRequestSchemaData): FireballCalculationRequest {
|
|
223
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
224
|
+
if (error) {
|
|
225
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
|
|
226
|
+
}
|
|
227
|
+
return this.makeCalculationRequest(value);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
makeCalculationRequest(data: FireballCalculationRequestSchemaData): FireballCalculationRequest {
|
|
231
|
+
return new FireballCalculationRequest(
|
|
232
|
+
data.material,
|
|
233
|
+
data.state,
|
|
234
|
+
data.dischargeRecords,
|
|
235
|
+
data.dischargeRecordCount,
|
|
236
|
+
data.dischargeResult,
|
|
237
|
+
data.weather
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export class FireballCalculation extends CalculationBase {
|
|
243
|
+
material: Entities.Material;
|
|
244
|
+
state: Entities.State;
|
|
245
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
246
|
+
dischargeRecordCount: number;
|
|
247
|
+
dischargeResult: Entities.DischargeResult;
|
|
248
|
+
weather: Entities.Weather;
|
|
249
|
+
flameResult?: Entities.FlameResult;
|
|
250
|
+
flameRecords?: Entities.FlameRecord[];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Calculates a fireball produced from an instantaneous or (short duration) time-varying source term. The utput can be used can be used to run radiation models for prediction of thermal effects.
|
|
254
|
+
*
|
|
255
|
+
* @param {Entities.Material} material - A Material entity with post-discharge composition.
|
|
256
|
+
* @param {Entities.State} state - A State entity.
|
|
257
|
+
* @param {Entities.DischargeRecord[]} dischargeRecords - An Array of Discharge Records.
|
|
258
|
+
* @param {number} dischargeRecordCount - Number of Discharge Records.
|
|
259
|
+
* @param {Entities.DischargeResult} dischargeResult - Discharge / source term definition.
|
|
260
|
+
* @param {Entities.Weather} weather - A Weather entity.
|
|
261
|
+
*/
|
|
262
|
+
constructor(
|
|
263
|
+
material: Entities.Material,
|
|
264
|
+
state: Entities.State,
|
|
265
|
+
dischargeRecords: Entities.DischargeRecord[],
|
|
266
|
+
dischargeRecordCount: number,
|
|
267
|
+
dischargeResult: Entities.DischargeResult,
|
|
268
|
+
weather: Entities.Weather
|
|
269
|
+
) {
|
|
270
|
+
super();
|
|
271
|
+
this.material = material;
|
|
272
|
+
this.state = state;
|
|
273
|
+
this.dischargeRecords = dischargeRecords;
|
|
274
|
+
this.dischargeRecordCount = dischargeRecordCount;
|
|
275
|
+
this.dischargeResult = dischargeResult;
|
|
276
|
+
this.weather = weather;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async run() {
|
|
280
|
+
try {
|
|
281
|
+
const request = new FireballCalculationRequest(
|
|
282
|
+
this.material,
|
|
283
|
+
this.state,
|
|
284
|
+
this.dischargeRecords,
|
|
285
|
+
this.dischargeRecordCount,
|
|
286
|
+
this.dischargeResult,
|
|
287
|
+
this.weather
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const schema = new FireballCalculationRequestSchema();
|
|
291
|
+
const validatedRequest = schema.validate(request);
|
|
292
|
+
|
|
293
|
+
const requestJson = JSON.stringify(validatedRequest);
|
|
294
|
+
const url = `${getAnalyticsApiTarget()}calculatefireball?clientId=${getClientAliasId()}`;
|
|
295
|
+
|
|
296
|
+
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
297
|
+
|
|
298
|
+
const response = await this.postRequest(url, requestJson);
|
|
299
|
+
|
|
300
|
+
if (response.status >= 200 && response.status < 300) {
|
|
301
|
+
const schema = new FireballCalculationResponseSchema();
|
|
302
|
+
const validatedResponse = schema.validate(response.data);
|
|
303
|
+
|
|
304
|
+
this.resultCode = validatedResponse.resultCode;
|
|
305
|
+
if (this.resultCode === Enums.ResultCode.SUCCESS) {
|
|
306
|
+
this.flameResult = validatedResponse.flameResult;
|
|
307
|
+
this.flameRecords = validatedResponse.flameRecords;
|
|
308
|
+
this.resultCode = validatedResponse.resultCode;
|
|
309
|
+
this.messages = validatedResponse.messages ?? [];
|
|
310
|
+
this.calculationElapsedTime = validatedResponse.calculationElapsedTime;
|
|
311
|
+
this.operationId = validatedResponse.operationId;
|
|
312
|
+
} else {
|
|
313
|
+
this.messages.push(...(validatedResponse.messages ?? []));
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
this.handleFailedResponse(response);
|
|
317
|
+
}
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (error instanceof Error) {
|
|
320
|
+
this.messages.push(`Error: ${error.message}`);
|
|
321
|
+
} else {
|
|
322
|
+
this.messages.push(`Unexpected error: ${JSON.stringify(error)}`);
|
|
323
|
+
}
|
|
324
|
+
console.error(error);
|
|
325
|
+
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return this.resultCode;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
toString() {
|
|
332
|
+
const parts = ["* Fireball"];
|
|
333
|
+
|
|
334
|
+
parts.push(`flameResult: ${String(this.flameResult)}`);
|
|
335
|
+
parts.push("*** flameRecords:");
|
|
336
|
+
parts.push(
|
|
337
|
+
this.flameRecords && this.flameRecords.length > 0
|
|
338
|
+
? this.flameRecords.map((point) => `flameRecordsElement: ${point}`).join("\n")
|
|
339
|
+
: "flameRecords does not contain any elements"
|
|
340
|
+
);
|
|
341
|
+
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
342
|
+
parts.push("*** messages:");
|
|
343
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : "(None)"}`);
|
|
344
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : "(None)"}`);
|
|
345
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : "(None)"}`);
|
|
346
|
+
|
|
347
|
+
return parts.join("\n");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export class FireballCalculationResponse extends CalculationResponseBase {
|
|
352
|
+
flameResult: Entities.FlameResult;
|
|
353
|
+
flameRecords: Entities.FlameRecord[];
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Fireball calculation response class.
|
|
357
|
+
*
|
|
358
|
+
* @param {Entities.FlameResult} flameResult - Flame scalar result.
|
|
359
|
+
* @param {Entities.FlameRecord[]} flameRecords - An array of fireball flame records.
|
|
360
|
+
*/
|
|
361
|
+
constructor(
|
|
362
|
+
flameResult: Entities.FlameResult,
|
|
363
|
+
flameRecords: Entities.FlameRecord[],
|
|
364
|
+
resultCode: Enums.ResultCode,
|
|
365
|
+
messages: string[],
|
|
366
|
+
calculationElapsedTime: number,
|
|
367
|
+
operationId: string
|
|
368
|
+
) {
|
|
369
|
+
super();
|
|
370
|
+
this.flameResult = flameResult;
|
|
371
|
+
this.flameRecords = flameRecords;
|
|
372
|
+
this.resultCode = resultCode;
|
|
373
|
+
this.messages = messages;
|
|
374
|
+
this.calculationElapsedTime = calculationElapsedTime;
|
|
375
|
+
this.operationId = operationId;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
379
|
+
if (data.flameResult) {
|
|
380
|
+
this.flameResult = new Entities.FlameResult();
|
|
381
|
+
this.flameResult.initialiseFromDictionary(data.flameResult as { [key: string]: unknown });
|
|
382
|
+
}
|
|
383
|
+
if (data.flameRecords && Array.isArray(data.flameRecords)) {
|
|
384
|
+
this.flameRecords = data.flameRecords.map(
|
|
385
|
+
(item) => {
|
|
386
|
+
const record = new Entities.FlameRecord();
|
|
387
|
+
record.initialiseFromDictionary(item);
|
|
388
|
+
return record;
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === "string" || typeof data.resultCode === "number")) {
|
|
393
|
+
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
394
|
+
}
|
|
395
|
+
this.messages = this.messages ?? [];
|
|
396
|
+
if (data.messages && Array.isArray(data.messages)) {
|
|
397
|
+
this.messages.push(...data.messages);
|
|
398
|
+
}
|
|
399
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === "number") {
|
|
400
|
+
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
401
|
+
}
|
|
402
|
+
if (data.operationId !== undefined && typeof data.operationId === "string") {
|
|
403
|
+
this.operationId = data.operationId as string;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface FireballCalculationResponseSchemaData {
|
|
409
|
+
flameResult: Entities.FlameResult;
|
|
410
|
+
flameRecords: Entities.FlameRecord[];
|
|
411
|
+
resultCode: Enums.ResultCode;
|
|
412
|
+
messages: string[];
|
|
413
|
+
calculationElapsedTime: number;
|
|
414
|
+
operationId: string;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export class FireballCalculationResponseSchema {
|
|
418
|
+
schema: Joi.ObjectSchema;
|
|
419
|
+
propertyTypes: Record<string, string>;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Schema for the Fireball calculation response.
|
|
423
|
+
*/
|
|
424
|
+
constructor() {
|
|
425
|
+
this.schema = Joi.object({
|
|
426
|
+
flameResult: new EntitySchemas.FlameResultSchema().schema,
|
|
427
|
+
flameRecords: Joi.array().items(new EntitySchemas.FlameRecordSchema().schema).allow(null),
|
|
428
|
+
resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
|
|
429
|
+
messages: Joi.array().items(Joi.string()),
|
|
430
|
+
calculationElapsedTime: Joi.number().unsafe(),
|
|
431
|
+
operationId: Joi.string().uuid().allow(null),
|
|
432
|
+
}).unknown(true);
|
|
433
|
+
|
|
434
|
+
this.propertyTypes = {
|
|
435
|
+
flameResult: "Entities.FlameResult",
|
|
436
|
+
flameRecords: "Entities.FlameRecord[]",
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
validate(data: FireballCalculationResponseSchemaData): FireballCalculationResponse {
|
|
441
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
442
|
+
if (error) {
|
|
443
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
|
|
444
|
+
}
|
|
445
|
+
return this.makeCalculationResponse(value);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
makeCalculationResponse(data: FireballCalculationResponseSchemaData): FireballCalculationResponse {
|
|
449
|
+
return new FireballCalculationResponse(
|
|
450
|
+
data.flameResult,
|
|
451
|
+
data.flameRecords,
|
|
452
|
+
data.resultCode,
|
|
453
|
+
data.messages,
|
|
454
|
+
data.calculationElapsedTime,
|
|
455
|
+
data.operationId
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|