@dnv-plant/typescriptpws 1.0.95 → 1.0.96

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/src/enums.ts CHANGED
@@ -1,15 +1,15 @@
1
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.95
10
- * Date/time: 19 Jan 2026 12:11:52
11
- * Template: templates/typescriptpws/enums.razor.
12
- ***********************************************************************/
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.96
10
+ * Date/time: 4 Apr 2026 08:17:52
11
+ * Template: templates/typescriptpws/enums.razor.
12
+ ***********************************************************************/
13
13
 
14
14
  /**
15
15
  * The Pasquill atmospheric stability classes, a common method for categorizing the amount of atmospheric turbulence present.
package/src/materials.ts CHANGED
@@ -1,27 +1,21 @@
1
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.95
10
- * Date/time: 19 Jan 2026 12:11:52
11
- * Template: templates/typescriptpws/materials.razor.
12
- ***********************************************************************/
13
-
14
- import {
15
- getRequest,
16
- postRequest,
17
- putRequest,
18
- getMaterialsApiTarget,
19
- getClientAliasId,
20
- } from "./utilities";
21
- import { MaterialSchema, MaterialComponentDataSchema } from "./entity-schemas";
22
- import { Material, MaterialComponentData } from "./entities";
23
-
24
- import Joi from "joi";
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.96
10
+ * Date/time: 4 Apr 2026 08:17:52
11
+ * Template: templates/typescriptpws/materials.razor.
12
+ ***********************************************************************/
13
+
14
+ import { getRequest, postRequest, putRequest, getMaterialsApiTarget, getClientAliasId } from './utilities';
15
+ import { MaterialSchema, MaterialComponentDataSchema } from './entity-schemas';
16
+ import { Material, MaterialComponentData } from './entities';
17
+
18
+ import Joi from 'joi';
25
19
 
26
20
  interface SchemaClass {
27
21
  schema: Joi.ObjectSchema; // The class must have a `schema` property of type Joi.ObjectSchema
@@ -34,7 +28,10 @@ export class MaterialInfo {
34
28
  * @param {string} id - A unique identifier of the material.
35
29
  * @param {string} name - The name of the material.
36
30
  */
37
- constructor(readonly id: string, readonly name: string) {}
31
+ constructor(
32
+ readonly id: string,
33
+ readonly name: string,
34
+ ) {}
38
35
  }
39
36
 
40
37
  export class MaterialCasIdInfo {
@@ -48,7 +45,7 @@ export class MaterialCasIdInfo {
48
45
  constructor(
49
46
  readonly id: string,
50
47
  readonly name: string,
51
- readonly casId: number
48
+ readonly casId: number,
52
49
  ) {}
53
50
  }
54
51
 
@@ -57,7 +54,7 @@ export class MaterialInfoSchema {
57
54
 
58
55
  constructor() {
59
56
  this.schema = Joi.object({
60
- id: Joi.string().guid({ version: "uuidv4" }).required(),
57
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
61
58
  displayName: Joi.string().required(),
62
59
  }).unknown(true);
63
60
  }
@@ -82,7 +79,7 @@ export class MaterialCasIdInfoSchema {
82
79
 
83
80
  constructor() {
84
81
  this.schema = Joi.object({
85
- id: Joi.string().guid({ version: "uuidv4" }).required(),
82
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
86
83
  name: Joi.string().required(),
87
84
  casId: Joi.number().required(),
88
85
  }).unknown(true);
@@ -94,11 +91,7 @@ export class MaterialCasIdInfoSchema {
94
91
  * @returns A MaterialCasIdInfo instance.
95
92
  * @throws Error if validation fails.
96
93
  */
97
- makeMaterialInfo(data: {
98
- id: string;
99
- name: string;
100
- casId: number;
101
- }): MaterialCasIdInfo {
94
+ makeMaterialInfo(data: { id: string; name: string; casId: number }): MaterialCasIdInfo {
102
95
  const { error, value } = this.schema.validate(data);
103
96
  if (error) {
104
97
  throw new Error(`Validation error: ${error.details[0].message}`);
@@ -118,7 +111,7 @@ export class MaterialEntityDescriptor {
118
111
  constructor(
119
112
  readonly id: string,
120
113
  readonly name: string,
121
- readonly casId: number
114
+ readonly casId: number,
122
115
  ) {}
123
116
  }
124
117
 
@@ -127,7 +120,7 @@ export class MaterialEntityDescriptorSchema {
127
120
 
128
121
  constructor() {
129
122
  this.schema = Joi.object({
130
- id: Joi.string().guid({ version: "uuidv4" }).required(),
123
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
131
124
  displayName: Joi.string().required(),
132
125
  extendedProperties: Joi.object({
133
126
  casId: Joi.number().required(),
@@ -140,11 +133,7 @@ export class MaterialEntityDescriptorSchema {
140
133
  * @returns A MaterialEntityDescriptor instance.
141
134
  * @throws Error if validation fails.
142
135
  */
143
- makeMaterialInfo(data: {
144
- id: string;
145
- displayName: string;
146
- extendedProperties: { casId: number };
147
- }): MaterialEntityDescriptor {
136
+ makeMaterialInfo(data: { id: string; displayName: string; extendedProperties: { casId: number } }): MaterialEntityDescriptor {
148
137
  const { error, value } = this.schema.validate(data);
149
138
  if (error) {
150
139
  throw new Error(`Validation error: ${error.details[0].message}`);
@@ -157,26 +146,15 @@ export class MaterialEntityDescriptorSchema {
157
146
  delete value.extendedProperties;
158
147
 
159
148
  // Return a new instance of the MaterialEntityDescriptor class.
160
- return new MaterialEntityDescriptor(
161
- value.id,
162
- value.displayName,
163
- value.cas_id
164
- );
149
+ return new MaterialEntityDescriptor(value.id, value.displayName, value.cas_id);
165
150
  }
166
151
  }
167
152
 
168
- async function getDataFromUrl<T>(
169
- url: string,
170
- schemaClass: SchemaClass,
171
- many: boolean = false,
172
- controller?: AbortController
173
- ): Promise<T | T[]> {
153
+ async function getDataFromUrl<T>(url: string, schemaClass: SchemaClass, many: boolean = false, controller?: AbortController): Promise<T | T[]> {
174
154
  const { data } = await getRequest(url, controller);
175
155
 
176
156
  // Access the Joi schema from the schema class
177
- const validationSchema = many
178
- ? Joi.array().items(schemaClass.schema)
179
- : schemaClass.schema;
157
+ const validationSchema = many ? Joi.array().items(schemaClass.schema) : schemaClass.schema;
180
158
 
181
159
  // Validate the data
182
160
  const { error, value } = validationSchema.validate(data, {
@@ -184,18 +162,14 @@ async function getDataFromUrl<T>(
184
162
  });
185
163
 
186
164
  if (error) {
187
- const errorMessages = error.details
188
- .map((e: { message: any }) => e.message)
189
- .join(", ");
165
+ const errorMessages = error.details.map((e: { message: any }) => e.message).join(', ');
190
166
  throw new Error(`Error retrieving data: ${errorMessages}`);
191
167
  }
192
168
 
193
169
  return value;
194
170
  }
195
171
 
196
- export async function getAllCasIds(
197
- controller?: AbortController
198
- ): Promise<MaterialCasIdInfo[]> {
172
+ export async function getAllCasIds(controller?: AbortController): Promise<MaterialCasIdInfo[]> {
199
173
  try {
200
174
  // Generate the URL
201
175
  const apiTarget = getMaterialsApiTarget();
@@ -203,23 +177,14 @@ export async function getAllCasIds(
203
177
  const url = `${apiTarget}cas?clientId=${clientAliasId}`;
204
178
 
205
179
  // Fetch and validate the data
206
- return getDataFromUrl(
207
- url,
208
- new MaterialCasIdInfoSchema(),
209
- true,
210
- controller
211
- ) as Promise<MaterialCasIdInfo[]>;
180
+ return getDataFromUrl(url, new MaterialCasIdInfoSchema(), true, controller) as Promise<MaterialCasIdInfo[]>;
212
181
  } catch (error: unknown) {
213
- const errorMessage =
214
- error instanceof Error ? error.message : "Unknown error";
182
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
215
183
  throw new Error(`Error retrieving CAS IDs: ${errorMessage}`);
216
184
  }
217
185
  }
218
186
 
219
- export async function getMaterialByCasId(
220
- casId: number,
221
- controller?: AbortController
222
- ): Promise<Material[]> {
187
+ export async function getMaterialByCasId(casId: number, controller?: AbortController): Promise<Material[]> {
223
188
  try {
224
189
  // Generate the URL
225
190
  const apiTarget = getMaterialsApiTarget();
@@ -227,25 +192,14 @@ export async function getMaterialByCasId(
227
192
  const url = `${apiTarget}cas/${casId}?clientId=${clientAliasId}`;
228
193
 
229
194
  // Fetch and validate the data
230
- return getDataFromUrl(
231
- url,
232
- new MaterialSchema(),
233
- true,
234
- controller
235
- ) as Promise<Material[]>;
195
+ return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
236
196
  } catch (error: unknown) {
237
- const errorMessage =
238
- error instanceof Error ? error.message : "Unknown error";
239
- throw new Error(
240
- `Error retrieving material with CAS ID ${casId}: ${errorMessage}`
241
- );
197
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
198
+ throw new Error(`Error retrieving material with CAS ID ${casId}: ${errorMessage}`);
242
199
  }
243
200
  }
244
201
 
245
- export async function getComponents(
246
- source: number,
247
- controller?: AbortController
248
- ): Promise<MaterialComponentData[]> {
202
+ export async function getComponents(source: number, controller?: AbortController): Promise<MaterialComponentData[]> {
249
203
  try {
250
204
  // Generate the URL
251
205
  const apiTarget = getMaterialsApiTarget();
@@ -253,41 +207,26 @@ export async function getComponents(
253
207
  const url = `${apiTarget}components?clientId=${clientAliasId}&sources=${source}`;
254
208
 
255
209
  // Fetch and validate the data
256
- return getDataFromUrl(
257
- url,
258
- new MaterialEntityDescriptorSchema(),
259
- true,
260
- controller
261
- ) as Promise<MaterialComponentData[]>;
210
+ return getDataFromUrl(url, new MaterialEntityDescriptorSchema(), true, controller) as Promise<MaterialComponentData[]>;
262
211
  } catch (error: unknown) {
263
- const errorMessage =
264
- error instanceof Error ? error.message : "Unknown error";
212
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
265
213
  throw new Error(`Error retrieving components: ${errorMessage}`);
266
214
  }
267
215
  }
268
216
 
269
- export async function getDnvComponents(
270
- controller?: AbortController
271
- ): Promise<MaterialComponentData[]> {
217
+ export async function getDnvComponents(controller?: AbortController): Promise<MaterialComponentData[]> {
272
218
  return getComponents(1, controller);
273
219
  }
274
220
 
275
- export async function getDipprComponents(
276
- controller?: AbortController
277
- ): Promise<MaterialComponentData[]> {
221
+ export async function getDipprComponents(controller?: AbortController): Promise<MaterialComponentData[]> {
278
222
  return getComponents(2, controller);
279
223
  }
280
224
 
281
- export async function getUserComponents(
282
- controller?: AbortController
283
- ): Promise<MaterialComponentData[]> {
225
+ export async function getUserComponents(controller?: AbortController): Promise<MaterialComponentData[]> {
284
226
  return getComponents(3, controller);
285
227
  }
286
228
 
287
- export async function getComponentById(
288
- id: string,
289
- controller?: AbortController
290
- ): Promise<MaterialComponentData> {
229
+ export async function getComponentById(id: string, controller?: AbortController): Promise<MaterialComponentData> {
291
230
  try {
292
231
  // Generate the URL
293
232
  const apiTarget = getMaterialsApiTarget();
@@ -295,94 +234,51 @@ export async function getComponentById(
295
234
  const url = `${apiTarget}components/id=${id}?clientId=${clientAliasId}`;
296
235
 
297
236
  // Fetch and validate the data
298
- return getDataFromUrl(
299
- url,
300
- new MaterialComponentDataSchema(),
301
- false,
302
- controller
303
- ) as Promise<MaterialComponentData>;
237
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
304
238
  } catch (error: unknown) {
305
- const errorMessage =
306
- error instanceof Error ? error.message : "Unknown error";
307
- throw new Error(
308
- `Error retrieving component with ID ${id}: ${errorMessage}`
309
- );
239
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
240
+ throw new Error(`Error retrieving component with ID ${id}: ${errorMessage}`);
310
241
  }
311
242
  }
312
243
 
313
- export async function getComponentByName(
314
- name: string,
315
- controller?: AbortController
316
- ): Promise<MaterialComponentData> {
244
+ export async function getComponentByName(name: string, controller?: AbortController): Promise<MaterialComponentData> {
317
245
  try {
318
246
  // Generate the URL
319
247
  const apiTarget = getMaterialsApiTarget();
320
248
  const clientAliasId = getClientAliasId();
321
- const url = `${apiTarget}components/name=${encodeURIComponent(
322
- name
323
- )}?clientId=${clientAliasId}`;
249
+ const url = `${apiTarget}components/name=${encodeURIComponent(name)}?clientId=${clientAliasId}`;
324
250
 
325
251
  // Fetch and validate the data
326
- return getDataFromUrl(
327
- url,
328
- new MaterialComponentDataSchema(),
329
- false,
330
- controller
331
- ) as Promise<MaterialComponentData>;
252
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
332
253
  } catch (error: unknown) {
333
- const errorMessage =
334
- error instanceof Error ? error.message : "Unknown error";
335
- throw new Error(
336
- `Error retrieving component with name ${name}: ${errorMessage}`
337
- );
254
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
255
+ throw new Error(`Error retrieving component with name ${name}: ${errorMessage}`);
338
256
  }
339
257
  }
340
258
 
341
- export async function getComponentByCasId(
342
- casId: number,
343
- controller?: AbortController
344
- ): Promise<MaterialComponentData> {
259
+ export async function getComponentByCasId(casId: number, controller?: AbortController): Promise<MaterialComponentData> {
345
260
  try {
346
261
  // Generate the URL
347
262
  const apiTarget = getMaterialsApiTarget();
348
263
  const clientAliasId = getClientAliasId();
349
- const url = `${apiTarget}components/casid=${encodeURIComponent(
350
- casId
351
- )}?clientId=${clientAliasId}`;
264
+ const url = `${apiTarget}components/casid=${encodeURIComponent(casId)}?clientId=${clientAliasId}`;
352
265
 
353
266
  // Fetch and validate the data
354
- return getDataFromUrl(
355
- url,
356
- new MaterialComponentDataSchema(),
357
- false,
358
- controller
359
- ) as Promise<MaterialComponentData>;
267
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
360
268
  } catch (error: unknown) {
361
- const errorMessage =
362
- error instanceof Error ? error.message : "Unknown error";
363
- throw new Error(
364
- `Error retrieving component with CAS ID ${casId}: ${errorMessage}`
365
- );
269
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
270
+ throw new Error(`Error retrieving component with CAS ID ${casId}: ${errorMessage}`);
366
271
  }
367
272
  }
368
273
 
369
- export async function storeDataAndGetResponse<T>(
370
- url: string,
371
- data: any,
372
- schemaClass: SchemaClass,
373
- controller?: AbortController
374
- ): Promise<T> {
274
+ export async function storeDataAndGetResponse<T>(url: string, data: any, schemaClass: SchemaClass, controller?: AbortController): Promise<T> {
375
275
  // Serialize the data using the schema
376
276
  const { error: reqErr, value: payload } = schemaClass.schema.validate(data);
377
277
  if (reqErr) {
378
278
  throw new Error(`Validation error (request): ${reqErr.details[0].message}`);
379
279
  }
380
280
 
381
- const { status: postStatus, headers } = await postRequest(
382
- url,
383
- JSON.stringify(payload),
384
- controller
385
- );
281
+ const { status: postStatus, headers } = await postRequest(url, JSON.stringify(payload), controller);
386
282
 
387
283
  if (postStatus !== 201) {
388
284
  throw new Error(`Expected 201 from POST, got ${postStatus}`);
@@ -390,26 +286,20 @@ export async function storeDataAndGetResponse<T>(
390
286
 
391
287
  const location = headers.location ?? headers.Location; // header name can vary
392
288
  if (!location) {
393
- throw new Error("POST succeeded but no Location header returned");
289
+ throw new Error('POST succeeded but no Location header returned');
394
290
  }
395
291
 
396
292
  const { data: fetched } = await getRequest(location, controller);
397
293
 
398
- const { error: respErr, value: parsed } =
399
- schemaClass.schema.validate(fetched);
294
+ const { error: respErr, value: parsed } = schemaClass.schema.validate(fetched);
400
295
  if (respErr) {
401
- throw new Error(
402
- `Validation error (response): ${respErr.details[0].message}`
403
- );
296
+ throw new Error(`Validation error (response): ${respErr.details[0].message}`);
404
297
  }
405
298
 
406
299
  return parsed as T;
407
300
  }
408
301
 
409
- export async function storeMaterialComponentData(
410
- materialComponentData: MaterialComponentData,
411
- controller?: AbortController
412
- ): Promise<MaterialComponentData> {
302
+ export async function storeMaterialComponentData(materialComponentData: MaterialComponentData, controller?: AbortController): Promise<MaterialComponentData> {
413
303
  try {
414
304
  // Generate the URL
415
305
  const apiTarget = getMaterialsApiTarget();
@@ -417,23 +307,14 @@ export async function storeMaterialComponentData(
417
307
  const url = `${apiTarget}components?clientId=${clientAliasId}`;
418
308
 
419
309
  // Store the data and return the response
420
- return storeDataAndGetResponse(
421
- url,
422
- materialComponentData,
423
- new MaterialComponentDataSchema(),
424
- controller
425
- );
310
+ return storeDataAndGetResponse(url, materialComponentData, new MaterialComponentDataSchema(), controller);
426
311
  } catch (error: unknown) {
427
- const errorMessage =
428
- error instanceof Error ? error.message : "Unknown error";
312
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
429
313
  throw new Error(`Error storing material component data: ${errorMessage}`);
430
314
  }
431
315
  }
432
316
 
433
- export async function storeMaterialComponentAndCreateMaterial(
434
- materialComponentData: MaterialComponentData,
435
- controller?: AbortController
436
- ): Promise<Material> {
317
+ export async function storeMaterialComponentAndCreateMaterial(materialComponentData: MaterialComponentData, controller?: AbortController): Promise<Material> {
437
318
  try {
438
319
  // Generate the URL
439
320
  const apiTarget = getMaterialsApiTarget();
@@ -441,44 +322,25 @@ export async function storeMaterialComponentAndCreateMaterial(
441
322
  const url = `${apiTarget}components/material?clientId=${clientAliasId}`;
442
323
 
443
324
  // Store the data and return the response
444
- return storeDataAndGetResponse(
445
- url,
446
- materialComponentData,
447
- new MaterialSchema(),
448
- controller
449
- );
325
+ return storeDataAndGetResponse(url, materialComponentData, new MaterialSchema(), controller);
450
326
  } catch (error: unknown) {
451
- const errorMessage =
452
- error instanceof Error ? error.message : "Unknown error";
453
- throw new Error(
454
- `Error storing material component and creating material: ${errorMessage}`
455
- );
327
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
328
+ throw new Error(`Error storing material component and creating material: ${errorMessage}`);
456
329
  }
457
330
  }
458
331
 
459
- export async function updateMaterialComponent(
460
- data: MaterialComponentData,
461
- controller?: AbortController
462
- ): Promise<boolean> {
332
+ export async function updateMaterialComponent(data: MaterialComponentData, controller?: AbortController): Promise<boolean> {
463
333
  const url = `${getMaterialsApiTarget()}components?clientId=${getClientAliasId()}`;
464
- const { status, statusText } = await putRequest(
465
- url,
466
- JSON.stringify(data),
467
- controller
468
- );
334
+ const { status, statusText } = await putRequest(url, JSON.stringify(data), controller);
469
335
 
470
336
  // Check if the response status is 204 (no content)
471
337
  if (status !== 204) {
472
- throw new Error(
473
- `Failed to update material component: ${status} ${statusText}`
474
- );
338
+ throw new Error(`Failed to update material component: ${status} ${statusText}`);
475
339
  }
476
340
  return true;
477
341
  }
478
342
 
479
- export async function getMaterials(
480
- controller?: AbortController
481
- ): Promise<Material[]> {
343
+ export async function getMaterials(controller?: AbortController): Promise<Material[]> {
482
344
  try {
483
345
  // Generate the URL
484
346
  const apiTarget = getMaterialsApiTarget();
@@ -486,23 +348,14 @@ export async function getMaterials(
486
348
  const url = `${apiTarget}materials?clientId=${clientAliasId}`;
487
349
 
488
350
  // Fetch and validate the data
489
- return getDataFromUrl(
490
- url,
491
- new MaterialSchema(),
492
- true,
493
- controller
494
- ) as Promise<Material[]>;
351
+ return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
495
352
  } catch (error: unknown) {
496
- const errorMessage =
497
- error instanceof Error ? error.message : "Unknown error";
353
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
498
354
  throw new Error(`Error retrieving materials: ${errorMessage}`);
499
355
  }
500
356
  }
501
357
 
502
- export async function getMaterialById(
503
- id: string,
504
- controller?: AbortController
505
- ): Promise<Material> {
358
+ export async function getMaterialById(id: string, controller?: AbortController): Promise<Material> {
506
359
  try {
507
360
  // Generate the URL
508
361
  const apiTarget = getMaterialsApiTarget();
@@ -510,23 +363,14 @@ export async function getMaterialById(
510
363
  const url = `${apiTarget}materials/id=${id}?clientId=${clientAliasId}`;
511
364
 
512
365
  // Fetch and validate the data
513
- return getDataFromUrl(
514
- url,
515
- new MaterialSchema(),
516
- false,
517
- controller
518
- ) as Promise<Material>;
366
+ return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
519
367
  } catch (error: unknown) {
520
- const errorMessage =
521
- error instanceof Error ? error.message : "Unknown error";
368
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
522
369
  throw new Error(`Error retrieving material with ID ${id}: ${errorMessage}`);
523
370
  }
524
371
  }
525
372
 
526
- export async function getMaterialByName(
527
- name: string,
528
- controller?: AbortController
529
- ): Promise<Material> {
373
+ export async function getMaterialByName(name: string, controller?: AbortController): Promise<Material> {
530
374
  try {
531
375
  // Generate the URL
532
376
  const apiTarget = getMaterialsApiTarget();
@@ -534,18 +378,10 @@ export async function getMaterialByName(
534
378
  const url = `${apiTarget}materials/name=${name}?clientId=${clientAliasId}`;
535
379
 
536
380
  // Fetch and validate the data
537
- return getDataFromUrl(
538
- url,
539
- new MaterialSchema(),
540
- false,
541
- controller
542
- ) as Promise<Material>;
381
+ return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
543
382
  } catch (error: unknown) {
544
- const errorMessage =
545
- error instanceof Error ? error.message : "Unknown error";
546
- throw new Error(
547
- `Error retrieving material with name ${name}: ${errorMessage}`
548
- );
383
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
384
+ throw new Error(`Error retrieving material with name ${name}: ${errorMessage}`);
549
385
  }
550
386
  }
551
387
 
@@ -557,15 +393,9 @@ export async function getMaterialNames(controller?: AbortController) {
557
393
  const url = `${apiTarget}materials/descriptors?clientId=${clientAliasId}`;
558
394
 
559
395
  // Fetch and validate the data
560
- return getDataFromUrl(
561
- url,
562
- new MaterialInfoSchema(),
563
- true,
564
- controller
565
- ) as Promise<MaterialInfo[]>;
396
+ return getDataFromUrl(url, new MaterialInfoSchema(), true, controller) as Promise<MaterialInfo[]>;
566
397
  } catch (error: unknown) {
567
- const errorMessage =
568
- error instanceof Error ? error.message : "Unknown error";
398
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
569
399
  throw new Error(`Error retrieving material names: ${errorMessage}`);
570
400
  }
571
401
  }