@dnv-plant/typescriptpws 1.0.92 → 1.0.93-alpha.2032673

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 CHANGED
@@ -6,8 +6,8 @@
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.92
10
- * Date/time: 09 Sept 2025 15:59:44
9
+ * Version: 1.0.93
10
+ * Date/time: 11 Sept 2025 11:24:42
11
11
  * Template: templates/typescriptpws/index.razor.
12
12
  ***********************************************************************/
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnv-plant/typescriptpws",
3
- "version": "1.0.92",
3
+ "version": "1.0.93-alpha.2032673",
4
4
  "description": "Integrate Phast models with our versatile APIs for enhanced customization and efficiency.",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -21,4 +21,4 @@
21
21
  "@vitest/ui": "^3.2.4",
22
22
  "vitest": "^3.2.4"
23
23
  }
24
- }
24
+ }
@@ -6,156 +6,19 @@
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.92
10
- * Date/time: 09 Sept 2025 15:59:43
9
+ * Version: 1.0.93
10
+ * Date/time: 11 Sept 2025 11:24:42
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
12
  ***********************************************************************/
13
13
 
14
14
  import * as Enums from "../enums";
15
15
  import * as Entities from "../entities";
16
16
  import * as EntitySchemas from "../entity-schemas";
17
- import { getAnalyticsApiTarget, getClientAliasId, postRequest } from "../utilities";
17
+ import { getAnalyticsApiTarget, getClientAliasId } from "../utilities";
18
+ import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from "./calculationBase"
18
19
 
19
20
  import Joi from "joi";
20
- import { AxiosResponse } from "axios";
21
21
 
22
-
23
- class CalculationRequestBase {
24
- /**
25
- * Calculation request base class.
26
- */
27
- constructor() {
28
- // Base class initialization code
29
- }
30
- }
31
-
32
- class CalculationBase {
33
- resultCode?: Enums.ResultCode = Enums.ResultCode.SUCCESS;
34
- messages: string[] = [];
35
- calculationElapsedTime?: number = 0.0;
36
- operationId?: string = "";
37
- controller?: AbortController;
38
-
39
- constructor(controller?: AbortController) {
40
- this.controller = controller;
41
- }
42
-
43
- /**
44
- * Post JSON to URL and time the call
45
- */
46
- async postRequest(url: string, data: string): Promise<AxiosResponse> {
47
- return postRequest(url, data, this.controller);
48
- }
49
-
50
- /**
51
- * Utility method to print the messages returned by the calculation.
52
- */
53
- printMessages(): void {
54
- if (this.messages && this.messages.length > 0) {
55
- this.messages.forEach((message) => console.log(message));
56
- } else {
57
- console.log("No messages");
58
- }
59
- }
60
-
61
- /**
62
- * Utility method to handle a failed response.
63
- */
64
- handleFailedResponse(response: AxiosResponse): void {
65
- try {
66
- const validatedFailedResponse = new CalculationFailedResponseSchema().validate(response.data);
67
-
68
- this.resultCode = validatedFailedResponse.resultCode;
69
- this.messages.push(...(validatedFailedResponse.messages ?? []));
70
- this.calculationElapsedTime = validatedFailedResponse.calculationElapsedTime;
71
- this.operationId = validatedFailedResponse.operationId;
72
- } catch (error) {
73
- if (error instanceof Error) {
74
- this.messages.push(`Failed to parse response: ${error.message}`);
75
- } else {
76
- this.messages.push("An unknown error occurred during response parsing.");
77
- }
78
- console.error("Failed to parse response:", error);
79
- } finally {
80
- this.messages.push(`${response.statusText} (Status code: ${response.status})`);
81
- }
82
- }
83
- }
84
-
85
- class CalculationResponseBase {
86
- resultCode?: Enums.ResultCode;
87
- messages?: string[];
88
- calculationElapsedTime?: number;
89
- operationId?: string;
90
-
91
- /**
92
- * Calculation response base class.
93
- */
94
- constructor(
95
- resultCode?: Enums.ResultCode,
96
- messages?: string[],
97
- calculationElapsedTime?: number,
98
- operationId?: string
99
- ) {
100
- this.resultCode = resultCode;
101
- this.messages = messages;
102
- this.calculationElapsedTime = calculationElapsedTime;
103
- this.operationId = operationId;
104
- }
105
- }
106
-
107
- class CalculationFailedResponse extends CalculationResponseBase {
108
- /**
109
- * Calculation failed response class.
110
- */
111
- constructor(
112
- resultCode?: Enums.ResultCode,
113
- messages: string[] = [],
114
- calculationElapsedTime: number = 0,
115
- operationId: string = ""
116
- ) {
117
- super(resultCode, messages, calculationElapsedTime, operationId);
118
- }
119
- }
120
-
121
- class CalculationFailedResponseSchema {
122
- schema: Joi.ObjectSchema;
123
-
124
- /**
125
- * Calculation failed response schema.
126
- */
127
- constructor() {
128
- this.schema = Joi.object({
129
- resultCode: Joi.string()
130
- .valid(...Object.values(Enums.ResultCode))
131
- .required(),
132
- messages: Joi.array().items(Joi.string()).required(),
133
- calculationElapsedTime: Joi.number().optional(),
134
- operationId: Joi.string().required(),
135
- }).unknown(true);
136
- }
137
-
138
- validate(data: {
139
- resultCode: Enums.ResultCode;
140
- messages: string[];
141
- calculationElapsedTime: number;
142
- operationId: string;
143
- }) {
144
- const { error, value } = this.schema.validate(data);
145
- if (error) throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
146
- return this.makeCalculationFailedResponse(value);
147
- }
148
-
149
- makeCalculationFailedResponse(data: {
150
- resultCode: Enums.ResultCode;
151
- messages: string[];
152
- calculationElapsedTime: number;
153
- operationId: string;
154
- }) {
155
- return new CalculationFailedResponse(data.resultCode, data.messages, data.calculationElapsedTime, data.operationId);
156
- }
157
- }
158
-
159
22
  export interface MixtureConstantPropertiesCalculationRequestSchemaData {
160
23
  material: Entities.Material;
161
24
  }
@@ -0,0 +1,166 @@
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.93
10
+ * Date/time: 11 Sept 2025 11:24:41
11
+ * Template: templates/typescriptpws/calculationbase.razor.
12
+ ***********************************************************************/
13
+
14
+ import { ResultCode } from "../enums";
15
+ import { postRequest } from "../utilities";
16
+ import Joi from "joi";
17
+ import { AxiosResponse } from "axios";
18
+
19
+ export class CalculationRequestBase {
20
+ /**
21
+ * Calculation request base class.
22
+ */
23
+ constructor() {
24
+ // Base class initialization code
25
+ }
26
+ }
27
+
28
+ export class CalculationBase {
29
+ resultCode?: ResultCode = ResultCode.SUCCESS;
30
+ messages: string[] = [];
31
+ calculationElapsedTime?: number = 0.0;
32
+ operationId?: string = "";
33
+ controller?: AbortController;
34
+
35
+ constructor(controller?: AbortController) {
36
+ this.controller = controller;
37
+ }
38
+
39
+ /**
40
+ * Post JSON to URL and time the call
41
+ */
42
+ async postRequest(url: string, data: string): Promise<AxiosResponse> {
43
+ return postRequest(url, data, this.controller);
44
+ }
45
+
46
+ /**
47
+ * Utility method to print the messages returned by the calculation.
48
+ */
49
+ printMessages(): void {
50
+ if (this.messages && this.messages.length > 0) {
51
+ this.messages.forEach((message) => console.log(message));
52
+ } else {
53
+ console.log("No messages");
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Utility method to handle a failed response.
59
+ */
60
+ handleFailedResponse(response: AxiosResponse): void {
61
+ try {
62
+ const validatedFailedResponse =
63
+ new CalculationFailedResponseSchema().validate(response.data);
64
+
65
+ this.resultCode = validatedFailedResponse.resultCode;
66
+ this.messages.push(...(validatedFailedResponse.messages ?? []));
67
+ this.calculationElapsedTime =
68
+ validatedFailedResponse.calculationElapsedTime;
69
+ this.operationId = validatedFailedResponse.operationId;
70
+ } catch (error) {
71
+ if (error instanceof Error) {
72
+ this.messages.push(`Failed to parse response: ${error.message}`);
73
+ } else {
74
+ this.messages.push(
75
+ "An unknown error occurred during response parsing."
76
+ );
77
+ }
78
+ } finally {
79
+ this.messages.push(
80
+ `${response.statusText} (Status code: ${response.status})`
81
+ );
82
+ }
83
+ }
84
+ }
85
+
86
+ export class CalculationResponseBase {
87
+ resultCode?: ResultCode;
88
+ messages?: string[];
89
+ calculationElapsedTime?: number;
90
+ operationId?: string;
91
+
92
+ /**
93
+ * Calculation response base class.
94
+ */
95
+ constructor(
96
+ resultCode?: ResultCode,
97
+ messages?: string[],
98
+ calculationElapsedTime?: number,
99
+ operationId?: string
100
+ ) {
101
+ this.resultCode = resultCode;
102
+ this.messages = messages;
103
+ this.calculationElapsedTime = calculationElapsedTime;
104
+ this.operationId = operationId;
105
+ }
106
+ }
107
+
108
+ class CalculationFailedResponse extends CalculationResponseBase {
109
+ /**
110
+ * Calculation failed response class.
111
+ */
112
+ constructor(
113
+ resultCode?: ResultCode,
114
+ messages: string[] = [],
115
+ calculationElapsedTime: number = 0,
116
+ operationId: string = ""
117
+ ) {
118
+ super(resultCode, messages, calculationElapsedTime, operationId);
119
+ }
120
+ }
121
+
122
+ class CalculationFailedResponseSchema {
123
+ schema: Joi.ObjectSchema;
124
+
125
+ /**
126
+ * Calculation failed response schema.
127
+ */
128
+ constructor() {
129
+ this.schema = Joi.object({
130
+ resultCode: Joi.string()
131
+ .valid(...Object.values(ResultCode))
132
+ .required(),
133
+ messages: Joi.array().items(Joi.string()).required(),
134
+ calculationElapsedTime: Joi.number().optional(),
135
+ operationId: Joi.string().required(),
136
+ }).unknown(true);
137
+ }
138
+
139
+ validate(data: {
140
+ resultCode: ResultCode;
141
+ messages: string[];
142
+ calculationElapsedTime: number;
143
+ operationId: string;
144
+ }) {
145
+ const { error, value } = this.schema.validate(data);
146
+ if (error)
147
+ throw new Error(
148
+ `Validation error: ${error.details.map((x) => x.message).join(", ")}`
149
+ );
150
+ return this.makeCalculationFailedResponse(value);
151
+ }
152
+
153
+ makeCalculationFailedResponse(data: {
154
+ resultCode: ResultCode;
155
+ messages: string[];
156
+ calculationElapsedTime: number;
157
+ operationId: string;
158
+ }) {
159
+ return new CalculationFailedResponse(
160
+ data.resultCode,
161
+ data.messages,
162
+ data.calculationElapsedTime,
163
+ data.operationId
164
+ );
165
+ }
166
+ }
@@ -6,156 +6,19 @@
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.92
10
- * Date/time: 09 Sept 2025 15:59:43
9
+ * Version: 1.0.93
10
+ * Date/time: 11 Sept 2025 11:24:42
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
12
  ***********************************************************************/
13
13
 
14
14
  import * as Enums from "../enums";
15
15
  import * as Entities from "../entities";
16
16
  import * as EntitySchemas from "../entity-schemas";
17
- import { getAnalyticsApiTarget, getClientAliasId, postRequest } from "../utilities";
17
+ import { getAnalyticsApiTarget, getClientAliasId } from "../utilities";
18
+ import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from "./calculationBase"
18
19
 
19
20
  import Joi from "joi";
20
- import { AxiosResponse } from "axios";
21
21
 
22
-
23
- class CalculationRequestBase {
24
- /**
25
- * Calculation request base class.
26
- */
27
- constructor() {
28
- // Base class initialization code
29
- }
30
- }
31
-
32
- class CalculationBase {
33
- resultCode?: Enums.ResultCode = Enums.ResultCode.SUCCESS;
34
- messages: string[] = [];
35
- calculationElapsedTime?: number = 0.0;
36
- operationId?: string = "";
37
- controller?: AbortController;
38
-
39
- constructor(controller?: AbortController) {
40
- this.controller = controller;
41
- }
42
-
43
- /**
44
- * Post JSON to URL and time the call
45
- */
46
- async postRequest(url: string, data: string): Promise<AxiosResponse> {
47
- return postRequest(url, data, this.controller);
48
- }
49
-
50
- /**
51
- * Utility method to print the messages returned by the calculation.
52
- */
53
- printMessages(): void {
54
- if (this.messages && this.messages.length > 0) {
55
- this.messages.forEach((message) => console.log(message));
56
- } else {
57
- console.log("No messages");
58
- }
59
- }
60
-
61
- /**
62
- * Utility method to handle a failed response.
63
- */
64
- handleFailedResponse(response: AxiosResponse): void {
65
- try {
66
- const validatedFailedResponse = new CalculationFailedResponseSchema().validate(response.data);
67
-
68
- this.resultCode = validatedFailedResponse.resultCode;
69
- this.messages.push(...(validatedFailedResponse.messages ?? []));
70
- this.calculationElapsedTime = validatedFailedResponse.calculationElapsedTime;
71
- this.operationId = validatedFailedResponse.operationId;
72
- } catch (error) {
73
- if (error instanceof Error) {
74
- this.messages.push(`Failed to parse response: ${error.message}`);
75
- } else {
76
- this.messages.push("An unknown error occurred during response parsing.");
77
- }
78
- console.error("Failed to parse response:", error);
79
- } finally {
80
- this.messages.push(`${response.statusText} (Status code: ${response.status})`);
81
- }
82
- }
83
- }
84
-
85
- class CalculationResponseBase {
86
- resultCode?: Enums.ResultCode;
87
- messages?: string[];
88
- calculationElapsedTime?: number;
89
- operationId?: string;
90
-
91
- /**
92
- * Calculation response base class.
93
- */
94
- constructor(
95
- resultCode?: Enums.ResultCode,
96
- messages?: string[],
97
- calculationElapsedTime?: number,
98
- operationId?: string
99
- ) {
100
- this.resultCode = resultCode;
101
- this.messages = messages;
102
- this.calculationElapsedTime = calculationElapsedTime;
103
- this.operationId = operationId;
104
- }
105
- }
106
-
107
- class CalculationFailedResponse extends CalculationResponseBase {
108
- /**
109
- * Calculation failed response class.
110
- */
111
- constructor(
112
- resultCode?: Enums.ResultCode,
113
- messages: string[] = [],
114
- calculationElapsedTime: number = 0,
115
- operationId: string = ""
116
- ) {
117
- super(resultCode, messages, calculationElapsedTime, operationId);
118
- }
119
- }
120
-
121
- class CalculationFailedResponseSchema {
122
- schema: Joi.ObjectSchema;
123
-
124
- /**
125
- * Calculation failed response schema.
126
- */
127
- constructor() {
128
- this.schema = Joi.object({
129
- resultCode: Joi.string()
130
- .valid(...Object.values(Enums.ResultCode))
131
- .required(),
132
- messages: Joi.array().items(Joi.string()).required(),
133
- calculationElapsedTime: Joi.number().optional(),
134
- operationId: Joi.string().required(),
135
- }).unknown(true);
136
- }
137
-
138
- validate(data: {
139
- resultCode: Enums.ResultCode;
140
- messages: string[];
141
- calculationElapsedTime: number;
142
- operationId: string;
143
- }) {
144
- const { error, value } = this.schema.validate(data);
145
- if (error) throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
146
- return this.makeCalculationFailedResponse(value);
147
- }
148
-
149
- makeCalculationFailedResponse(data: {
150
- resultCode: Enums.ResultCode;
151
- messages: string[];
152
- calculationElapsedTime: number;
153
- operationId: string;
154
- }) {
155
- return new CalculationFailedResponse(data.resultCode, data.messages, data.calculationElapsedTime, data.operationId);
156
- }
157
- }
158
-
159
22
  export interface BESSConfidenceIntervalEnergyScalingCalculationRequestSchemaData {
160
23
  chemistry: number;
161
24
  confidenceInterval: number;
@@ -6,156 +6,19 @@
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.92
10
- * Date/time: 09 Sept 2025 15:59:43
9
+ * Version: 1.0.93
10
+ * Date/time: 11 Sept 2025 11:24:42
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
12
  ***********************************************************************/
13
13
 
14
14
  import * as Enums from "../enums";
15
15
  import * as Entities from "../entities";
16
16
  import * as EntitySchemas from "../entity-schemas";
17
- import { getAnalyticsApiTarget, getClientAliasId, postRequest } from "../utilities";
17
+ import { getAnalyticsApiTarget, getClientAliasId } from "../utilities";
18
+ import { CalculationRequestBase, CalculationBase, CalculationResponseBase } from "./calculationBase"
18
19
 
19
20
  import Joi from "joi";
20
- import { AxiosResponse } from "axios";
21
21
 
22
-
23
- class CalculationRequestBase {
24
- /**
25
- * Calculation request base class.
26
- */
27
- constructor() {
28
- // Base class initialization code
29
- }
30
- }
31
-
32
- class CalculationBase {
33
- resultCode?: Enums.ResultCode = Enums.ResultCode.SUCCESS;
34
- messages: string[] = [];
35
- calculationElapsedTime?: number = 0.0;
36
- operationId?: string = "";
37
- controller?: AbortController;
38
-
39
- constructor(controller?: AbortController) {
40
- this.controller = controller;
41
- }
42
-
43
- /**
44
- * Post JSON to URL and time the call
45
- */
46
- async postRequest(url: string, data: string): Promise<AxiosResponse> {
47
- return postRequest(url, data, this.controller);
48
- }
49
-
50
- /**
51
- * Utility method to print the messages returned by the calculation.
52
- */
53
- printMessages(): void {
54
- if (this.messages && this.messages.length > 0) {
55
- this.messages.forEach((message) => console.log(message));
56
- } else {
57
- console.log("No messages");
58
- }
59
- }
60
-
61
- /**
62
- * Utility method to handle a failed response.
63
- */
64
- handleFailedResponse(response: AxiosResponse): void {
65
- try {
66
- const validatedFailedResponse = new CalculationFailedResponseSchema().validate(response.data);
67
-
68
- this.resultCode = validatedFailedResponse.resultCode;
69
- this.messages.push(...(validatedFailedResponse.messages ?? []));
70
- this.calculationElapsedTime = validatedFailedResponse.calculationElapsedTime;
71
- this.operationId = validatedFailedResponse.operationId;
72
- } catch (error) {
73
- if (error instanceof Error) {
74
- this.messages.push(`Failed to parse response: ${error.message}`);
75
- } else {
76
- this.messages.push("An unknown error occurred during response parsing.");
77
- }
78
- console.error("Failed to parse response:", error);
79
- } finally {
80
- this.messages.push(`${response.statusText} (Status code: ${response.status})`);
81
- }
82
- }
83
- }
84
-
85
- class CalculationResponseBase {
86
- resultCode?: Enums.ResultCode;
87
- messages?: string[];
88
- calculationElapsedTime?: number;
89
- operationId?: string;
90
-
91
- /**
92
- * Calculation response base class.
93
- */
94
- constructor(
95
- resultCode?: Enums.ResultCode,
96
- messages?: string[],
97
- calculationElapsedTime?: number,
98
- operationId?: string
99
- ) {
100
- this.resultCode = resultCode;
101
- this.messages = messages;
102
- this.calculationElapsedTime = calculationElapsedTime;
103
- this.operationId = operationId;
104
- }
105
- }
106
-
107
- class CalculationFailedResponse extends CalculationResponseBase {
108
- /**
109
- * Calculation failed response class.
110
- */
111
- constructor(
112
- resultCode?: Enums.ResultCode,
113
- messages: string[] = [],
114
- calculationElapsedTime: number = 0,
115
- operationId: string = ""
116
- ) {
117
- super(resultCode, messages, calculationElapsedTime, operationId);
118
- }
119
- }
120
-
121
- class CalculationFailedResponseSchema {
122
- schema: Joi.ObjectSchema;
123
-
124
- /**
125
- * Calculation failed response schema.
126
- */
127
- constructor() {
128
- this.schema = Joi.object({
129
- resultCode: Joi.string()
130
- .valid(...Object.values(Enums.ResultCode))
131
- .required(),
132
- messages: Joi.array().items(Joi.string()).required(),
133
- calculationElapsedTime: Joi.number().optional(),
134
- operationId: Joi.string().required(),
135
- }).unknown(true);
136
- }
137
-
138
- validate(data: {
139
- resultCode: Enums.ResultCode;
140
- messages: string[];
141
- calculationElapsedTime: number;
142
- operationId: string;
143
- }) {
144
- const { error, value } = this.schema.validate(data);
145
- if (error) throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
146
- return this.makeCalculationFailedResponse(value);
147
- }
148
-
149
- makeCalculationFailedResponse(data: {
150
- resultCode: Enums.ResultCode;
151
- messages: string[];
152
- calculationElapsedTime: number;
153
- operationId: string;
154
- }) {
155
- return new CalculationFailedResponse(data.resultCode, data.messages, data.calculationElapsedTime, data.operationId);
156
- }
157
- }
158
-
159
22
  export interface DispersionCalculationRequestSchemaData {
160
23
  material: Entities.Material;
161
24
  substrate: Entities.Substrate;