@dnv-plant/typescriptpws 1.0.86 → 1.0.88

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.
@@ -6,12 +6,10 @@
6
6
  * Editing it may lead to inconsistent results and limit DNV's ability to provide support.
7
7
  * Please contact DNV if you believe changes are required.
8
8
  *
9
- * Version: 1.0.86
10
- * Date/time: 10 Jul 2025 09:49:06
9
+ * Version: 1.0.89
10
+ * Date/time: 29 Jul 2025 17:59:11
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
- ***********************************************************************/
13
-
14
-
12
+ ***********************************************************************/
15
13
 
16
14
  import * as Enums from "../enums";
17
15
  import * as Entities from "../entities";
@@ -36,12 +34,17 @@ class CalculationBase {
36
34
  messages: string[] = [];
37
35
  calculationElapsedTime?: number = 0.0;
38
36
  operationId?: string = "";
37
+ controller?: AbortController;
38
+
39
+ constructor(controller?: AbortController) {
40
+ this.controller = controller;
41
+ }
39
42
 
40
43
  /**
41
44
  * Post JSON to URL and time the call
42
45
  */
43
46
  async postRequest(url: string, data: string): Promise<AxiosResponse> {
44
- return postRequest(url, data);
47
+ return postRequest(url, data, this.controller);
45
48
  }
46
49
 
47
50
  /**
@@ -173,28 +176,22 @@ class PoolFireCalculationRequest extends CalculationRequestBase {
173
176
  /**
174
177
  * PoolFire calculation request class.
175
178
  *
176
- * @param {Entities.Material} material - a material entity with post-discharge composition.
177
- * @param {Entities.PoolRecord[]} poolRecords - an array of pool records.
178
- * @param {number} poolRecordCount - Number of pool records.
179
- * @param {Entities.Weather} weather - a weather entity.
180
- * @param {Entities.Substrate} substrate - a substrate entity.
181
- * @param {Entities.FlammableParameters} flammableParameters - a flammable parameters entity.
182
179
  */
183
- constructor(
180
+ constructor(data: {
184
181
  material: Entities.Material,
185
182
  poolRecords: Entities.PoolRecord[],
186
183
  poolRecordCount: number,
187
184
  weather: Entities.Weather,
188
185
  substrate: Entities.Substrate,
189
186
  flammableParameters: Entities.FlammableParameters
190
- ) {
187
+ }) {
191
188
  super();
192
- this.material = material;
193
- this.poolRecords = poolRecords;
194
- this.poolRecordCount = poolRecordCount;
195
- this.weather = weather;
196
- this.substrate = substrate;
197
- this.flammableParameters = flammableParameters;
189
+ this.material = data.material;
190
+ this.poolRecords = data.poolRecords;
191
+ this.poolRecordCount = data.poolRecordCount;
192
+ this.weather = data.weather;
193
+ this.substrate = data.substrate;
194
+ this.flammableParameters = data.flammableParameters;
198
195
  }
199
196
  }
200
197
 
@@ -234,14 +231,7 @@ export class PoolFireCalculationRequestSchema {
234
231
  }
235
232
 
236
233
  makeCalculationRequest(data: PoolFireCalculationRequestSchemaData): PoolFireCalculationRequest {
237
- return new PoolFireCalculationRequest(
238
- data.material,
239
- data.poolRecords,
240
- data.poolRecordCount,
241
- data.weather,
242
- data.substrate,
243
- data.flammableParameters
244
- );
234
+ return new PoolFireCalculationRequest(data);
245
235
  }
246
236
  }
247
237
 
@@ -258,40 +248,35 @@ export class PoolFireCalculation extends CalculationBase {
258
248
  /**
259
249
  * Determines the flame produced from an ignited flammable pool.
260
250
  *
261
- * @param {Entities.Material} material - a material entity with post-discharge composition.
262
- * @param {Entities.PoolRecord[]} poolRecords - an array of pool records.
263
- * @param {number} poolRecordCount - Number of pool records.
264
- * @param {Entities.Weather} weather - a weather entity.
265
- * @param {Entities.Substrate} substrate - a substrate entity.
266
- * @param {Entities.FlammableParameters} flammableParameters - a flammable parameters entity.
267
251
  */
268
- constructor(
252
+ constructor(data: {
269
253
  material: Entities.Material,
270
254
  poolRecords: Entities.PoolRecord[],
271
255
  poolRecordCount: number,
272
256
  weather: Entities.Weather,
273
257
  substrate: Entities.Substrate,
274
258
  flammableParameters: Entities.FlammableParameters
275
- ) {
276
- super();
277
- this.material = material;
278
- this.poolRecords = poolRecords;
279
- this.poolRecordCount = poolRecordCount;
280
- this.weather = weather;
281
- this.substrate = substrate;
282
- this.flammableParameters = flammableParameters;
259
+ controller?: AbortController;
260
+ }) {
261
+ super(data.controller);
262
+ this.material = data.material;
263
+ this.poolRecords = data.poolRecords;
264
+ this.poolRecordCount = data.poolRecordCount;
265
+ this.weather = data.weather;
266
+ this.substrate = data.substrate;
267
+ this.flammableParameters = data.flammableParameters;
283
268
  }
284
269
 
285
270
  async run() {
286
271
  try {
287
- const request = new PoolFireCalculationRequest(
288
- this.material,
289
- this.poolRecords,
290
- this.poolRecordCount,
291
- this.weather,
292
- this.substrate,
293
- this.flammableParameters
294
- );
272
+ const request = new PoolFireCalculationRequest({
273
+ material: this.material,
274
+ poolRecords: this.poolRecords,
275
+ poolRecordCount: this.poolRecordCount,
276
+ weather: this.weather,
277
+ substrate: this.substrate,
278
+ flammableParameters: this.flammableParameters
279
+ });
295
280
 
296
281
  const schema = new PoolFireCalculationRequestSchema();
297
282
  const validatedRequest = schema.validate(request);
@@ -358,24 +343,22 @@ export class PoolFireCalculationResponse extends CalculationResponseBase {
358
343
  /**
359
344
  * PoolFire calculation response class.
360
345
  *
361
- * @param {Entities.PoolFireFlameResult} poolFireFlameResult - Scalar flame results.
362
- * @param {Entities.FlameRecord[]} flameRecords - an array of pool fire flame records.
363
346
  */
364
- constructor(
347
+ constructor(data: {
365
348
  poolFireFlameResult: Entities.PoolFireFlameResult,
366
349
  flameRecords: Entities.FlameRecord[],
367
350
  resultCode: Enums.ResultCode,
368
351
  messages: string[],
369
352
  calculationElapsedTime: number,
370
353
  operationId: string
371
- ) {
354
+ }) {
372
355
  super();
373
- this.poolFireFlameResult = poolFireFlameResult;
374
- this.flameRecords = flameRecords;
375
- this.resultCode = resultCode;
376
- this.messages = messages;
377
- this.calculationElapsedTime = calculationElapsedTime;
378
- this.operationId = operationId;
356
+ this.poolFireFlameResult = data.poolFireFlameResult;
357
+ this.flameRecords = data.flameRecords;
358
+ this.resultCode = data.resultCode;
359
+ this.messages = data.messages;
360
+ this.calculationElapsedTime = data.calculationElapsedTime;
361
+ this.operationId = data.operationId;
379
362
  }
380
363
 
381
364
  initialiseFromDictionary(data: { [key: string]: unknown }) {
@@ -449,13 +432,6 @@ export class PoolFireCalculationResponseSchema {
449
432
  }
450
433
 
451
434
  makeCalculationResponse(data: PoolFireCalculationResponseSchemaData): PoolFireCalculationResponse {
452
- return new PoolFireCalculationResponse(
453
- data.poolFireFlameResult,
454
- data.flameRecords,
455
- data.resultCode,
456
- data.messages,
457
- data.calculationElapsedTime,
458
- data.operationId
459
- );
435
+ return new PoolFireCalculationResponse(data);
460
436
  }
461
437
  }
@@ -6,12 +6,10 @@
6
6
  * Editing it may lead to inconsistent results and limit DNV's ability to provide support.
7
7
  * Please contact DNV if you believe changes are required.
8
8
  *
9
- * Version: 1.0.86
10
- * Date/time: 10 Jul 2025 09:49:06
9
+ * Version: 1.0.89
10
+ * Date/time: 29 Jul 2025 17:59:11
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
- ***********************************************************************/
13
-
14
-
12
+ ***********************************************************************/
15
13
 
16
14
  import * as Enums from "../enums";
17
15
  import * as Entities from "../entities";
@@ -36,12 +34,17 @@ class CalculationBase {
36
34
  messages: string[] = [];
37
35
  calculationElapsedTime?: number = 0.0;
38
36
  operationId?: string = "";
37
+ controller?: AbortController;
38
+
39
+ constructor(controller?: AbortController) {
40
+ this.controller = controller;
41
+ }
39
42
 
40
43
  /**
41
44
  * Post JSON to URL and time the call
42
45
  */
43
46
  async postRequest(url: string, data: string): Promise<AxiosResponse> {
44
- return postRequest(url, data);
47
+ return postRequest(url, data, this.controller);
45
48
  }
46
49
 
47
50
  /**
@@ -165,16 +168,14 @@ class FlashCalculationRequest extends CalculationRequestBase {
165
168
  /**
166
169
  * Flash calculation request class.
167
170
  *
168
- * @param {Entities.Material} material - a material entity.
169
- * @param {Entities.State} materialState - a state entity.
170
171
  */
171
- constructor(
172
+ constructor(data: {
172
173
  material: Entities.Material,
173
174
  materialState: Entities.State
174
- ) {
175
+ }) {
175
176
  super();
176
- this.material = material;
177
- this.materialState = materialState;
177
+ this.material = data.material;
178
+ this.materialState = data.materialState;
178
179
  }
179
180
  }
180
181
 
@@ -206,10 +207,7 @@ export class FlashCalculationRequestSchema {
206
207
  }
207
208
 
208
209
  makeCalculationRequest(data: FlashCalculationRequestSchemaData): FlashCalculationRequest {
209
- return new FlashCalculationRequest(
210
- data.material,
211
- data.materialState
212
- );
210
+ return new FlashCalculationRequest(data);
213
211
  }
214
212
  }
215
213
 
@@ -222,24 +220,23 @@ export class FlashCalculation extends CalculationBase {
222
220
  * Calculates fluid properties for a user-defined material where the user has defined the pressure and temperature or pressure and liquid fraction. The model carries out a flash calculation
223
221
  to obtain the fluid properties.
224
222
  *
225
- * @param {Entities.Material} material - a material entity.
226
- * @param {Entities.State} materialState - a state entity.
227
223
  */
228
- constructor(
224
+ constructor(data: {
229
225
  material: Entities.Material,
230
226
  materialState: Entities.State
231
- ) {
232
- super();
233
- this.material = material;
234
- this.materialState = materialState;
227
+ controller?: AbortController;
228
+ }) {
229
+ super(data.controller);
230
+ this.material = data.material;
231
+ this.materialState = data.materialState;
235
232
  }
236
233
 
237
234
  async run() {
238
235
  try {
239
- const request = new FlashCalculationRequest(
240
- this.material,
241
- this.materialState
242
- );
236
+ const request = new FlashCalculationRequest({
237
+ material: this.material,
238
+ materialState: this.materialState
239
+ });
243
240
 
244
241
  const schema = new FlashCalculationRequestSchema();
245
242
  const validatedRequest = schema.validate(request);
@@ -298,21 +295,20 @@ export class FlashCalculationResponse extends CalculationResponseBase {
298
295
  /**
299
296
  * Flash calculation response class.
300
297
  *
301
- * @param {Entities.FlashResult} flashResult - Fluid properties at given conditions.
302
298
  */
303
- constructor(
299
+ constructor(data: {
304
300
  flashResult: Entities.FlashResult,
305
301
  resultCode: Enums.ResultCode,
306
302
  messages: string[],
307
303
  calculationElapsedTime: number,
308
304
  operationId: string
309
- ) {
305
+ }) {
310
306
  super();
311
- this.flashResult = flashResult;
312
- this.resultCode = resultCode;
313
- this.messages = messages;
314
- this.calculationElapsedTime = calculationElapsedTime;
315
- this.operationId = operationId;
307
+ this.flashResult = data.flashResult;
308
+ this.resultCode = data.resultCode;
309
+ this.messages = data.messages;
310
+ this.calculationElapsedTime = data.calculationElapsedTime;
311
+ this.operationId = data.operationId;
316
312
  }
317
313
 
318
314
  initialiseFromDictionary(data: { [key: string]: unknown }) {
@@ -374,12 +370,6 @@ export class FlashCalculationResponseSchema {
374
370
  }
375
371
 
376
372
  makeCalculationResponse(data: FlashCalculationResponseSchemaData): FlashCalculationResponse {
377
- return new FlashCalculationResponse(
378
- data.flashResult,
379
- data.resultCode,
380
- data.messages,
381
- data.calculationElapsedTime,
382
- data.operationId
383
- );
373
+ return new FlashCalculationResponse(data);
384
374
  }
385
375
  }