@dnv-plant/typescriptpws 1.0.97 → 1.0.98-alpha.2397542

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.
@@ -1,15 +1,19 @@
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.97
10
- * Date/time: 13 Apr 2026 17:02:52
11
- * Template: templates/typescriptpws/calculations.razor.
12
- ***********************************************************************/
1
+ // ************************************************************************************
2
+ // *
3
+ // * This file has been auto-generated by a code generation tool.
4
+ // *
5
+ // * DO NOT MODIFY THIS FILE
6
+ // * This file is maintained by DNV.
7
+ // * Editing it may lead to inconsistent results and limit DNV's ability to provide support.
8
+ // * Please contact DNV if you believe changes are required.
9
+ // *
10
+ // * API version: 1.0.
11
+ // * MDE version: 9.3.8211.
12
+ // * Package version: 1.0.98
13
+ // * Date/time: 23 Jun 2026 12:11:11.
14
+ // * Template: TYPE_SCRIPT_PWS/calculations.sbn.
15
+ // *
16
+ // ************************************************************************************
13
17
 
14
18
  import * as Enums from '../enums';
15
19
  import * as Entities from '../entities';
@@ -172,8 +176,8 @@ export class ConvertCompositionMassToMoleCalculationResponse extends Calculation
172
176
  }
173
177
 
174
178
  initialiseFromDictionary(data: { [key: string]: unknown }) {
175
- if (data.compositionMole && Array.isArray(data.compositionMole)) {
176
- this.compositionMole = data.compositionMole.map((item) => parseFloat(item));
179
+ if (data.compositionMole !== undefined && Array.isArray(data.compositionMole)) {
180
+ this.compositionMole = data.compositionMole as number[];
177
181
  }
178
182
  if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
179
183
  this.resultCode = data.resultCode as Enums.ResultCode;
@@ -386,8 +390,8 @@ export class ConvertCompositionMoleToMassCalculationResponse extends Calculation
386
390
  }
387
391
 
388
392
  initialiseFromDictionary(data: { [key: string]: unknown }) {
389
- if (data.compositionMass && Array.isArray(data.compositionMass)) {
390
- this.compositionMass = data.compositionMass.map((item) => parseFloat(item));
393
+ if (data.compositionMass !== undefined && Array.isArray(data.compositionMass)) {
394
+ this.compositionMass = data.compositionMass as number[];
391
395
  }
392
396
  if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
393
397
  this.resultCode = data.resultCode as Enums.ResultCode;
@@ -642,6 +646,440 @@ export class GetMassFromVesselCalculationResponseSchema {
642
646
  }
643
647
  }
644
648
 
649
+ export interface GetPipelineLengthCalculationRequestSchemaData {
650
+ pipe: Entities.Pipe;
651
+ }
652
+
653
+ class GetPipelineLengthCalculationRequest extends CalculationRequestBase {
654
+ pipe: Entities.Pipe;
655
+
656
+ /**
657
+ * GetPipelineLength calculation request class.
658
+ *
659
+ */
660
+ constructor(data: { pipe: Entities.Pipe }) {
661
+ super();
662
+ this.pipe = data.pipe;
663
+ }
664
+ }
665
+
666
+ export class GetPipelineLengthCalculationRequestSchema {
667
+ schema: Joi.ObjectSchema;
668
+ propertyTypes: Record<string, string>;
669
+
670
+ /**
671
+ * Schema for the GetPipelineLength calculation request.
672
+ */
673
+ constructor() {
674
+ this.schema = Joi.object({
675
+ pipe: new EntitySchemas.PipeSchema().schema,
676
+ }).unknown(true);
677
+
678
+ this.propertyTypes = {
679
+ pipe: 'Entities.Pipe',
680
+ };
681
+ }
682
+
683
+ validate(data: GetPipelineLengthCalculationRequestSchemaData): GetPipelineLengthCalculationRequest {
684
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
685
+ if (error) {
686
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
687
+ }
688
+ return this.makeCalculationRequest(value);
689
+ }
690
+
691
+ makeCalculationRequest(data: GetPipelineLengthCalculationRequestSchemaData): GetPipelineLengthCalculationRequest {
692
+ return new GetPipelineLengthCalculationRequest(data);
693
+ }
694
+ }
695
+
696
+ export class GetPipelineLengthCalculation extends CalculationBase {
697
+ pipe: Entities.Pipe;
698
+ length?: number;
699
+
700
+ /**
701
+ * Determines the pipeline length based on the coordinates of the nodes of the pipeline.
702
+ *
703
+ */
704
+ constructor(data: { pipe: Entities.Pipe; controller?: AbortController }) {
705
+ super(data.controller);
706
+ this.pipe = data.pipe;
707
+ }
708
+
709
+ async run() {
710
+ try {
711
+ const request = new GetPipelineLengthCalculationRequest({
712
+ pipe: this.pipe,
713
+ });
714
+
715
+ const schema = new GetPipelineLengthCalculationRequestSchema();
716
+ const validatedRequest = schema.validate(request);
717
+
718
+ const requestJson = JSON.stringify(validatedRequest);
719
+ const url = `${getAnalyticsApiTarget()}getpipelinelength?clientId=${getClientAliasId()}`;
720
+
721
+ this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
722
+
723
+ const { data } = await this.postRequest(url, requestJson);
724
+
725
+ const responseSchema = new GetPipelineLengthCalculationResponseSchema();
726
+ const validatedResponse = responseSchema.validate(data);
727
+
728
+ this.resultCode = validatedResponse.resultCode;
729
+ if (this.resultCode === Enums.ResultCode.SUCCESS) {
730
+ Object.assign(this, {
731
+ length: validatedResponse.length,
732
+ resultCode: validatedResponse.resultCode,
733
+ messages: validatedResponse.messages ?? [],
734
+ calculationElapsedTime: validatedResponse.calculationElapsedTime,
735
+ operationId: validatedResponse.operationId,
736
+ });
737
+ } else {
738
+ this.messages.push(...(validatedResponse.messages ?? []));
739
+ }
740
+ } catch (err: any) {
741
+ if ((err as any)?.response) {
742
+ this.handleFailedResponse((err as any).response);
743
+ } else {
744
+ throw err;
745
+ }
746
+ console.error(err);
747
+ }
748
+
749
+ return this.resultCode;
750
+ }
751
+
752
+ toString() {
753
+ const parts = ['* GetPipelineLength'];
754
+
755
+ parts.push(`length: ${String(this.length)}`);
756
+ parts.push(`resultCode: ${String(this.resultCode)}`);
757
+ parts.push('*** messages:');
758
+ parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
759
+ parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
760
+ parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
761
+
762
+ return parts.join('\n');
763
+ }
764
+ }
765
+
766
+ export class GetPipelineLengthCalculationResponse extends CalculationResponseBase {
767
+ length: number;
768
+
769
+ /**
770
+ * GetPipelineLength calculation response class.
771
+ *
772
+ */
773
+ constructor(data: { length: number; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
774
+ super();
775
+ this.length = data.length;
776
+ this.resultCode = data.resultCode;
777
+ this.messages = data.messages;
778
+ this.calculationElapsedTime = data.calculationElapsedTime;
779
+ this.operationId = data.operationId;
780
+ }
781
+
782
+ initialiseFromDictionary(data: { [key: string]: unknown }) {
783
+ if (data.length !== undefined && typeof data.length === 'number') {
784
+ this.length = data.length as number;
785
+ }
786
+ if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
787
+ this.resultCode = data.resultCode as Enums.ResultCode;
788
+ }
789
+ this.messages = this.messages ?? [];
790
+ if (data.messages && Array.isArray(data.messages)) {
791
+ this.messages.push(...data.messages);
792
+ }
793
+ if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
794
+ this.calculationElapsedTime = data.calculationElapsedTime as number;
795
+ }
796
+ if (data.operationId !== undefined && typeof data.operationId === 'string') {
797
+ this.operationId = data.operationId as string;
798
+ }
799
+ }
800
+ }
801
+
802
+ export interface GetPipelineLengthCalculationResponseSchemaData {
803
+ length: number;
804
+ resultCode: Enums.ResultCode;
805
+ messages: string[];
806
+ calculationElapsedTime: number;
807
+ operationId: string;
808
+ }
809
+
810
+ export class GetPipelineLengthCalculationResponseSchema {
811
+ schema: Joi.ObjectSchema;
812
+ propertyTypes: Record<string, string>;
813
+
814
+ /**
815
+ * Schema for the GetPipelineLength calculation response.
816
+ */
817
+ constructor() {
818
+ this.schema = Joi.object({
819
+ length: Joi.number().unsafe(),
820
+ resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
821
+ messages: Joi.array().items(Joi.string()),
822
+ calculationElapsedTime: Joi.number().unsafe(),
823
+ operationId: Joi.string().uuid().allow(null),
824
+ }).unknown(true);
825
+
826
+ this.propertyTypes = {
827
+ length: 'number',
828
+ };
829
+ }
830
+
831
+ validate(data: GetPipelineLengthCalculationResponseSchemaData): GetPipelineLengthCalculationResponse {
832
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
833
+ if (error) {
834
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
835
+ }
836
+ return this.makeCalculationResponse(value);
837
+ }
838
+
839
+ makeCalculationResponse(data: GetPipelineLengthCalculationResponseSchemaData): GetPipelineLengthCalculationResponse {
840
+ return new GetPipelineLengthCalculationResponse(data);
841
+ }
842
+ }
843
+
844
+ export interface LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequestSchemaData {
845
+ material: Entities.Material;
846
+ mass: number;
847
+ pressure: number;
848
+ temperature: number;
849
+ releaseElevation: number;
850
+ }
851
+
852
+ class LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequest extends CalculationRequestBase {
853
+ material: Entities.Material;
854
+ mass: number;
855
+ pressure: number;
856
+ temperature: number;
857
+ releaseElevation: number;
858
+
859
+ /**
860
+ * LoadMassInventoryVesselForCatastrophicRuptureScenario calculation request class.
861
+ *
862
+ */
863
+ constructor(data: { material: Entities.Material; mass: number; pressure: number; temperature: number; releaseElevation: number }) {
864
+ super();
865
+ this.material = data.material;
866
+ this.mass = data.mass;
867
+ this.pressure = data.pressure;
868
+ this.temperature = data.temperature;
869
+ this.releaseElevation = data.releaseElevation;
870
+ }
871
+ }
872
+
873
+ export class LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequestSchema {
874
+ schema: Joi.ObjectSchema;
875
+ propertyTypes: Record<string, string>;
876
+
877
+ /**
878
+ * Schema for the LoadMassInventoryVesselForCatastrophicRuptureScenario calculation request.
879
+ */
880
+ constructor() {
881
+ this.schema = Joi.object({
882
+ material: new EntitySchemas.MaterialSchema().schema,
883
+ mass: Joi.number().unsafe(),
884
+ pressure: Joi.number().unsafe(),
885
+ temperature: Joi.number().unsafe(),
886
+ releaseElevation: Joi.number().unsafe(),
887
+ }).unknown(true);
888
+
889
+ this.propertyTypes = {
890
+ material: 'Entities.Material',
891
+ mass: 'number',
892
+ pressure: 'number',
893
+ temperature: 'number',
894
+ releaseElevation: 'number',
895
+ };
896
+ }
897
+
898
+ validate(data: LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequestSchemaData): LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequest {
899
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
900
+ if (error) {
901
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
902
+ }
903
+ return this.makeCalculationRequest(value);
904
+ }
905
+
906
+ makeCalculationRequest(data: LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequestSchemaData): LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequest {
907
+ return new LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequest(data);
908
+ }
909
+ }
910
+
911
+ export class LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculation extends CalculationBase {
912
+ material: Entities.Material;
913
+ mass: number;
914
+ pressure: number;
915
+ temperature: number;
916
+ releaseElevation: number;
917
+ vessel?: Entities.Vessel;
918
+ volume?: number;
919
+
920
+ /**
921
+ * Sets up a vessel from a mass inventory, pressure, temperature and elevation specifications.
922
+ *
923
+ */
924
+ constructor(data: { material: Entities.Material; mass: number; pressure: number; temperature: number; releaseElevation: number; controller?: AbortController }) {
925
+ super(data.controller);
926
+ this.material = data.material;
927
+ this.mass = data.mass;
928
+ this.pressure = data.pressure;
929
+ this.temperature = data.temperature;
930
+ this.releaseElevation = data.releaseElevation;
931
+ }
932
+
933
+ async run() {
934
+ try {
935
+ const request = new LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequest({
936
+ material: this.material,
937
+ mass: this.mass,
938
+ pressure: this.pressure,
939
+ temperature: this.temperature,
940
+ releaseElevation: this.releaseElevation,
941
+ });
942
+
943
+ const schema = new LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationRequestSchema();
944
+ const validatedRequest = schema.validate(request);
945
+
946
+ const requestJson = JSON.stringify(validatedRequest);
947
+ const url = `${getAnalyticsApiTarget()}utilities/loadmassinventoryvesselforcatastrophicrupturescenario?clientId=${getClientAliasId()}`;
948
+
949
+ this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
950
+
951
+ const { data } = await this.postRequest(url, requestJson);
952
+
953
+ const responseSchema = new LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponseSchema();
954
+ const validatedResponse = responseSchema.validate(data);
955
+
956
+ this.resultCode = validatedResponse.resultCode;
957
+ if (this.resultCode === Enums.ResultCode.SUCCESS) {
958
+ Object.assign(this, {
959
+ vessel: validatedResponse.vessel,
960
+ volume: validatedResponse.volume,
961
+ resultCode: validatedResponse.resultCode,
962
+ messages: validatedResponse.messages ?? [],
963
+ calculationElapsedTime: validatedResponse.calculationElapsedTime,
964
+ operationId: validatedResponse.operationId,
965
+ });
966
+ } else {
967
+ this.messages.push(...(validatedResponse.messages ?? []));
968
+ }
969
+ } catch (err: any) {
970
+ if ((err as any)?.response) {
971
+ this.handleFailedResponse((err as any).response);
972
+ } else {
973
+ throw err;
974
+ }
975
+ console.error(err);
976
+ }
977
+
978
+ return this.resultCode;
979
+ }
980
+
981
+ toString() {
982
+ const parts = ['* LoadMassInventoryVesselForCatastrophicRuptureScenario'];
983
+
984
+ parts.push(`vessel: ${String(this.vessel)}`);
985
+ parts.push(`volume: ${String(this.volume)}`);
986
+ parts.push(`resultCode: ${String(this.resultCode)}`);
987
+ parts.push('*** messages:');
988
+ parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
989
+ parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
990
+ parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
991
+
992
+ return parts.join('\n');
993
+ }
994
+ }
995
+
996
+ export class LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponse extends CalculationResponseBase {
997
+ vessel: Entities.Vessel;
998
+ volume: number;
999
+
1000
+ /**
1001
+ * LoadMassInventoryVesselForCatastrophicRuptureScenario calculation response class.
1002
+ *
1003
+ */
1004
+ constructor(data: { vessel: Entities.Vessel; volume: number; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
1005
+ super();
1006
+ this.vessel = data.vessel;
1007
+ this.volume = data.volume;
1008
+ this.resultCode = data.resultCode;
1009
+ this.messages = data.messages;
1010
+ this.calculationElapsedTime = data.calculationElapsedTime;
1011
+ this.operationId = data.operationId;
1012
+ }
1013
+
1014
+ initialiseFromDictionary(data: { [key: string]: unknown }) {
1015
+ if (data.vessel) {
1016
+ this.vessel = new Entities.Vessel();
1017
+ this.vessel.initialiseFromDictionary(data.vessel as { [key: string]: unknown });
1018
+ }
1019
+ if (data.volume !== undefined && typeof data.volume === 'number') {
1020
+ this.volume = data.volume as number;
1021
+ }
1022
+ if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
1023
+ this.resultCode = data.resultCode as Enums.ResultCode;
1024
+ }
1025
+ this.messages = this.messages ?? [];
1026
+ if (data.messages && Array.isArray(data.messages)) {
1027
+ this.messages.push(...data.messages);
1028
+ }
1029
+ if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
1030
+ this.calculationElapsedTime = data.calculationElapsedTime as number;
1031
+ }
1032
+ if (data.operationId !== undefined && typeof data.operationId === 'string') {
1033
+ this.operationId = data.operationId as string;
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ export interface LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponseSchemaData {
1039
+ vessel: Entities.Vessel;
1040
+ volume: number;
1041
+ resultCode: Enums.ResultCode;
1042
+ messages: string[];
1043
+ calculationElapsedTime: number;
1044
+ operationId: string;
1045
+ }
1046
+
1047
+ export class LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponseSchema {
1048
+ schema: Joi.ObjectSchema;
1049
+ propertyTypes: Record<string, string>;
1050
+
1051
+ /**
1052
+ * Schema for the LoadMassInventoryVesselForCatastrophicRuptureScenario calculation response.
1053
+ */
1054
+ constructor() {
1055
+ this.schema = Joi.object({
1056
+ vessel: new EntitySchemas.VesselSchema().schema,
1057
+ volume: Joi.number().unsafe(),
1058
+ resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
1059
+ messages: Joi.array().items(Joi.string()),
1060
+ calculationElapsedTime: Joi.number().unsafe(),
1061
+ operationId: Joi.string().uuid().allow(null),
1062
+ }).unknown(true);
1063
+
1064
+ this.propertyTypes = {
1065
+ vessel: 'Entities.Vessel',
1066
+ volume: 'number',
1067
+ };
1068
+ }
1069
+
1070
+ validate(data: LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponseSchemaData): LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponse {
1071
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
1072
+ if (error) {
1073
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
1074
+ }
1075
+ return this.makeCalculationResponse(value);
1076
+ }
1077
+
1078
+ makeCalculationResponse(data: LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponseSchemaData): LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponse {
1079
+ return new LoadMassInventoryVesselForCatastrophicRuptureScenarioCalculationResponse(data);
1080
+ }
1081
+ }
1082
+
645
1083
  export interface LoadMassInventoryVesselForLeakScenarioCalculationRequestSchemaData {
646
1084
  material: Entities.Material;
647
1085
  mass: number;
@@ -732,7 +1170,7 @@ export class LoadMassInventoryVesselForLeakScenarioCalculation extends Calculati
732
1170
  volume?: number;
733
1171
 
734
1172
  /**
735
- * Sets up a vessel and a leak scenario from a mass inventory, pressure, temperature and hole size specifications.
1173
+ * Sets up a vessel and a leak scenario from a mass inventory, pressure, temperature and hole size specifications.
736
1174
  *
737
1175
  */
738
1176
  constructor(data: {
@@ -1014,7 +1452,7 @@ export class LoadMassInventoryVesselForLineRuptureScenarioCalculation extends Ca
1014
1452
  volume?: number;
1015
1453
 
1016
1454
  /**
1017
- * Sets up a vessel and a line rupture scenario from a mass inventory, pressure, temperature, pipe diameter and length specifications.
1455
+ * Sets up a vessel and a line rupture scenario from a mass inventory, pressure, temperature pipe diameter and length specifications.
1018
1456
  *
1019
1457
  */
1020
1458
  constructor(data: {
@@ -1323,7 +1761,7 @@ export class LoadMassInventoryVesselForReliefValveScenarioCalculation extends Ca
1323
1761
  volume?: number;
1324
1762
 
1325
1763
  /**
1326
- * Sets up a vessel and a relief valve scenario from a mass inventory, pressure, temperature, pipe diameter, length and constriction size specifications.
1764
+ * Sets up a vessel and a relief valve scenario from a mass inventory, pressure, temperature pipe diameter, length and constriction size specifications.
1327
1765
  *
1328
1766
  */
1329
1767
  constructor(data: {
@@ -1581,7 +2019,7 @@ export class ReliefValveMinTemperatureCalculation extends CalculationBase {
1581
2019
  minTemperature?: number;
1582
2020
 
1583
2021
  /**
1584
- * The Relief Valve scenario does not allow fluid conditions to be liquid. As such, his method calculates the lower limit for the input temperature to ensure vapour or two-phase fluid state.
2022
+ * The Relief Valve scenario does not allow fluid conditions to be liquid. As such, this method calculates the lower limit for the input temperature to ensure vapour or two-phase fluid state.
1585
2023
  *
1586
2024
  */
1587
2025
  constructor(data: { material: Entities.Material; pressure: number; controller?: AbortController }) {
@@ -1778,7 +2216,7 @@ export class SetMixingLayerHeightCalculation extends CalculationBase {
1778
2216
  updatedWeather?: Entities.Weather;
1779
2217
 
1780
2218
  /**
1781
- * Updates the mixing layer height in a weather according to the stability class,.
2219
+ * Updates the mixing layer height in a weather according to the stability class.
1782
2220
  *
1783
2221
  */
1784
2222
  constructor(data: { weather: Entities.Weather; controller?: AbortController }) {
@@ -1796,7 +2234,7 @@ export class SetMixingLayerHeightCalculation extends CalculationBase {
1796
2234
  const validatedRequest = schema.validate(request);
1797
2235
 
1798
2236
  const requestJson = JSON.stringify(validatedRequest);
1799
- const url = `${getAnalyticsApiTarget()}utilities/SetMixingLayerHeight?clientId=${getClientAliasId()}`;
2237
+ const url = `${getAnalyticsApiTarget()}utilities/setmixinglayerheight?clientId=${getClientAliasId()}`;
1800
2238
 
1801
2239
  this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
1802
2240
 
@@ -2588,6 +3026,218 @@ export class SetPhaseToReleaseForReliefValveScenarioCalculationResponseSchema {
2588
3026
  }
2589
3027
  }
2590
3028
 
3029
+ export interface SetPipelineLengthCalculationRequestSchemaData {
3030
+ length: number;
3031
+ height: number;
3032
+ pipe: Entities.Pipe;
3033
+ }
3034
+
3035
+ class SetPipelineLengthCalculationRequest extends CalculationRequestBase {
3036
+ length: number;
3037
+ height: number;
3038
+ pipe: Entities.Pipe;
3039
+
3040
+ /**
3041
+ * SetPipelineLength calculation request class.
3042
+ *
3043
+ */
3044
+ constructor(data: { length: number; height: number; pipe: Entities.Pipe }) {
3045
+ super();
3046
+ this.length = data.length;
3047
+ this.height = data.height;
3048
+ this.pipe = data.pipe;
3049
+ }
3050
+ }
3051
+
3052
+ export class SetPipelineLengthCalculationRequestSchema {
3053
+ schema: Joi.ObjectSchema;
3054
+ propertyTypes: Record<string, string>;
3055
+
3056
+ /**
3057
+ * Schema for the SetPipelineLength calculation request.
3058
+ */
3059
+ constructor() {
3060
+ this.schema = Joi.object({
3061
+ length: Joi.number().unsafe(),
3062
+ height: Joi.number().unsafe(),
3063
+ pipe: new EntitySchemas.PipeSchema().schema,
3064
+ }).unknown(true);
3065
+
3066
+ this.propertyTypes = {
3067
+ length: 'number',
3068
+ height: 'number',
3069
+ pipe: 'Entities.Pipe',
3070
+ };
3071
+ }
3072
+
3073
+ validate(data: SetPipelineLengthCalculationRequestSchemaData): SetPipelineLengthCalculationRequest {
3074
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
3075
+ if (error) {
3076
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
3077
+ }
3078
+ return this.makeCalculationRequest(value);
3079
+ }
3080
+
3081
+ makeCalculationRequest(data: SetPipelineLengthCalculationRequestSchemaData): SetPipelineLengthCalculationRequest {
3082
+ return new SetPipelineLengthCalculationRequest(data);
3083
+ }
3084
+ }
3085
+
3086
+ export class SetPipelineLengthCalculation extends CalculationBase {
3087
+ length: number;
3088
+ height: number;
3089
+ pipe: Entities.Pipe;
3090
+ updatedPipe?: Entities.Pipe;
3091
+
3092
+ /**
3093
+ * When the user only wants to specify the length of the pipeline and not the coordinates, this method can be used to set the pipe node coordinates based on the input length and elevation. The method assumes a straight horizontal pipeline with the first node at the origin and height and the second node at (length, 0, height).
3094
+ *
3095
+ */
3096
+ constructor(data: { length: number; height: number; pipe: Entities.Pipe; controller?: AbortController }) {
3097
+ super(data.controller);
3098
+ this.length = data.length;
3099
+ this.height = data.height;
3100
+ this.pipe = data.pipe;
3101
+ }
3102
+
3103
+ async run() {
3104
+ try {
3105
+ const request = new SetPipelineLengthCalculationRequest({
3106
+ length: this.length,
3107
+ height: this.height,
3108
+ pipe: this.pipe,
3109
+ });
3110
+
3111
+ const schema = new SetPipelineLengthCalculationRequestSchema();
3112
+ const validatedRequest = schema.validate(request);
3113
+
3114
+ const requestJson = JSON.stringify(validatedRequest);
3115
+ const url = `${getAnalyticsApiTarget()}utilities/setpipelinelength?clientId=${getClientAliasId()}`;
3116
+
3117
+ this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
3118
+
3119
+ const { data } = await this.postRequest(url, requestJson);
3120
+
3121
+ const responseSchema = new SetPipelineLengthCalculationResponseSchema();
3122
+ const validatedResponse = responseSchema.validate(data);
3123
+
3124
+ this.resultCode = validatedResponse.resultCode;
3125
+ if (this.resultCode === Enums.ResultCode.SUCCESS) {
3126
+ Object.assign(this, {
3127
+ updatedPipe: validatedResponse.updatedPipe,
3128
+ resultCode: validatedResponse.resultCode,
3129
+ messages: validatedResponse.messages ?? [],
3130
+ calculationElapsedTime: validatedResponse.calculationElapsedTime,
3131
+ operationId: validatedResponse.operationId,
3132
+ });
3133
+ } else {
3134
+ this.messages.push(...(validatedResponse.messages ?? []));
3135
+ }
3136
+ } catch (err: any) {
3137
+ if ((err as any)?.response) {
3138
+ this.handleFailedResponse((err as any).response);
3139
+ } else {
3140
+ throw err;
3141
+ }
3142
+ console.error(err);
3143
+ }
3144
+
3145
+ return this.resultCode;
3146
+ }
3147
+
3148
+ toString() {
3149
+ const parts = ['* SetPipelineLength'];
3150
+
3151
+ parts.push(`updatedPipe: ${String(this.updatedPipe)}`);
3152
+ parts.push(`resultCode: ${String(this.resultCode)}`);
3153
+ parts.push('*** messages:');
3154
+ parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
3155
+ parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
3156
+ parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
3157
+
3158
+ return parts.join('\n');
3159
+ }
3160
+ }
3161
+
3162
+ export class SetPipelineLengthCalculationResponse extends CalculationResponseBase {
3163
+ updatedPipe: Entities.Pipe;
3164
+
3165
+ /**
3166
+ * SetPipelineLength calculation response class.
3167
+ *
3168
+ */
3169
+ constructor(data: { updatedPipe: Entities.Pipe; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
3170
+ super();
3171
+ this.updatedPipe = data.updatedPipe;
3172
+ this.resultCode = data.resultCode;
3173
+ this.messages = data.messages;
3174
+ this.calculationElapsedTime = data.calculationElapsedTime;
3175
+ this.operationId = data.operationId;
3176
+ }
3177
+
3178
+ initialiseFromDictionary(data: { [key: string]: unknown }) {
3179
+ if (data.updatedPipe) {
3180
+ this.updatedPipe = new Entities.Pipe();
3181
+ this.updatedPipe.initialiseFromDictionary(data.updatedPipe as { [key: string]: unknown });
3182
+ }
3183
+ if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
3184
+ this.resultCode = data.resultCode as Enums.ResultCode;
3185
+ }
3186
+ this.messages = this.messages ?? [];
3187
+ if (data.messages && Array.isArray(data.messages)) {
3188
+ this.messages.push(...data.messages);
3189
+ }
3190
+ if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
3191
+ this.calculationElapsedTime = data.calculationElapsedTime as number;
3192
+ }
3193
+ if (data.operationId !== undefined && typeof data.operationId === 'string') {
3194
+ this.operationId = data.operationId as string;
3195
+ }
3196
+ }
3197
+ }
3198
+
3199
+ export interface SetPipelineLengthCalculationResponseSchemaData {
3200
+ updatedPipe: Entities.Pipe;
3201
+ resultCode: Enums.ResultCode;
3202
+ messages: string[];
3203
+ calculationElapsedTime: number;
3204
+ operationId: string;
3205
+ }
3206
+
3207
+ export class SetPipelineLengthCalculationResponseSchema {
3208
+ schema: Joi.ObjectSchema;
3209
+ propertyTypes: Record<string, string>;
3210
+
3211
+ /**
3212
+ * Schema for the SetPipelineLength calculation response.
3213
+ */
3214
+ constructor() {
3215
+ this.schema = Joi.object({
3216
+ updatedPipe: new EntitySchemas.PipeSchema().schema,
3217
+ resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
3218
+ messages: Joi.array().items(Joi.string()),
3219
+ calculationElapsedTime: Joi.number().unsafe(),
3220
+ operationId: Joi.string().uuid().allow(null),
3221
+ }).unknown(true);
3222
+
3223
+ this.propertyTypes = {
3224
+ updatedPipe: 'Entities.Pipe',
3225
+ };
3226
+ }
3227
+
3228
+ validate(data: SetPipelineLengthCalculationResponseSchemaData): SetPipelineLengthCalculationResponse {
3229
+ const { error, value } = this.schema.validate(data, { abortEarly: false });
3230
+ if (error) {
3231
+ throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
3232
+ }
3233
+ return this.makeCalculationResponse(value);
3234
+ }
3235
+
3236
+ makeCalculationResponse(data: SetPipelineLengthCalculationResponseSchemaData): SetPipelineLengthCalculationResponse {
3237
+ return new SetPipelineLengthCalculationResponse(data);
3238
+ }
3239
+ }
3240
+
2591
3241
  export interface SetReleaseElevationForScenarioCalculationRequestSchemaData {
2592
3242
  releaseElevation: number;
2593
3243
  releaseHeightFraction: number;
@@ -2674,7 +3324,7 @@ export class SetReleaseElevationForScenarioCalculation extends CalculationBase {
2674
3324
  const validatedRequest = schema.validate(request);
2675
3325
 
2676
3326
  const requestJson = JSON.stringify(validatedRequest);
2677
- const url = `${getAnalyticsApiTarget()}utilities/SetReleaseElevationForScenario?clientId=${getClientAliasId()}`;
3327
+ const url = `${getAnalyticsApiTarget()}setreleaseelevationforscenario?clientId=${getClientAliasId()}`;
2678
3328
 
2679
3329
  this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
2680
3330