@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.
package/src/materials.ts CHANGED
@@ -6,9 +6,9 @@
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.97
10
- * Date/time: 13 Apr 2026 17:02:52
11
- * Template: templates/typescriptpws/materials.razor.
9
+ * Version: 1.0.0
10
+ * Date/time: 23 Jun 2026 12:11:11
11
+ * Template: TYPE_SCRIPT_PWS/materials.sbn.
12
12
  ***********************************************************************/
13
13
 
14
14
  import { getRequest, postRequest, putRequest, getMaterialsApiTarget, getClientAliasId } from './utilities';
@@ -29,8 +29,8 @@ export class MaterialInfo {
29
29
  * @param {string} name - The name of the material.
30
30
  */
31
31
  constructor(
32
- readonly id: string,
33
- readonly name: string,
32
+ readonly id: string,
33
+ readonly name: string,
34
34
  ) {}
35
35
  }
36
36
 
@@ -43,9 +43,9 @@ export class MaterialCasIdInfo {
43
43
  * @param {number} casId - The CAS ID of the material.
44
44
  */
45
45
  constructor(
46
- readonly id: string,
47
- readonly name: string,
48
- readonly casId: number,
46
+ readonly id: string,
47
+ readonly name: string,
48
+ readonly casId: number,
49
49
  ) {}
50
50
  }
51
51
 
@@ -53,10 +53,10 @@ export class MaterialInfoSchema {
53
53
  schema: Joi.ObjectSchema;
54
54
 
55
55
  constructor() {
56
- this.schema = Joi.object({
57
- id: Joi.string().guid({ version: 'uuidv4' }).required(),
58
- displayName: Joi.string().required(),
59
- }).unknown(true);
56
+ this.schema = Joi.object({
57
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
58
+ displayName: Joi.string().required(),
59
+ }).unknown(true);
60
60
  }
61
61
 
62
62
  /**
@@ -66,11 +66,11 @@ export class MaterialInfoSchema {
66
66
  * @throws Error if validation fails.
67
67
  */
68
68
  makeMaterialInfo(data: { id: string; displayName: string }): MaterialInfo {
69
- const { error, value } = this.schema.validate(data);
70
- if (error) {
71
- throw new Error(`Validation error: ${error.details[0].message}`);
72
- }
73
- return new MaterialInfo(value.id, value.displayName);
69
+ const { error, value } = this.schema.validate(data);
70
+ if (error) {
71
+ throw new Error(`Validation error: ${error.details[0].message}`);
72
+ }
73
+ return new MaterialInfo(value.id, value.displayName);
74
74
  }
75
75
  }
76
76
 
@@ -78,11 +78,11 @@ export class MaterialCasIdInfoSchema {
78
78
  schema: Joi.ObjectSchema;
79
79
 
80
80
  constructor() {
81
- this.schema = Joi.object({
82
- id: Joi.string().guid({ version: 'uuidv4' }).required(),
83
- name: Joi.string().required(),
84
- casId: Joi.number().required(),
85
- }).unknown(true);
81
+ this.schema = Joi.object({
82
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
83
+ name: Joi.string().required(),
84
+ casId: Joi.number().required(),
85
+ }).unknown(true);
86
86
  }
87
87
 
88
88
  /**
@@ -92,11 +92,11 @@ export class MaterialCasIdInfoSchema {
92
92
  * @throws Error if validation fails.
93
93
  */
94
94
  makeMaterialInfo(data: { id: string; name: string; casId: number }): MaterialCasIdInfo {
95
- const { error, value } = this.schema.validate(data);
96
- if (error) {
97
- throw new Error(`Validation error: ${error.details[0].message}`);
98
- }
99
- return new MaterialCasIdInfo(value.id, value.name, value.casId);
95
+ const { error, value } = this.schema.validate(data);
96
+ if (error) {
97
+ throw new Error(`Validation error: ${error.details[0].message}`);
98
+ }
99
+ return new MaterialCasIdInfo(value.id, value.name, value.casId);
100
100
  }
101
101
  }
102
102
 
@@ -109,9 +109,9 @@ export class MaterialEntityDescriptor {
109
109
  * @param {number} casId - The CAS ID of the material.
110
110
  */
111
111
  constructor(
112
- readonly id: string,
113
- readonly name: string,
114
- readonly casId: number,
112
+ readonly id: string,
113
+ readonly name: string,
114
+ readonly casId: number,
115
115
  ) {}
116
116
  }
117
117
 
@@ -119,13 +119,13 @@ export class MaterialEntityDescriptorSchema {
119
119
  schema: Joi.ObjectSchema;
120
120
 
121
121
  constructor() {
122
- this.schema = Joi.object({
123
- id: Joi.string().guid({ version: 'uuidv4' }).required(),
124
- displayName: Joi.string().required(),
125
- extendedProperties: Joi.object({
126
- casId: Joi.number().required(),
127
- }).required(),
128
- }).unknown(true);
122
+ this.schema = Joi.object({
123
+ id: Joi.string().guid({ version: 'uuidv4' }).required(),
124
+ displayName: Joi.string().required(),
125
+ extendedProperties: Joi.object({
126
+ casId: Joi.number().required(),
127
+ }).required(),
128
+ }).unknown(true);
129
129
  }
130
130
 
131
131
  /** Validates and transforms data into a MaterialEntityDescriptor object.
@@ -134,19 +134,19 @@ export class MaterialEntityDescriptorSchema {
134
134
  * @throws Error if validation fails.
135
135
  */
136
136
  makeMaterialInfo(data: { id: string; displayName: string; extendedProperties: { casId: number } }): MaterialEntityDescriptor {
137
- const { error, value } = this.schema.validate(data);
138
- if (error) {
139
- throw new Error(`Validation error: ${error.details[0].message}`);
140
- }
137
+ const { error, value } = this.schema.validate(data);
138
+ if (error) {
139
+ throw new Error(`Validation error: ${error.details[0].message}`);
140
+ }
141
141
 
142
- // Add the cas_id to the data dictionary.
143
- value.cas_id = value.extendedProperties.casId;
142
+ // Add the cas_id to the data dictionary.
143
+ value.cas_id = value.extendedProperties.casId;
144
144
 
145
- // Remove the extended_properties from the data dictionary.
146
- delete value.extendedProperties;
145
+ // Remove the extended_properties from the data dictionary.
146
+ delete value.extendedProperties;
147
147
 
148
- // Return a new instance of the MaterialEntityDescriptor class.
149
- return new MaterialEntityDescriptor(value.id, value.displayName, value.cas_id);
148
+ // Return a new instance of the MaterialEntityDescriptor class.
149
+ return new MaterialEntityDescriptor(value.id, value.displayName, value.cas_id);
150
150
  }
151
151
  }
152
152
 
@@ -158,12 +158,12 @@ async function getDataFromUrl<T>(url: string, schemaClass: SchemaClass, many: bo
158
158
 
159
159
  // Validate the data
160
160
  const { error, value } = validationSchema.validate(data, {
161
- abortEarly: false,
161
+ abortEarly: false,
162
162
  });
163
163
 
164
164
  if (error) {
165
- const errorMessages = error.details.map((e: { message: any }) => e.message).join(', ');
166
- throw new Error(`Error retrieving data: ${errorMessages}`);
165
+ const errorMessages = error.details.map((e: { message: any }) => e.message).join(', ');
166
+ throw new Error(`Error retrieving data: ${errorMessages}`);
167
167
  }
168
168
 
169
169
  return value;
@@ -171,46 +171,46 @@ async function getDataFromUrl<T>(url: string, schemaClass: SchemaClass, many: bo
171
171
 
172
172
  export async function getAllCasIds(controller?: AbortController): Promise<MaterialCasIdInfo[]> {
173
173
  try {
174
- // Generate the URL
175
- const apiTarget = getMaterialsApiTarget();
176
- const clientAliasId = getClientAliasId();
177
- const url = `${apiTarget}cas?clientId=${clientAliasId}`;
174
+ // Generate the URL
175
+ const apiTarget = getMaterialsApiTarget();
176
+ const clientAliasId = getClientAliasId();
177
+ const url = `${apiTarget}cas?clientId=${clientAliasId}`;
178
178
 
179
- // Fetch and validate the data
180
- return getDataFromUrl(url, new MaterialCasIdInfoSchema(), true, controller) as Promise<MaterialCasIdInfo[]>;
179
+ // Fetch and validate the data
180
+ return getDataFromUrl(url, new MaterialCasIdInfoSchema(), true, controller) as Promise<MaterialCasIdInfo[]>;
181
181
  } catch (error: unknown) {
182
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
183
- throw new Error(`Error retrieving CAS IDs: ${errorMessage}`);
182
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
183
+ throw new Error(`Error retrieving CAS IDs: ${errorMessage}`);
184
184
  }
185
185
  }
186
186
 
187
187
  export async function getMaterialByCasId(casId: number, controller?: AbortController): Promise<Material[]> {
188
188
  try {
189
- // Generate the URL
190
- const apiTarget = getMaterialsApiTarget();
191
- const clientAliasId = getClientAliasId();
192
- const url = `${apiTarget}cas/${casId}?clientId=${clientAliasId}`;
189
+ // Generate the URL
190
+ const apiTarget = getMaterialsApiTarget();
191
+ const clientAliasId = getClientAliasId();
192
+ const url = `${apiTarget}cas/${casId}?clientId=${clientAliasId}`;
193
193
 
194
- // Fetch and validate the data
195
- return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
194
+ // Fetch and validate the data
195
+ return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
196
196
  } catch (error: unknown) {
197
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
198
- throw new Error(`Error retrieving material with CAS ID ${casId}: ${errorMessage}`);
197
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
198
+ throw new Error(`Error retrieving material with CAS ID ${casId}: ${errorMessage}`);
199
199
  }
200
200
  }
201
201
 
202
202
  export async function getComponents(source: number, controller?: AbortController): Promise<MaterialComponentData[]> {
203
203
  try {
204
- // Generate the URL
205
- const apiTarget = getMaterialsApiTarget();
206
- const clientAliasId = getClientAliasId();
207
- const url = `${apiTarget}components?clientId=${clientAliasId}&sources=${source}`;
204
+ // Generate the URL
205
+ const apiTarget = getMaterialsApiTarget();
206
+ const clientAliasId = getClientAliasId();
207
+ const url = `${apiTarget}components?clientId=${clientAliasId}&sources=${source}`;
208
208
 
209
- // Fetch and validate the data
210
- return getDataFromUrl(url, new MaterialEntityDescriptorSchema(), true, controller) as Promise<MaterialComponentData[]>;
209
+ // Fetch and validate the data
210
+ return getDataFromUrl(url, new MaterialEntityDescriptorSchema(), true, controller) as Promise<MaterialComponentData[]>;
211
211
  } catch (error: unknown) {
212
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
213
- throw new Error(`Error retrieving components: ${errorMessage}`);
212
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
213
+ throw new Error(`Error retrieving components: ${errorMessage}`);
214
214
  }
215
215
  }
216
216
 
@@ -228,46 +228,46 @@ export async function getUserComponents(controller?: AbortController): Promise<M
228
228
 
229
229
  export async function getComponentById(id: string, controller?: AbortController): Promise<MaterialComponentData> {
230
230
  try {
231
- // Generate the URL
232
- const apiTarget = getMaterialsApiTarget();
233
- const clientAliasId = getClientAliasId();
234
- const url = `${apiTarget}components/id=${id}?clientId=${clientAliasId}`;
231
+ // Generate the URL
232
+ const apiTarget = getMaterialsApiTarget();
233
+ const clientAliasId = getClientAliasId();
234
+ const url = `${apiTarget}components/id=${id}?clientId=${clientAliasId}`;
235
235
 
236
- // Fetch and validate the data
237
- return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
236
+ // Fetch and validate the data
237
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
238
238
  } catch (error: unknown) {
239
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
240
- throw new Error(`Error retrieving component with ID ${id}: ${errorMessage}`);
239
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
240
+ throw new Error(`Error retrieving component with ID ${id}: ${errorMessage}`);
241
241
  }
242
242
  }
243
243
 
244
244
  export async function getComponentByName(name: string, controller?: AbortController): Promise<MaterialComponentData> {
245
245
  try {
246
- // Generate the URL
247
- const apiTarget = getMaterialsApiTarget();
248
- const clientAliasId = getClientAliasId();
249
- const url = `${apiTarget}components/name=${encodeURIComponent(name)}?clientId=${clientAliasId}`;
246
+ // Generate the URL
247
+ const apiTarget = getMaterialsApiTarget();
248
+ const clientAliasId = getClientAliasId();
249
+ const url = `${apiTarget}components/name=${encodeURIComponent(name)}?clientId=${clientAliasId}`;
250
250
 
251
- // Fetch and validate the data
252
- return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
251
+ // Fetch and validate the data
252
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
253
253
  } catch (error: unknown) {
254
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
255
- throw new Error(`Error retrieving component with name ${name}: ${errorMessage}`);
254
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
255
+ throw new Error(`Error retrieving component with name ${name}: ${errorMessage}`);
256
256
  }
257
257
  }
258
258
 
259
259
  export async function getComponentByCasId(casId: number, controller?: AbortController): Promise<MaterialComponentData> {
260
260
  try {
261
- // Generate the URL
262
- const apiTarget = getMaterialsApiTarget();
263
- const clientAliasId = getClientAliasId();
264
- const url = `${apiTarget}components/casid=${encodeURIComponent(casId)}?clientId=${clientAliasId}`;
261
+ // Generate the URL
262
+ const apiTarget = getMaterialsApiTarget();
263
+ const clientAliasId = getClientAliasId();
264
+ const url = `${apiTarget}components/casid=${encodeURIComponent(casId)}?clientId=${clientAliasId}`;
265
265
 
266
- // Fetch and validate the data
267
- return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
266
+ // Fetch and validate the data
267
+ return getDataFromUrl(url, new MaterialComponentDataSchema(), false, controller) as Promise<MaterialComponentData>;
268
268
  } catch (error: unknown) {
269
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
270
- throw new Error(`Error retrieving component with CAS ID ${casId}: ${errorMessage}`);
269
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
270
+ throw new Error(`Error retrieving component with CAS ID ${casId}: ${errorMessage}`);
271
271
  }
272
272
  }
273
273
 
@@ -275,25 +275,25 @@ export async function storeDataAndGetResponse<T>(url: string, data: any, schemaC
275
275
  // Serialize the data using the schema
276
276
  const { error: reqErr, value: payload } = schemaClass.schema.validate(data);
277
277
  if (reqErr) {
278
- throw new Error(`Validation error (request): ${reqErr.details[0].message}`);
278
+ throw new Error(`Validation error (request): ${reqErr.details[0].message}`);
279
279
  }
280
280
 
281
281
  const { status: postStatus, headers } = await postRequest(url, JSON.stringify(payload), controller);
282
282
 
283
283
  if (postStatus !== 201) {
284
- throw new Error(`Expected 201 from POST, got ${postStatus}`);
284
+ throw new Error(`Expected 201 from POST, got ${postStatus}`);
285
285
  }
286
286
 
287
287
  const location = headers.location ?? headers.Location; // header name can vary
288
288
  if (!location) {
289
- throw new Error('POST succeeded but no Location header returned');
289
+ throw new Error('POST succeeded but no Location header returned');
290
290
  }
291
291
 
292
292
  const { data: fetched } = await getRequest(location, controller);
293
293
 
294
294
  const { error: respErr, value: parsed } = schemaClass.schema.validate(fetched);
295
295
  if (respErr) {
296
- throw new Error(`Validation error (response): ${respErr.details[0].message}`);
296
+ throw new Error(`Validation error (response): ${respErr.details[0].message}`);
297
297
  }
298
298
 
299
299
  return parsed as T;
@@ -301,31 +301,31 @@ export async function storeDataAndGetResponse<T>(url: string, data: any, schemaC
301
301
 
302
302
  export async function storeMaterialComponentData(materialComponentData: MaterialComponentData, controller?: AbortController): Promise<MaterialComponentData> {
303
303
  try {
304
- // Generate the URL
305
- const apiTarget = getMaterialsApiTarget();
306
- const clientAliasId = getClientAliasId();
307
- const url = `${apiTarget}components?clientId=${clientAliasId}`;
304
+ // Generate the URL
305
+ const apiTarget = getMaterialsApiTarget();
306
+ const clientAliasId = getClientAliasId();
307
+ const url = `${apiTarget}components?clientId=${clientAliasId}`;
308
308
 
309
- // Store the data and return the response
310
- return storeDataAndGetResponse(url, materialComponentData, new MaterialComponentDataSchema(), controller);
309
+ // Store the data and return the response
310
+ return storeDataAndGetResponse(url, materialComponentData, new MaterialComponentDataSchema(), controller);
311
311
  } catch (error: unknown) {
312
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
313
- throw new Error(`Error storing material component data: ${errorMessage}`);
312
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
313
+ throw new Error(`Error storing material component data: ${errorMessage}`);
314
314
  }
315
315
  }
316
316
 
317
317
  export async function storeMaterialComponentAndCreateMaterial(materialComponentData: MaterialComponentData, controller?: AbortController): Promise<Material> {
318
318
  try {
319
- // Generate the URL
320
- const apiTarget = getMaterialsApiTarget();
321
- const clientAliasId = getClientAliasId();
322
- const url = `${apiTarget}components/material?clientId=${clientAliasId}`;
319
+ // Generate the URL
320
+ const apiTarget = getMaterialsApiTarget();
321
+ const clientAliasId = getClientAliasId();
322
+ const url = `${apiTarget}components/material?clientId=${clientAliasId}`;
323
323
 
324
- // Store the data and return the response
325
- return storeDataAndGetResponse(url, materialComponentData, new MaterialSchema(), controller);
324
+ // Store the data and return the response
325
+ return storeDataAndGetResponse(url, materialComponentData, new MaterialSchema(), controller);
326
326
  } catch (error: unknown) {
327
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
328
- throw new Error(`Error storing material component and creating material: ${errorMessage}`);
327
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
328
+ throw new Error(`Error storing material component and creating material: ${errorMessage}`);
329
329
  }
330
330
  }
331
331
 
@@ -335,67 +335,67 @@ export async function updateMaterialComponent(data: MaterialComponentData, contr
335
335
 
336
336
  // Check if the response status is 204 (no content)
337
337
  if (status !== 204) {
338
- throw new Error(`Failed to update material component: ${status} ${statusText}`);
338
+ throw new Error(`Failed to update material component: ${status} ${statusText}`);
339
339
  }
340
340
  return true;
341
341
  }
342
342
 
343
343
  export async function getMaterials(controller?: AbortController): Promise<Material[]> {
344
344
  try {
345
- // Generate the URL
346
- const apiTarget = getMaterialsApiTarget();
347
- const clientAliasId = getClientAliasId();
348
- const url = `${apiTarget}materials?clientId=${clientAliasId}`;
345
+ // Generate the URL
346
+ const apiTarget = getMaterialsApiTarget();
347
+ const clientAliasId = getClientAliasId();
348
+ const url = `${apiTarget}materials?clientId=${clientAliasId}`;
349
349
 
350
- // Fetch and validate the data
351
- return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
350
+ // Fetch and validate the data
351
+ return getDataFromUrl(url, new MaterialSchema(), true, controller) as Promise<Material[]>;
352
352
  } catch (error: unknown) {
353
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
354
- throw new Error(`Error retrieving materials: ${errorMessage}`);
353
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
354
+ throw new Error(`Error retrieving materials: ${errorMessage}`);
355
355
  }
356
356
  }
357
357
 
358
358
  export async function getMaterialById(id: string, controller?: AbortController): Promise<Material> {
359
359
  try {
360
- // Generate the URL
361
- const apiTarget = getMaterialsApiTarget();
362
- const clientAliasId = getClientAliasId();
363
- const url = `${apiTarget}materials/id=${id}?clientId=${clientAliasId}`;
360
+ // Generate the URL
361
+ const apiTarget = getMaterialsApiTarget();
362
+ const clientAliasId = getClientAliasId();
363
+ const url = `${apiTarget}materials/id=${id}?clientId=${clientAliasId}`;
364
364
 
365
- // Fetch and validate the data
366
- return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
365
+ // Fetch and validate the data
366
+ return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
367
367
  } catch (error: unknown) {
368
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
369
- throw new Error(`Error retrieving material with ID ${id}: ${errorMessage}`);
368
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
369
+ throw new Error(`Error retrieving material with ID ${id}: ${errorMessage}`);
370
370
  }
371
371
  }
372
372
 
373
373
  export async function getMaterialByName(name: string, controller?: AbortController): Promise<Material> {
374
374
  try {
375
- // Generate the URL
376
- const apiTarget = getMaterialsApiTarget();
377
- const clientAliasId = getClientAliasId();
378
- const url = `${apiTarget}materials/name=${name}?clientId=${clientAliasId}`;
375
+ // Generate the URL
376
+ const apiTarget = getMaterialsApiTarget();
377
+ const clientAliasId = getClientAliasId();
378
+ const url = `${apiTarget}materials/name=${name}?clientId=${clientAliasId}`;
379
379
 
380
- // Fetch and validate the data
381
- return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
380
+ // Fetch and validate the data
381
+ return getDataFromUrl(url, new MaterialSchema(), false, controller) as Promise<Material>;
382
382
  } catch (error: unknown) {
383
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
384
- throw new Error(`Error retrieving material with name ${name}: ${errorMessage}`);
383
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
384
+ throw new Error(`Error retrieving material with name ${name}: ${errorMessage}`);
385
385
  }
386
386
  }
387
387
 
388
388
  export async function getMaterialNames(controller?: AbortController) {
389
389
  try {
390
- // Generate the URL
391
- const apiTarget = getMaterialsApiTarget();
392
- const clientAliasId = getClientAliasId();
393
- const url = `${apiTarget}materials/descriptors?clientId=${clientAliasId}`;
390
+ // Generate the URL
391
+ const apiTarget = getMaterialsApiTarget();
392
+ const clientAliasId = getClientAliasId();
393
+ const url = `${apiTarget}materials/descriptors?clientId=${clientAliasId}`;
394
394
 
395
- // Fetch and validate the data
396
- return getDataFromUrl(url, new MaterialInfoSchema(), true, controller) as Promise<MaterialInfo[]>;
395
+ // Fetch and validate the data
396
+ return getDataFromUrl(url, new MaterialInfoSchema(), true, controller) as Promise<MaterialInfo[]>;
397
397
  } catch (error: unknown) {
398
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
399
- throw new Error(`Error retrieving material names: ${errorMessage}`);
398
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
399
+ throw new Error(`Error retrieving material names: ${errorMessage}`);
400
400
  }
401
- }
401
+ }