@dnv-plant/typescriptpws 1.0.65 → 1.0.66

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.
@@ -0,0 +1,38 @@
1
+ trigger:
2
+ batch: true
3
+ branches:
4
+ include:
5
+ - main
6
+ schedules:
7
+ - cron: '0 4 * * 5'
8
+ displayName: 'Weekly Friday 4 AM Run'
9
+ always: true
10
+ branches:
11
+ include:
12
+ - main
13
+ pool:
14
+ vmImage: ubuntu-latest
15
+ stages:
16
+ - stage: Veracode
17
+ jobs:
18
+ - job: 'Veracode_Scan'
19
+ steps:
20
+ - task: ArchiveFiles@2
21
+ inputs:
22
+ rootFolderOrFile: .
23
+ includeRootFolder: true
24
+ archiveType: 'zip'
25
+ archiveFile: '$(Build.ArtifactStagingDirectory)/src.zip'
26
+ replaceExistingArchive: true
27
+ - task: Veracode@3
28
+ inputs:
29
+ ConnectionDetailsSelection: 'Endpoint'
30
+ AnalysisService: 'Veracode'
31
+ veracodeAppProfile: 'PWS Clients - TypeScript PWS'
32
+ version: '$(Build.BuildNumber)'
33
+ filepath: '$(Build.ArtifactStagingDirectory)/src.zip'
34
+ failBuildIfUploadAndScanBuildStepFails: true
35
+ importResults: true
36
+ failBuildOnPolicyFail: false
37
+ maximumWaitTime: '30'
38
+ createProfile: true
package/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:21:00
5
5
  * Template: templates/typescriptpws/index.razor.
6
6
  ***********************************************************************/
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnv-plant/typescriptpws",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "description": "Integrate Phast models with our versatile APIs for enhanced customization and efficiency.",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -147,6 +147,279 @@ class CalculationFailedResponseSchema {
147
147
  }
148
148
  }
149
149
 
150
+ export interface BESSToxicSourceCalculationRequestSchemaData {
151
+ bessUnit: Entities.BESSUnit;
152
+ bessRelease: Entities.BESSRelease;
153
+ }
154
+
155
+ class BESSToxicSourceCalculationRequest extends CalculationRequestBase {
156
+ bessUnit: Entities.BESSUnit;
157
+ bessRelease: Entities.BESSRelease;
158
+
159
+ /**
160
+ * BESSToxicSource calculation request class.
161
+ *
162
+ * @param {Entities.BESSUnit} bessUnit - BESS unit under thermal runaway.
163
+ * @param {Entities.BESSRelease} bessRelease - Specifics of the release from the unit being considered.
164
+ */
165
+ constructor(
166
+ bessUnit: Entities.BESSUnit,
167
+ bessRelease: Entities.BESSRelease
168
+ ) {
169
+ super();
170
+ this.bessUnit = bessUnit;
171
+ this.bessRelease = bessRelease;
172
+ }
173
+ }
174
+
175
+ export class BESSToxicSourceCalculationRequestSchema {
176
+ schema: Joi.ObjectSchema;
177
+ propertyTypes: Record<string, string>;
178
+
179
+ /**
180
+ * Schema for the BESSToxicSource calculation request.
181
+ */
182
+ constructor() {
183
+ this.schema = Joi.object({
184
+ bessUnit: new EntitySchemas.BESSUnitSchema().schema,
185
+ bessRelease: new EntitySchemas.BESSReleaseSchema().schema,
186
+ }).unknown(true);
187
+
188
+ this.propertyTypes = {
189
+ bessUnit: "Entities.BESSUnit",
190
+ bessRelease: "Entities.BESSRelease",
191
+ };
192
+ }
193
+
194
+ validate(data: BESSToxicSourceCalculationRequestSchemaData): BESSToxicSourceCalculationRequest {
195
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
196
+ if (error) {
197
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
198
+ }
199
+ return this.makeCalculationRequest(value);
200
+ }
201
+
202
+ makeCalculationRequest(data: BESSToxicSourceCalculationRequestSchemaData): BESSToxicSourceCalculationRequest {
203
+ return new BESSToxicSourceCalculationRequest(
204
+ data.bessUnit,
205
+ data.bessRelease
206
+ );
207
+ }
208
+ }
209
+
210
+ export class BESSToxicSourceCalculation extends CalculationBase {
211
+ bessUnit: Entities.BESSUnit;
212
+ bessRelease: Entities.BESSRelease;
213
+ bessMaterial?: Entities.Material;
214
+ dischargeResult?: Entities.DischargeResult;
215
+ dischargeRecords?: Entities.DischargeRecord[];
216
+
217
+ /**
218
+ * Toxic outflow from a BESS unit.
219
+ *
220
+ * @param {Entities.BESSUnit} bessUnit - BESS unit under thermal runaway.
221
+ * @param {Entities.BESSRelease} bessRelease - Specifics of the release from the unit being considered.
222
+ */
223
+ constructor(
224
+ bessUnit: Entities.BESSUnit,
225
+ bessRelease: Entities.BESSRelease
226
+ ) {
227
+ super();
228
+ this.bessUnit = bessUnit;
229
+ this.bessRelease = bessRelease;
230
+ }
231
+
232
+ async run() {
233
+ try {
234
+ const request = new BESSToxicSourceCalculationRequest(
235
+ this.bessUnit,
236
+ this.bessRelease
237
+ );
238
+
239
+ const schema = new BESSToxicSourceCalculationRequestSchema();
240
+ const validatedRequest = schema.validate(request);
241
+
242
+ const requestJson = JSON.stringify(validatedRequest);
243
+ const url = `${getAnalyticsApiTarget()}calculatebesstoxicsource?clientId=${getClientAliasId()}`;
244
+
245
+ this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
246
+
247
+ const response = await this.postRequest(url, requestJson);
248
+
249
+ if (response.status >= 200 && response.status < 300) {
250
+ const schema = new BESSToxicSourceCalculationResponseSchema();
251
+ const validatedResponse = schema.validate(response.data);
252
+
253
+ this.resultCode = validatedResponse.resultCode;
254
+ if (this.resultCode === Enums.ResultCode.SUCCESS) {
255
+ this.bessMaterial = validatedResponse.bessMaterial;
256
+ this.dischargeResult = validatedResponse.dischargeResult;
257
+ this.dischargeRecords = validatedResponse.dischargeRecords;
258
+ this.resultCode = validatedResponse.resultCode;
259
+ this.messages = validatedResponse.messages ?? [];
260
+ this.calculationElapsedTime = validatedResponse.calculationElapsedTime;
261
+ this.operationId = validatedResponse.operationId;
262
+ } else {
263
+ this.messages.push(...(validatedResponse.messages ?? []));
264
+ }
265
+ } else {
266
+ this.handleFailedResponse(response);
267
+ }
268
+ } catch (error) {
269
+ if (error instanceof Error) {
270
+ this.messages.push(`Error: ${error.message}`);
271
+ } else {
272
+ this.messages.push(`Unexpected error: ${JSON.stringify(error)}`);
273
+ }
274
+ console.error(error);
275
+ this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
276
+ }
277
+
278
+ return this.resultCode;
279
+ }
280
+
281
+ toString() {
282
+ const parts = ["* BESSToxicSource"];
283
+
284
+ parts.push(`bessMaterial: ${String(this.bessMaterial)}`);
285
+ parts.push(`dischargeResult: ${String(this.dischargeResult)}`);
286
+ parts.push("*** dischargeRecords:");
287
+ parts.push(
288
+ this.dischargeRecords && this.dischargeRecords.length > 0
289
+ ? this.dischargeRecords.map((point) => `dischargeRecordsElement: ${point}`).join("\n")
290
+ : "dischargeRecords does not contain any elements"
291
+ );
292
+ parts.push(`resultCode: ${String(this.resultCode)}`);
293
+ parts.push("*** messages:");
294
+ parts.push(`messages: ${this.messages !== undefined ? this.messages : "(None)"}`);
295
+ parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : "(None)"}`);
296
+ parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : "(None)"}`);
297
+
298
+ return parts.join("\n");
299
+ }
300
+ }
301
+
302
+ export class BESSToxicSourceCalculationResponse extends CalculationResponseBase {
303
+ bessMaterial: Entities.Material;
304
+ dischargeResult: Entities.DischargeResult;
305
+ dischargeRecords: Entities.DischargeRecord[];
306
+
307
+ /**
308
+ * BESSToxicSource calculation response class.
309
+ *
310
+ * @param {Entities.Material} bessMaterial - Composition of the released material (dependent on batter chemistry).
311
+ * @param {Entities.DischargeResult} dischargeResult - Scalar discharge results.
312
+ * @param {Entities.DischargeRecord[]} dischargeRecords - Array of discharge records.
313
+ */
314
+ constructor(
315
+ bessMaterial: Entities.Material,
316
+ dischargeResult: Entities.DischargeResult,
317
+ dischargeRecords: Entities.DischargeRecord[],
318
+ resultCode: Enums.ResultCode,
319
+ messages: string[],
320
+ calculationElapsedTime: number,
321
+ operationId: string
322
+ ) {
323
+ super();
324
+ this.bessMaterial = bessMaterial;
325
+ this.dischargeResult = dischargeResult;
326
+ this.dischargeRecords = dischargeRecords;
327
+ this.resultCode = resultCode;
328
+ this.messages = messages;
329
+ this.calculationElapsedTime = calculationElapsedTime;
330
+ this.operationId = operationId;
331
+ }
332
+
333
+ initialiseFromDictionary(data: { [key: string]: unknown }) {
334
+ if (data.bessMaterial) {
335
+ this.bessMaterial = new Entities.Material();
336
+ this.bessMaterial.initialiseFromDictionary(data.bessMaterial as { [key: string]: unknown });
337
+ }
338
+ if (data.dischargeResult) {
339
+ this.dischargeResult = new Entities.DischargeResult();
340
+ this.dischargeResult.initialiseFromDictionary(data.dischargeResult as { [key: string]: unknown });
341
+ }
342
+ if (data.dischargeRecords && Array.isArray(data.dischargeRecords)) {
343
+ this.dischargeRecords = data.dischargeRecords.map(
344
+ (item) => {
345
+ const record = new Entities.DischargeRecord();
346
+ record.initialiseFromDictionary(item);
347
+ return record;
348
+ }
349
+ );
350
+ }
351
+ if (data.resultCode !== undefined && (typeof data.resultCode === "string" || typeof data.resultCode === "number")) {
352
+ this.resultCode = data.resultCode as Enums.ResultCode;
353
+ }
354
+ this.messages = this.messages ?? [];
355
+ if (data.messages && Array.isArray(data.messages)) {
356
+ this.messages.push(...data.messages);
357
+ }
358
+ if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === "number") {
359
+ this.calculationElapsedTime = data.calculationElapsedTime as number;
360
+ }
361
+ if (data.operationId !== undefined && typeof data.operationId === "string") {
362
+ this.operationId = data.operationId as string;
363
+ }
364
+ }
365
+ }
366
+
367
+ export interface BESSToxicSourceCalculationResponseSchemaData {
368
+ bessMaterial: Entities.Material;
369
+ dischargeResult: Entities.DischargeResult;
370
+ dischargeRecords: Entities.DischargeRecord[];
371
+ resultCode: Enums.ResultCode;
372
+ messages: string[];
373
+ calculationElapsedTime: number;
374
+ operationId: string;
375
+ }
376
+
377
+ export class BESSToxicSourceCalculationResponseSchema {
378
+ schema: Joi.ObjectSchema;
379
+ propertyTypes: Record<string, string>;
380
+
381
+ /**
382
+ * Schema for the BESSToxicSource calculation response.
383
+ */
384
+ constructor() {
385
+ this.schema = Joi.object({
386
+ bessMaterial: new EntitySchemas.MaterialSchema().schema,
387
+ dischargeResult: new EntitySchemas.DischargeResultSchema().schema,
388
+ dischargeRecords: Joi.array().items(new EntitySchemas.DischargeRecordSchema().schema).allow(null),
389
+ resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
390
+ messages: Joi.array().items(Joi.string()),
391
+ calculationElapsedTime: Joi.number().unsafe(),
392
+ operationId: Joi.string().uuid().allow(null),
393
+ }).unknown(true);
394
+
395
+ this.propertyTypes = {
396
+ bessMaterial: "Entities.Material",
397
+ dischargeResult: "Entities.DischargeResult",
398
+ dischargeRecords: "Entities.DischargeRecord[]",
399
+ };
400
+ }
401
+
402
+ validate(data: BESSToxicSourceCalculationResponseSchemaData): BESSToxicSourceCalculationResponse {
403
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
404
+ if (error) {
405
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
406
+ }
407
+ return this.makeCalculationResponse(value);
408
+ }
409
+
410
+ makeCalculationResponse(data: BESSToxicSourceCalculationResponseSchemaData): BESSToxicSourceCalculationResponse {
411
+ return new BESSToxicSourceCalculationResponse(
412
+ data.bessMaterial,
413
+ data.dischargeResult,
414
+ data.dischargeRecords,
415
+ data.resultCode,
416
+ data.messages,
417
+ data.calculationElapsedTime,
418
+ data.operationId
419
+ );
420
+ }
421
+ }
422
+
150
423
  export interface LongPipeBreachCalculationRequestSchemaData {
151
424
  pipe: Entities.Pipe;
152
425
  pipeBreach: Entities.PipeBreach;
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:45
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/calculations.razor.
6
6
  ***********************************************************************/
7
7
 
package/src/constants.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:42
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:57
5
5
  * Template: templates/typescriptpws/constants.razor.
6
6
  ***********************************************************************/
7
7
 
package/src/entities.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:44
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:58
5
5
  * Template: templates/typescriptpws/entities.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:44
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:59
5
5
  * Template: templates/typescriptpws/entityschemas.razor.
6
6
  ***********************************************************************/
7
7
 
package/src/enums.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:43
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:58
5
5
  * Template: templates/typescriptpws/enums.razor.
6
6
  ***********************************************************************/
7
7
 
package/src/materials.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:42
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:57
5
5
  * Template: templates/typescriptpws/materials.razor.
6
6
  ***********************************************************************/
7
7
 
package/src/utilities.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.65
4
- * Date/time: 04 Apr 2025 16:39:41
3
+ * Version: 1.0.66
4
+ * Date/time: 08 Apr 2025 12:20:56
5
5
  * Template: templates/typescriptpws/utilities.razor.
6
6
  ***********************************************************************/
7
7