@dnv-plant/typescriptpws 1.0.18 → 1.0.22-alpha.1807518

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,7 +1,7 @@
1
1
  /***********************************************************************
2
2
  * This file has been auto-generated by a code generation tool.
3
- * Version: 1.0.18
4
- * Date/time: 18 Feb 2025 14:37:50
3
+ * Version: 1.0.22
4
+ * Date/time: 19 Feb 2025 15:30:41
5
5
  * Template: templates/typescriptpws/entityschemas.razor.
6
6
  ***********************************************************************/
7
7
 
@@ -33,7 +33,49 @@ const propertiesToIgnore = [
33
33
  // Convert array to regex pattern
34
34
  const ignoredPropertiesRegex = new RegExp(`^(${propertiesToIgnore.join("|")})$`);
35
35
 
36
- export interface LocalPositionSchemaData {
36
+ class ValidationError extends Error {
37
+ constructor(public details: string[]) {
38
+ super(`Validation error: ${details.join(", ")}`);
39
+ this.name = "ValidationError";
40
+ }
41
+ }
42
+
43
+ abstract class SchemaBase<T> {
44
+ schema: Joi.ObjectSchema;
45
+ propertyTypes: Record<string, string>;
46
+
47
+ constructor() {
48
+ this.schema = Joi.object({
49
+ id: Joi.string().allow(""),
50
+ typeId: Joi.string().allow(""),
51
+ displayName: Joi.string().allow(""),
52
+ });
53
+
54
+ this.propertyTypes = {
55
+ id: "string",
56
+ typeId: "string",
57
+ displayName: "string",
58
+ };
59
+ }
60
+
61
+ validate(data: T): T {
62
+ const { error } = this.schema.validate(data, { abortEarly: false });
63
+ if (error) {
64
+ throw new ValidationError(error.details.map((x) => x.message));
65
+ }
66
+ return this.makeEntity(data);
67
+ }
68
+
69
+ abstract makeEntity(data: T): any;
70
+ }
71
+
72
+ interface SchemaBaseData {
73
+ id: string;
74
+ typeId: string;
75
+ displayName: string;
76
+ }
77
+
78
+ export interface LocalPositionSchemaData extends SchemaBaseData {
37
79
  x: number;
38
80
  y: number;
39
81
  z: number;
@@ -45,39 +87,35 @@ export interface LocalPositionSchemaData {
45
87
  * Description: Position with reference to some arbitrary local origin and axes.
46
88
  * ================================================================================
47
89
  */
48
- export class LocalPositionSchema {
49
- schema: Joi.ObjectSchema;
50
- propertyTypes: Record<string, unknown>;
51
-
90
+ export class LocalPositionSchema extends SchemaBase<LocalPositionSchemaData> {
52
91
  constructor() {
53
- this.schema = Joi.object({
54
- x: Joi.number().unsafe(),
55
- y: Joi.number().unsafe(),
56
- z: Joi.number().unsafe(),
57
- })
58
- .pattern(
59
- ignoredPropertiesRegex,
60
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
61
- )
62
- .unknown(false);
92
+ super();
93
+ this.schema = this.schema.concat(
94
+ Joi.object({
95
+ x: Joi.number().unsafe(),
96
+ y: Joi.number().unsafe(),
97
+ z: Joi.number().unsafe(),
98
+ })
99
+ )
100
+ .pattern(
101
+ ignoredPropertiesRegex,
102
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
103
+ )
104
+ .unknown(false);
63
105
 
64
106
  this.propertyTypes = {
107
+ ...this.propertyTypes,
65
108
  x: "number",
66
109
  y: "number",
67
110
  z: "number",
68
111
  };
69
112
  }
70
113
 
71
- validate(data: LocalPositionSchemaData): Entities.LocalPosition {
72
- const { error, value } = this.schema.validate(data, { abortEarly: false });
73
- if (error) {
74
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
75
- }
76
- return this.makeEntity(value);
77
- }
78
-
79
114
  makeEntity(data: LocalPositionSchemaData): Entities.LocalPosition {
80
115
  return new Entities.LocalPosition(
116
+ data.id,
117
+ data.typeId,
118
+ data.displayName,
81
119
  data.x,
82
120
  data.y,
83
121
  data.z
@@ -85,7 +123,7 @@ export class LocalPositionSchema {
85
123
  }
86
124
  }
87
125
 
88
- export interface AssetSchemaData {
126
+ export interface AssetSchemaData extends SchemaBaseData {
89
127
  location: Entities.LocalPosition;
90
128
  }
91
129
 
@@ -95,41 +133,37 @@ export interface AssetSchemaData {
95
133
  * Description: Any equipment to be modeled, vessels, pipelines
96
134
  * ================================================================================
97
135
  */
98
- export class AssetSchema {
99
- schema: Joi.ObjectSchema;
100
- propertyTypes: Record<string, unknown>;
101
-
136
+ export class AssetSchema extends SchemaBase<AssetSchemaData> {
102
137
  constructor() {
103
- this.schema = Joi.object({
104
- location: new LocalPositionSchema().schema,
105
- })
106
- .pattern(
107
- ignoredPropertiesRegex,
108
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
109
- )
110
- .unknown(false);
138
+ super();
139
+ this.schema = this.schema.concat(
140
+ Joi.object({
141
+ location: new LocalPositionSchema().schema,
142
+ })
143
+ )
144
+ .pattern(
145
+ ignoredPropertiesRegex,
146
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
147
+ )
148
+ .unknown(false);
111
149
 
112
150
  this.propertyTypes = {
151
+ ...this.propertyTypes,
113
152
  location: "LocalPosition",
114
153
  };
115
154
  }
116
155
 
117
- validate(data: AssetSchemaData): Entities.Asset {
118
- const { error, value } = this.schema.validate(data, { abortEarly: false });
119
- if (error) {
120
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
121
- }
122
- return this.makeEntity(value);
123
- }
124
-
125
156
  makeEntity(data: AssetSchemaData): Entities.Asset {
126
157
  return new Entities.Asset(
158
+ data.id,
159
+ data.typeId,
160
+ data.displayName,
127
161
  data.location
128
162
  );
129
163
  }
130
164
  }
131
165
 
132
- export interface MaterialComponentSchemaData {
166
+ export interface MaterialComponentSchemaData extends SchemaBaseData {
133
167
  name: string;
134
168
  moleFraction: number;
135
169
  }
@@ -140,44 +174,40 @@ export interface MaterialComponentSchemaData {
140
174
  * Description: Constituent component of a material.
141
175
  * ================================================================================
142
176
  */
143
- export class MaterialComponentSchema {
144
- schema: Joi.ObjectSchema;
145
- propertyTypes: Record<string, unknown>;
146
-
177
+ export class MaterialComponentSchema extends SchemaBase<MaterialComponentSchemaData> {
147
178
  constructor() {
148
- this.schema = Joi.object({
149
- name: Joi.string().allow(""),
150
- moleFraction: Joi.number().unsafe(),
151
- })
152
- .pattern(
153
- ignoredPropertiesRegex,
154
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
155
- )
156
- .unknown(false);
179
+ super();
180
+ this.schema = this.schema.concat(
181
+ Joi.object({
182
+ name: Joi.string().allow(""),
183
+ moleFraction: Joi.number().unsafe(),
184
+ })
185
+ )
186
+ .pattern(
187
+ ignoredPropertiesRegex,
188
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
189
+ )
190
+ .unknown(false);
157
191
 
158
192
  this.propertyTypes = {
193
+ ...this.propertyTypes,
159
194
  name: "string",
160
195
  moleFraction: "number",
161
196
  };
162
197
  }
163
198
 
164
- validate(data: MaterialComponentSchemaData): Entities.MaterialComponent {
165
- const { error, value } = this.schema.validate(data, { abortEarly: false });
166
- if (error) {
167
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
168
- }
169
- return this.makeEntity(value);
170
- }
171
-
172
199
  makeEntity(data: MaterialComponentSchemaData): Entities.MaterialComponent {
173
200
  return new Entities.MaterialComponent(
201
+ data.id,
202
+ data.typeId,
203
+ data.displayName,
174
204
  data.name,
175
205
  data.moleFraction
176
206
  );
177
207
  }
178
208
  }
179
209
 
180
- export interface MaterialSchemaData {
210
+ export interface MaterialSchemaData extends SchemaBaseData {
181
211
  name: string;
182
212
  components: Entities.MaterialComponent[];
183
213
  componentCount: number;
@@ -190,24 +220,25 @@ export interface MaterialSchemaData {
190
220
  * Description: The material to use in calculations.
191
221
  * ================================================================================
192
222
  */
193
- export class MaterialSchema {
194
- schema: Joi.ObjectSchema;
195
- propertyTypes: Record<string, unknown>;
196
-
223
+ export class MaterialSchema extends SchemaBase<MaterialSchemaData> {
197
224
  constructor() {
198
- this.schema = Joi.object({
199
- name: Joi.string().allow(""),
200
- components: Joi.array().items(new MaterialComponentSchema().schema).allow(null),
201
- componentCount: Joi.number().integer(),
202
- propertyTemplate: Joi.string().valid(...Object.values(Enums.PropertyTemplate)),
203
- })
204
- .pattern(
205
- ignoredPropertiesRegex,
206
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
207
- )
208
- .unknown(false);
225
+ super();
226
+ this.schema = this.schema.concat(
227
+ Joi.object({
228
+ name: Joi.string().allow(""),
229
+ components: Joi.array().items(new MaterialComponentSchema().schema).allow(null),
230
+ componentCount: Joi.number().integer(),
231
+ propertyTemplate: Joi.string().valid(...Object.values(Enums.PropertyTemplate)),
232
+ })
233
+ )
234
+ .pattern(
235
+ ignoredPropertiesRegex,
236
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
237
+ )
238
+ .unknown(false);
209
239
 
210
240
  this.propertyTypes = {
241
+ ...this.propertyTypes,
211
242
  name: "string",
212
243
  components: "MaterialComponent[]",
213
244
  componentCount: "number",
@@ -215,16 +246,11 @@ export class MaterialSchema {
215
246
  };
216
247
  }
217
248
 
218
- validate(data: MaterialSchemaData): Entities.Material {
219
- const { error, value } = this.schema.validate(data, { abortEarly: false });
220
- if (error) {
221
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
222
- }
223
- return this.makeEntity(value);
224
- }
225
-
226
249
  makeEntity(data: MaterialSchemaData): Entities.Material {
227
250
  return new Entities.Material(
251
+ data.id,
252
+ data.typeId,
253
+ data.displayName,
228
254
  data.name,
229
255
  data.components,
230
256
  data.componentCount,
@@ -233,7 +259,7 @@ export class MaterialSchema {
233
259
  }
234
260
  }
235
261
 
236
- export interface StateSchemaData {
262
+ export interface StateSchemaData extends SchemaBaseData {
237
263
  pressure: number;
238
264
  temperature: number;
239
265
  liquidFraction: number;
@@ -247,25 +273,26 @@ export interface StateSchemaData {
247
273
  * Description: Description of the fluid state.
248
274
  * ================================================================================
249
275
  */
250
- export class StateSchema {
251
- schema: Joi.ObjectSchema;
252
- propertyTypes: Record<string, unknown>;
253
-
276
+ export class StateSchema extends SchemaBase<StateSchemaData> {
254
277
  constructor() {
255
- this.schema = Joi.object({
256
- pressure: Joi.number().unsafe(),
257
- temperature: Joi.number().unsafe(),
258
- liquidFraction: Joi.number().unsafe(),
259
- flashFlag: Joi.string().valid(...Object.values(Enums.FluidSpec)),
260
- mixtureModelling: Joi.string().valid(...Object.values(Enums.MixtureModelling)),
261
- })
262
- .pattern(
263
- ignoredPropertiesRegex,
264
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
265
- )
266
- .unknown(false);
278
+ super();
279
+ this.schema = this.schema.concat(
280
+ Joi.object({
281
+ pressure: Joi.number().unsafe(),
282
+ temperature: Joi.number().unsafe(),
283
+ liquidFraction: Joi.number().unsafe(),
284
+ flashFlag: Joi.string().valid(...Object.values(Enums.FluidSpec)),
285
+ mixtureModelling: Joi.string().valid(...Object.values(Enums.MixtureModelling)),
286
+ })
287
+ )
288
+ .pattern(
289
+ ignoredPropertiesRegex,
290
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
291
+ )
292
+ .unknown(false);
267
293
 
268
294
  this.propertyTypes = {
295
+ ...this.propertyTypes,
269
296
  pressure: "number",
270
297
  temperature: "number",
271
298
  liquidFraction: "number",
@@ -274,16 +301,11 @@ export class StateSchema {
274
301
  };
275
302
  }
276
303
 
277
- validate(data: StateSchemaData): Entities.State {
278
- const { error, value } = this.schema.validate(data, { abortEarly: false });
279
- if (error) {
280
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
281
- }
282
- return this.makeEntity(value);
283
- }
284
-
285
304
  makeEntity(data: StateSchemaData): Entities.State {
286
305
  return new Entities.State(
306
+ data.id,
307
+ data.typeId,
308
+ data.displayName,
287
309
  data.pressure,
288
310
  data.temperature,
289
311
  data.liquidFraction,
@@ -293,7 +315,7 @@ export class StateSchema {
293
315
  }
294
316
  }
295
317
 
296
- export interface AtmosphericStorageTankSchemaData {
318
+ export interface AtmosphericStorageTankSchemaData extends SchemaBaseData {
297
319
  location: Entities.LocalPosition;
298
320
  state: Entities.State;
299
321
  diameter: number;
@@ -308,26 +330,27 @@ export interface AtmosphericStorageTankSchemaData {
308
330
  * Description: An atmospheric storage tank asset to model events that involve releases from unpressurised containment.
309
331
  * ================================================================================
310
332
  */
311
- export class AtmosphericStorageTankSchema {
312
- schema: Joi.ObjectSchema;
313
- propertyTypes: Record<string, unknown>;
314
-
333
+ export class AtmosphericStorageTankSchema extends SchemaBase<AtmosphericStorageTankSchemaData> {
315
334
  constructor() {
316
- this.schema = Joi.object({
317
- location: new LocalPositionSchema().schema,
318
- state: new StateSchema().schema,
319
- diameter: Joi.number().unsafe(),
320
- height: Joi.number().unsafe(),
321
- material: new MaterialSchema().schema,
322
- liquidFillFractionByVolume: Joi.number().unsafe(),
323
- })
324
- .pattern(
325
- ignoredPropertiesRegex,
326
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
327
- )
328
- .unknown(false);
335
+ super();
336
+ this.schema = this.schema.concat(
337
+ Joi.object({
338
+ location: new LocalPositionSchema().schema,
339
+ state: new StateSchema().schema,
340
+ diameter: Joi.number().unsafe(),
341
+ height: Joi.number().unsafe(),
342
+ material: new MaterialSchema().schema,
343
+ liquidFillFractionByVolume: Joi.number().unsafe(),
344
+ })
345
+ )
346
+ .pattern(
347
+ ignoredPropertiesRegex,
348
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
349
+ )
350
+ .unknown(false);
329
351
 
330
352
  this.propertyTypes = {
353
+ ...this.propertyTypes,
331
354
  location: "LocalPosition",
332
355
  state: "State",
333
356
  diameter: "number",
@@ -337,16 +360,11 @@ export class AtmosphericStorageTankSchema {
337
360
  };
338
361
  }
339
362
 
340
- validate(data: AtmosphericStorageTankSchemaData): Entities.AtmosphericStorageTank {
341
- const { error, value } = this.schema.validate(data, { abortEarly: false });
342
- if (error) {
343
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
344
- }
345
- return this.makeEntity(value);
346
- }
347
-
348
363
  makeEntity(data: AtmosphericStorageTankSchemaData): Entities.AtmosphericStorageTank {
349
364
  return new Entities.AtmosphericStorageTank(
365
+ data.id,
366
+ data.typeId,
367
+ data.displayName,
350
368
  data.location,
351
369
  data.state,
352
370
  data.diameter,
@@ -357,7 +375,7 @@ export class AtmosphericStorageTankSchema {
357
375
  }
358
376
  }
359
377
 
360
- export interface BundSchemaData {
378
+ export interface BundSchemaData extends SchemaBaseData {
361
379
  bundHeight: number;
362
380
  bundDiameter: number;
363
381
  specifyBund: boolean;
@@ -369,39 +387,35 @@ export interface BundSchemaData {
369
387
  * Description: A bund entity used in the modelling of pool spreading and vaporisation.
370
388
  * ================================================================================
371
389
  */
372
- export class BundSchema {
373
- schema: Joi.ObjectSchema;
374
- propertyTypes: Record<string, unknown>;
375
-
390
+ export class BundSchema extends SchemaBase<BundSchemaData> {
376
391
  constructor() {
377
- this.schema = Joi.object({
378
- bundHeight: Joi.number().unsafe(),
379
- bundDiameter: Joi.number().unsafe(),
380
- specifyBund: Joi.boolean(),
381
- })
382
- .pattern(
383
- ignoredPropertiesRegex,
384
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
385
- )
386
- .unknown(false);
392
+ super();
393
+ this.schema = this.schema.concat(
394
+ Joi.object({
395
+ bundHeight: Joi.number().unsafe(),
396
+ bundDiameter: Joi.number().unsafe(),
397
+ specifyBund: Joi.boolean(),
398
+ })
399
+ )
400
+ .pattern(
401
+ ignoredPropertiesRegex,
402
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
403
+ )
404
+ .unknown(false);
387
405
 
388
406
  this.propertyTypes = {
407
+ ...this.propertyTypes,
389
408
  bundHeight: "number",
390
409
  bundDiameter: "number",
391
410
  specifyBund: "boolean",
392
411
  };
393
412
  }
394
413
 
395
- validate(data: BundSchemaData): Entities.Bund {
396
- const { error, value } = this.schema.validate(data, { abortEarly: false });
397
- if (error) {
398
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
399
- }
400
- return this.makeEntity(value);
401
- }
402
-
403
414
  makeEntity(data: BundSchemaData): Entities.Bund {
404
415
  return new Entities.Bund(
416
+ data.id,
417
+ data.typeId,
418
+ data.displayName,
405
419
  data.bundHeight,
406
420
  data.bundDiameter,
407
421
  data.specifyBund
@@ -409,7 +423,7 @@ export class BundSchema {
409
423
  }
410
424
  }
411
425
 
412
- export interface ScenarioSchemaData {}
426
+ export interface ScenarioSchemaData extends SchemaBaseData {}
413
427
 
414
428
  /**
415
429
  * ================================================================================
@@ -417,35 +431,31 @@ export interface ScenarioSchemaData {}
417
431
  * Description: Base struct/class for all scenario types.
418
432
  * ================================================================================
419
433
  */
420
- export class ScenarioSchema {
421
- schema: Joi.ObjectSchema;
422
- propertyTypes: Record<string, unknown>;
423
-
434
+ export class ScenarioSchema extends SchemaBase<ScenarioSchemaData> {
424
435
  constructor() {
425
- this.schema = Joi.object()
426
- .pattern(
427
- ignoredPropertiesRegex,
428
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
429
- )
430
- .unknown(false);
436
+ super();
437
+ this.schema = this.schema.concat(
438
+ Joi.object()
439
+ )
440
+ .pattern(
441
+ ignoredPropertiesRegex,
442
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
443
+ )
444
+ .unknown(false);
431
445
 
432
- this.propertyTypes = {};
433
- }
434
-
435
- validate(data: ScenarioSchemaData): Entities.Scenario {
436
- const { error } = this.schema.validate(data, { abortEarly: false });
437
- if (error) {
438
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
439
- }
440
- return this.makeEntity();
446
+ this.propertyTypes = {
447
+ ...this.propertyTypes,};
441
448
  }
442
449
 
443
- makeEntity(): Entities.Scenario {
444
- return new Entities.Scenario();
450
+ makeEntity(data: ScenarioSchemaData): Entities.Scenario {
451
+ return new Entities.Scenario(
452
+ data.id,
453
+ data.typeId,
454
+ data.displayName,);
445
455
  }
446
456
  }
447
457
 
448
- export interface InstantaneousSchemaData {}
458
+ export interface InstantaneousSchemaData extends SchemaBaseData {}
449
459
 
450
460
  /**
451
461
  * ================================================================================
@@ -453,35 +463,31 @@ export interface InstantaneousSchemaData {}
453
463
  * Description: Base struct/class for instantaneous release scenarios.
454
464
  * ================================================================================
455
465
  */
456
- export class InstantaneousSchema {
457
- schema: Joi.ObjectSchema;
458
- propertyTypes: Record<string, unknown>;
459
-
466
+ export class InstantaneousSchema extends SchemaBase<InstantaneousSchemaData> {
460
467
  constructor() {
461
- this.schema = Joi.object()
462
- .pattern(
463
- ignoredPropertiesRegex,
464
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
465
- )
466
- .unknown(false);
467
-
468
- this.propertyTypes = {};
469
- }
468
+ super();
469
+ this.schema = this.schema.concat(
470
+ Joi.object()
471
+ )
472
+ .pattern(
473
+ ignoredPropertiesRegex,
474
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
475
+ )
476
+ .unknown(false);
470
477
 
471
- validate(data: InstantaneousSchemaData): Entities.Instantaneous {
472
- const { error } = this.schema.validate(data, { abortEarly: false });
473
- if (error) {
474
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
475
- }
476
- return this.makeEntity();
478
+ this.propertyTypes = {
479
+ ...this.propertyTypes,};
477
480
  }
478
481
 
479
- makeEntity(): Entities.Instantaneous {
480
- return new Entities.Instantaneous();
482
+ makeEntity(data: InstantaneousSchemaData): Entities.Instantaneous {
483
+ return new Entities.Instantaneous(
484
+ data.id,
485
+ data.typeId,
486
+ data.displayName,);
481
487
  }
482
488
  }
483
489
 
484
- export interface CatastrophicRuptureSchemaData {}
490
+ export interface CatastrophicRuptureSchemaData extends SchemaBaseData {}
485
491
 
486
492
  /**
487
493
  * ================================================================================
@@ -489,35 +495,31 @@ export interface CatastrophicRuptureSchemaData {}
489
495
  * Description: An instanaeous release of the entire inventory of an associated vessel, intended to model an incident in which the vessel is destroyed by an impact, a crack, or some other failure which propagates very quickly.
490
496
  * ================================================================================
491
497
  */
492
- export class CatastrophicRuptureSchema {
493
- schema: Joi.ObjectSchema;
494
- propertyTypes: Record<string, unknown>;
495
-
498
+ export class CatastrophicRuptureSchema extends SchemaBase<CatastrophicRuptureSchemaData> {
496
499
  constructor() {
497
- this.schema = Joi.object()
498
- .pattern(
499
- ignoredPropertiesRegex,
500
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
501
- )
502
- .unknown(false);
503
-
504
- this.propertyTypes = {};
505
- }
500
+ super();
501
+ this.schema = this.schema.concat(
502
+ Joi.object()
503
+ )
504
+ .pattern(
505
+ ignoredPropertiesRegex,
506
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
507
+ )
508
+ .unknown(false);
506
509
 
507
- validate(data: CatastrophicRuptureSchemaData): Entities.CatastrophicRupture {
508
- const { error } = this.schema.validate(data, { abortEarly: false });
509
- if (error) {
510
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
511
- }
512
- return this.makeEntity();
510
+ this.propertyTypes = {
511
+ ...this.propertyTypes,};
513
512
  }
514
513
 
515
- makeEntity(): Entities.CatastrophicRupture {
516
- return new Entities.CatastrophicRupture();
514
+ makeEntity(data: CatastrophicRuptureSchemaData): Entities.CatastrophicRupture {
515
+ return new Entities.CatastrophicRupture(
516
+ data.id,
517
+ data.typeId,
518
+ data.displayName,);
517
519
  }
518
520
  }
519
521
 
520
- export interface ConcentrationRecordSchemaData {
522
+ export interface ConcentrationRecordSchemaData extends SchemaBaseData {
521
523
  concentration: number;
522
524
  position: Entities.LocalPosition;
523
525
  }
@@ -528,44 +530,40 @@ export interface ConcentrationRecordSchemaData {
528
530
  * Description: A record containing the cloud concentration at a specified x, y, z position.
529
531
  * ================================================================================
530
532
  */
531
- export class ConcentrationRecordSchema {
532
- schema: Joi.ObjectSchema;
533
- propertyTypes: Record<string, unknown>;
534
-
533
+ export class ConcentrationRecordSchema extends SchemaBase<ConcentrationRecordSchemaData> {
535
534
  constructor() {
536
- this.schema = Joi.object({
537
- concentration: Joi.number().unsafe(),
538
- position: new LocalPositionSchema().schema,
539
- })
540
- .pattern(
541
- ignoredPropertiesRegex,
542
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
543
- )
544
- .unknown(false);
535
+ super();
536
+ this.schema = this.schema.concat(
537
+ Joi.object({
538
+ concentration: Joi.number().unsafe(),
539
+ position: new LocalPositionSchema().schema,
540
+ })
541
+ )
542
+ .pattern(
543
+ ignoredPropertiesRegex,
544
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
545
+ )
546
+ .unknown(false);
545
547
 
546
548
  this.propertyTypes = {
549
+ ...this.propertyTypes,
547
550
  concentration: "number",
548
551
  position: "LocalPosition",
549
552
  };
550
553
  }
551
554
 
552
- validate(data: ConcentrationRecordSchemaData): Entities.ConcentrationRecord {
553
- const { error, value } = this.schema.validate(data, { abortEarly: false });
554
- if (error) {
555
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
556
- }
557
- return this.makeEntity(value);
558
- }
559
-
560
555
  makeEntity(data: ConcentrationRecordSchemaData): Entities.ConcentrationRecord {
561
556
  return new Entities.ConcentrationRecord(
557
+ data.id,
558
+ data.typeId,
559
+ data.displayName,
562
560
  data.concentration,
563
561
  data.position
564
562
  );
565
563
  }
566
564
  }
567
565
 
568
- export interface ConstantMaterialResultSchemaData {
566
+ export interface ConstantMaterialResultSchemaData extends SchemaBaseData {
569
567
  criticalPressure: number;
570
568
  criticalTemperature: number;
571
569
  totalMolecularWeight: number;
@@ -577,39 +575,35 @@ export interface ConstantMaterialResultSchemaData {
577
575
  * Description: Constant material properties, i.e. critical pressure, temperature, molecular weight
578
576
  * ================================================================================
579
577
  */
580
- export class ConstantMaterialResultSchema {
581
- schema: Joi.ObjectSchema;
582
- propertyTypes: Record<string, unknown>;
583
-
578
+ export class ConstantMaterialResultSchema extends SchemaBase<ConstantMaterialResultSchemaData> {
584
579
  constructor() {
585
- this.schema = Joi.object({
586
- criticalPressure: Joi.number().unsafe(),
587
- criticalTemperature: Joi.number().unsafe(),
588
- totalMolecularWeight: Joi.number().unsafe(),
589
- })
590
- .pattern(
591
- ignoredPropertiesRegex,
592
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
593
- )
594
- .unknown(false);
580
+ super();
581
+ this.schema = this.schema.concat(
582
+ Joi.object({
583
+ criticalPressure: Joi.number().unsafe(),
584
+ criticalTemperature: Joi.number().unsafe(),
585
+ totalMolecularWeight: Joi.number().unsafe(),
586
+ })
587
+ )
588
+ .pattern(
589
+ ignoredPropertiesRegex,
590
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
591
+ )
592
+ .unknown(false);
595
593
 
596
594
  this.propertyTypes = {
595
+ ...this.propertyTypes,
597
596
  criticalPressure: "number",
598
597
  criticalTemperature: "number",
599
598
  totalMolecularWeight: "number",
600
599
  };
601
600
  }
602
601
 
603
- validate(data: ConstantMaterialResultSchemaData): Entities.ConstantMaterialResult {
604
- const { error, value } = this.schema.validate(data, { abortEarly: false });
605
- if (error) {
606
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
607
- }
608
- return this.makeEntity(value);
609
- }
610
-
611
602
  makeEntity(data: ConstantMaterialResultSchemaData): Entities.ConstantMaterialResult {
612
603
  return new Entities.ConstantMaterialResult(
604
+ data.id,
605
+ data.typeId,
606
+ data.displayName,
613
607
  data.criticalPressure,
614
608
  data.criticalTemperature,
615
609
  data.totalMolecularWeight
@@ -617,7 +611,7 @@ export class ConstantMaterialResultSchema {
617
611
  }
618
612
  }
619
613
 
620
- export interface DischargeParametersSchemaData {
614
+ export interface DischargeParametersSchemaData extends SchemaBaseData {
621
615
  flashAtOrifice: Enums.FlashAtOrifice;
622
616
  }
623
617
 
@@ -627,41 +621,37 @@ export interface DischargeParametersSchemaData {
627
621
  * Description: A set of parameters used in discharge calculations.
628
622
  * ================================================================================
629
623
  */
630
- export class DischargeParametersSchema {
631
- schema: Joi.ObjectSchema;
632
- propertyTypes: Record<string, unknown>;
633
-
624
+ export class DischargeParametersSchema extends SchemaBase<DischargeParametersSchemaData> {
634
625
  constructor() {
635
- this.schema = Joi.object({
636
- flashAtOrifice: Joi.string().valid(...Object.values(Enums.FlashAtOrifice)),
637
- })
638
- .pattern(
639
- ignoredPropertiesRegex,
640
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
641
- )
642
- .unknown(false);
626
+ super();
627
+ this.schema = this.schema.concat(
628
+ Joi.object({
629
+ flashAtOrifice: Joi.string().valid(...Object.values(Enums.FlashAtOrifice)),
630
+ })
631
+ )
632
+ .pattern(
633
+ ignoredPropertiesRegex,
634
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
635
+ )
636
+ .unknown(false);
643
637
 
644
638
  this.propertyTypes = {
639
+ ...this.propertyTypes,
645
640
  flashAtOrifice: "Enums.FlashAtOrifice",
646
641
  };
647
642
  }
648
643
 
649
- validate(data: DischargeParametersSchemaData): Entities.DischargeParameters {
650
- const { error, value } = this.schema.validate(data, { abortEarly: false });
651
- if (error) {
652
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
653
- }
654
- return this.makeEntity(value);
655
- }
656
-
657
644
  makeEntity(data: DischargeParametersSchemaData): Entities.DischargeParameters {
658
645
  return new Entities.DischargeParameters(
646
+ data.id,
647
+ data.typeId,
648
+ data.displayName,
659
649
  data.flashAtOrifice
660
650
  );
661
651
  }
662
652
  }
663
653
 
664
- export interface DischargeRecordSchemaData {
654
+ export interface DischargeRecordSchemaData extends SchemaBaseData {
665
655
  time: number;
666
656
  massFlow: number;
667
657
  finalState: Entities.State;
@@ -679,29 +669,30 @@ export interface DischargeRecordSchemaData {
679
669
  * Description: A record containing discharge results at a given time.
680
670
  * ================================================================================
681
671
  */
682
- export class DischargeRecordSchema {
683
- schema: Joi.ObjectSchema;
684
- propertyTypes: Record<string, unknown>;
685
-
672
+ export class DischargeRecordSchema extends SchemaBase<DischargeRecordSchemaData> {
686
673
  constructor() {
687
- this.schema = Joi.object({
688
- time: Joi.number().unsafe(),
689
- massFlow: Joi.number().unsafe(),
690
- finalState: new StateSchema().schema,
691
- finalVelocity: Joi.number().unsafe(),
692
- orificeState: new StateSchema().schema,
693
- orificeVelocity: Joi.number().unsafe(),
694
- storageState: new StateSchema().schema,
695
- dropletDiameter: Joi.number().unsafe(),
696
- expandedDiameter: Joi.number().unsafe(),
697
- })
698
- .pattern(
699
- ignoredPropertiesRegex,
700
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
701
- )
702
- .unknown(false);
674
+ super();
675
+ this.schema = this.schema.concat(
676
+ Joi.object({
677
+ time: Joi.number().unsafe(),
678
+ massFlow: Joi.number().unsafe(),
679
+ finalState: new StateSchema().schema,
680
+ finalVelocity: Joi.number().unsafe(),
681
+ orificeState: new StateSchema().schema,
682
+ orificeVelocity: Joi.number().unsafe(),
683
+ storageState: new StateSchema().schema,
684
+ dropletDiameter: Joi.number().unsafe(),
685
+ expandedDiameter: Joi.number().unsafe(),
686
+ })
687
+ )
688
+ .pattern(
689
+ ignoredPropertiesRegex,
690
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
691
+ )
692
+ .unknown(false);
703
693
 
704
694
  this.propertyTypes = {
695
+ ...this.propertyTypes,
705
696
  time: "number",
706
697
  massFlow: "number",
707
698
  finalState: "State",
@@ -714,16 +705,11 @@ export class DischargeRecordSchema {
714
705
  };
715
706
  }
716
707
 
717
- validate(data: DischargeRecordSchemaData): Entities.DischargeRecord {
718
- const { error, value } = this.schema.validate(data, { abortEarly: false });
719
- if (error) {
720
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
721
- }
722
- return this.makeEntity(value);
723
- }
724
-
725
708
  makeEntity(data: DischargeRecordSchemaData): Entities.DischargeRecord {
726
709
  return new Entities.DischargeRecord(
710
+ data.id,
711
+ data.typeId,
712
+ data.displayName,
727
713
  data.time,
728
714
  data.massFlow,
729
715
  data.finalState,
@@ -737,7 +723,7 @@ export class DischargeRecordSchema {
737
723
  }
738
724
  }
739
725
 
740
- export interface DischargeResultSchemaData {
726
+ export interface DischargeResultSchemaData extends SchemaBaseData {
741
727
  expansionEnergy: number;
742
728
  releaseMass: number;
743
729
  height: number;
@@ -753,27 +739,28 @@ export interface DischargeResultSchemaData {
753
739
  * Description: A set of discharge results that do not vary with time.
754
740
  * ================================================================================
755
741
  */
756
- export class DischargeResultSchema {
757
- schema: Joi.ObjectSchema;
758
- propertyTypes: Record<string, unknown>;
759
-
742
+ export class DischargeResultSchema extends SchemaBase<DischargeResultSchemaData> {
760
743
  constructor() {
761
- this.schema = Joi.object({
762
- expansionEnergy: Joi.number().unsafe(),
763
- releaseMass: Joi.number().unsafe(),
764
- height: Joi.number().unsafe(),
765
- angle: Joi.number().unsafe(),
766
- holeDiameter: Joi.number().unsafe(),
767
- releaseType: Joi.string().valid(...Object.values(Enums.DynamicType)),
768
- preDilutionAirRate: Joi.number().unsafe(),
769
- })
770
- .pattern(
771
- ignoredPropertiesRegex,
772
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
773
- )
774
- .unknown(false);
744
+ super();
745
+ this.schema = this.schema.concat(
746
+ Joi.object({
747
+ expansionEnergy: Joi.number().unsafe(),
748
+ releaseMass: Joi.number().unsafe(),
749
+ height: Joi.number().unsafe(),
750
+ angle: Joi.number().unsafe(),
751
+ holeDiameter: Joi.number().unsafe(),
752
+ releaseType: Joi.string().valid(...Object.values(Enums.DynamicType)),
753
+ preDilutionAirRate: Joi.number().unsafe(),
754
+ })
755
+ )
756
+ .pattern(
757
+ ignoredPropertiesRegex,
758
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
759
+ )
760
+ .unknown(false);
775
761
 
776
762
  this.propertyTypes = {
763
+ ...this.propertyTypes,
777
764
  expansionEnergy: "number",
778
765
  releaseMass: "number",
779
766
  height: "number",
@@ -784,16 +771,11 @@ export class DischargeResultSchema {
784
771
  };
785
772
  }
786
773
 
787
- validate(data: DischargeResultSchemaData): Entities.DischargeResult {
788
- const { error, value } = this.schema.validate(data, { abortEarly: false });
789
- if (error) {
790
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
791
- }
792
- return this.makeEntity(value);
793
- }
794
-
795
774
  makeEntity(data: DischargeResultSchemaData): Entities.DischargeResult {
796
775
  return new Entities.DischargeResult(
776
+ data.id,
777
+ data.typeId,
778
+ data.displayName,
797
779
  data.expansionEnergy,
798
780
  data.releaseMass,
799
781
  data.height,
@@ -805,7 +787,7 @@ export class DischargeResultSchema {
805
787
  }
806
788
  }
807
789
 
808
- export interface DispersionOutputConfigSchemaData {
790
+ export interface DispersionOutputConfigSchemaData extends SchemaBaseData {
809
791
  downwindDistance: number;
810
792
  time: number;
811
793
  resolution: Enums.Resolution;
@@ -825,31 +807,32 @@ export interface DispersionOutputConfigSchemaData {
825
807
  * Description: Dispersion plotting and reporting parameters.
826
808
  * ================================================================================
827
809
  */
828
- export class DispersionOutputConfigSchema {
829
- schema: Joi.ObjectSchema;
830
- propertyTypes: Record<string, unknown>;
831
-
810
+ export class DispersionOutputConfigSchema extends SchemaBase<DispersionOutputConfigSchemaData> {
832
811
  constructor() {
833
- this.schema = Joi.object({
834
- downwindDistance: Joi.number().unsafe(),
835
- time: Joi.number().unsafe(),
836
- resolution: Joi.string().valid(...Object.values(Enums.Resolution)),
837
- elevation: Joi.number().unsafe(),
838
- specialConcentration: Joi.string().valid(...Object.values(Enums.SpecialConcentration)),
839
- concentration: Joi.number().unsafe(),
840
- crosswindDistance: Joi.number().unsafe(),
841
- contourType: Joi.string().valid(...Object.values(Enums.ContourType)),
842
- lflFractionValue: Joi.number().unsafe(),
843
- componentToTrackIndex: Joi.number().integer(),
844
- componentToTrackName: Joi.string().allow(""),
845
- })
846
- .pattern(
847
- ignoredPropertiesRegex,
848
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
849
- )
850
- .unknown(false);
812
+ super();
813
+ this.schema = this.schema.concat(
814
+ Joi.object({
815
+ downwindDistance: Joi.number().unsafe(),
816
+ time: Joi.number().unsafe(),
817
+ resolution: Joi.string().valid(...Object.values(Enums.Resolution)),
818
+ elevation: Joi.number().unsafe(),
819
+ specialConcentration: Joi.string().valid(...Object.values(Enums.SpecialConcentration)),
820
+ concentration: Joi.number().unsafe(),
821
+ crosswindDistance: Joi.number().unsafe(),
822
+ contourType: Joi.string().valid(...Object.values(Enums.ContourType)),
823
+ lflFractionValue: Joi.number().unsafe(),
824
+ componentToTrackIndex: Joi.number().integer(),
825
+ componentToTrackName: Joi.string().allow(""),
826
+ })
827
+ )
828
+ .pattern(
829
+ ignoredPropertiesRegex,
830
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
831
+ )
832
+ .unknown(false);
851
833
 
852
834
  this.propertyTypes = {
835
+ ...this.propertyTypes,
853
836
  downwindDistance: "number",
854
837
  time: "number",
855
838
  resolution: "Enums.Resolution",
@@ -864,16 +847,11 @@ export class DispersionOutputConfigSchema {
864
847
  };
865
848
  }
866
849
 
867
- validate(data: DispersionOutputConfigSchemaData): Entities.DispersionOutputConfig {
868
- const { error, value } = this.schema.validate(data, { abortEarly: false });
869
- if (error) {
870
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
871
- }
872
- return this.makeEntity(value);
873
- }
874
-
875
850
  makeEntity(data: DispersionOutputConfigSchemaData): Entities.DispersionOutputConfig {
876
851
  return new Entities.DispersionOutputConfig(
852
+ data.id,
853
+ data.typeId,
854
+ data.displayName,
877
855
  data.downwindDistance,
878
856
  data.time,
879
857
  data.resolution,
@@ -889,7 +867,7 @@ export class DispersionOutputConfigSchema {
889
867
  }
890
868
  }
891
869
 
892
- export interface DispersionParametersSchemaData {
870
+ export interface DispersionParametersSchemaData extends SchemaBaseData {
893
871
  relativeTolerance: number;
894
872
  rainoutThermoFlag: Enums.RainoutThermoFlag;
895
873
  fixedStepSize: number;
@@ -908,30 +886,31 @@ export interface DispersionParametersSchemaData {
908
886
  * Description: A set of parameters used in dispersion calculations.
909
887
  * ================================================================================
910
888
  */
911
- export class DispersionParametersSchema {
912
- schema: Joi.ObjectSchema;
913
- propertyTypes: Record<string, unknown>;
914
-
889
+ export class DispersionParametersSchema extends SchemaBase<DispersionParametersSchemaData> {
915
890
  constructor() {
916
- this.schema = Joi.object({
917
- relativeTolerance: Joi.number().unsafe(),
918
- rainoutThermoFlag: Joi.string().valid(...Object.values(Enums.RainoutThermoFlag)),
919
- fixedStepSize: Joi.number().unsafe(),
920
- outputStepMultiplier: Joi.number().unsafe(),
921
- maxDispersionDistance: Joi.number().unsafe(),
922
- maxDispersionHeight: Joi.number().unsafe(),
923
- numberOfReleaseObservers: Joi.number().integer(),
924
- numberOfPoolObservers: Joi.number().integer(),
925
- averagingTime: Joi.number().unsafe(),
926
- lflFractionToStop: Joi.number().unsafe(),
927
- })
928
- .pattern(
929
- ignoredPropertiesRegex,
930
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
931
- )
932
- .unknown(false);
891
+ super();
892
+ this.schema = this.schema.concat(
893
+ Joi.object({
894
+ relativeTolerance: Joi.number().unsafe(),
895
+ rainoutThermoFlag: Joi.string().valid(...Object.values(Enums.RainoutThermoFlag)),
896
+ fixedStepSize: Joi.number().unsafe(),
897
+ outputStepMultiplier: Joi.number().unsafe(),
898
+ maxDispersionDistance: Joi.number().unsafe(),
899
+ maxDispersionHeight: Joi.number().unsafe(),
900
+ numberOfReleaseObservers: Joi.number().integer(),
901
+ numberOfPoolObservers: Joi.number().integer(),
902
+ averagingTime: Joi.number().unsafe(),
903
+ lflFractionToStop: Joi.number().unsafe(),
904
+ })
905
+ )
906
+ .pattern(
907
+ ignoredPropertiesRegex,
908
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
909
+ )
910
+ .unknown(false);
933
911
 
934
912
  this.propertyTypes = {
913
+ ...this.propertyTypes,
935
914
  relativeTolerance: "number",
936
915
  rainoutThermoFlag: "Enums.RainoutThermoFlag",
937
916
  fixedStepSize: "number",
@@ -945,16 +924,11 @@ export class DispersionParametersSchema {
945
924
  };
946
925
  }
947
926
 
948
- validate(data: DispersionParametersSchemaData): Entities.DispersionParameters {
949
- const { error, value } = this.schema.validate(data, { abortEarly: false });
950
- if (error) {
951
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
952
- }
953
- return this.makeEntity(value);
954
- }
955
-
956
927
  makeEntity(data: DispersionParametersSchemaData): Entities.DispersionParameters {
957
928
  return new Entities.DispersionParameters(
929
+ data.id,
930
+ data.typeId,
931
+ data.displayName,
958
932
  data.relativeTolerance,
959
933
  data.rainoutThermoFlag,
960
934
  data.fixedStepSize,
@@ -969,7 +943,7 @@ export class DispersionParametersSchema {
969
943
  }
970
944
  }
971
945
 
972
- export interface DispersionRecordSchemaData {
946
+ export interface DispersionRecordSchemaData extends SchemaBaseData {
973
947
  observerIndex: number;
974
948
  centrelineConcentration: number;
975
949
  downwindDistance: number;
@@ -1007,49 +981,50 @@ export interface DispersionRecordSchemaData {
1007
981
  * Description: A record containing observer dispersion results at a given time.
1008
982
  * ================================================================================
1009
983
  */
1010
- export class DispersionRecordSchema {
1011
- schema: Joi.ObjectSchema;
1012
- propertyTypes: Record<string, unknown>;
1013
-
984
+ export class DispersionRecordSchema extends SchemaBase<DispersionRecordSchemaData> {
1014
985
  constructor() {
1015
- this.schema = Joi.object({
1016
- observerIndex: Joi.number().integer(),
1017
- centrelineConcentration: Joi.number().unsafe(),
1018
- downwindDistance: Joi.number().unsafe(),
1019
- time: Joi.number().unsafe(),
1020
- centrelineConcentrationUncorrected: Joi.number().unsafe(),
1021
- crosswindRadius: Joi.number().unsafe(),
1022
- verticalRadius: Joi.number().unsafe(),
1023
- crosswindExponent: Joi.number().unsafe(),
1024
- verticalExponent: Joi.number().unsafe(),
1025
- theta: Joi.number().unsafe(),
1026
- centrelineHeight: Joi.number().unsafe(),
1027
- liquidFraction: Joi.number().unsafe(),
1028
- vapourTemperature: Joi.number().unsafe(),
1029
- massConc: Joi.number().unsafe(),
1030
- velocity: Joi.number().unsafe(),
1031
- massFlow: Joi.number().unsafe(),
1032
- profileFlag: Joi.number().integer(),
1033
- elevFlag: Joi.number().integer(),
1034
- rhoCloud: Joi.number().unsafe(),
1035
- liqTemp: Joi.number().unsafe(),
1036
- effectiveWidth: Joi.number().unsafe(),
1037
- effectiveHeight: Joi.number().unsafe(),
1038
- passTranDist: Joi.number().unsafe(),
1039
- downwindRadius: Joi.number().unsafe(),
1040
- dropletDiameter: Joi.number().unsafe(),
1041
- dropletHeight: Joi.number().unsafe(),
1042
- dropletDistance: Joi.number().unsafe(),
1043
- mass: Joi.number().unsafe(),
1044
- instCon: Joi.string().valid(...Object.values(Enums.DynamicType)),
1045
- })
1046
- .pattern(
1047
- ignoredPropertiesRegex,
1048
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1049
- )
1050
- .unknown(false);
986
+ super();
987
+ this.schema = this.schema.concat(
988
+ Joi.object({
989
+ observerIndex: Joi.number().integer(),
990
+ centrelineConcentration: Joi.number().unsafe(),
991
+ downwindDistance: Joi.number().unsafe(),
992
+ time: Joi.number().unsafe(),
993
+ centrelineConcentrationUncorrected: Joi.number().unsafe(),
994
+ crosswindRadius: Joi.number().unsafe(),
995
+ verticalRadius: Joi.number().unsafe(),
996
+ crosswindExponent: Joi.number().unsafe(),
997
+ verticalExponent: Joi.number().unsafe(),
998
+ theta: Joi.number().unsafe(),
999
+ centrelineHeight: Joi.number().unsafe(),
1000
+ liquidFraction: Joi.number().unsafe(),
1001
+ vapourTemperature: Joi.number().unsafe(),
1002
+ massConc: Joi.number().unsafe(),
1003
+ velocity: Joi.number().unsafe(),
1004
+ massFlow: Joi.number().unsafe(),
1005
+ profileFlag: Joi.number().integer(),
1006
+ elevFlag: Joi.number().integer(),
1007
+ rhoCloud: Joi.number().unsafe(),
1008
+ liqTemp: Joi.number().unsafe(),
1009
+ effectiveWidth: Joi.number().unsafe(),
1010
+ effectiveHeight: Joi.number().unsafe(),
1011
+ passTranDist: Joi.number().unsafe(),
1012
+ downwindRadius: Joi.number().unsafe(),
1013
+ dropletDiameter: Joi.number().unsafe(),
1014
+ dropletHeight: Joi.number().unsafe(),
1015
+ dropletDistance: Joi.number().unsafe(),
1016
+ mass: Joi.number().unsafe(),
1017
+ instCon: Joi.string().valid(...Object.values(Enums.DynamicType)),
1018
+ })
1019
+ )
1020
+ .pattern(
1021
+ ignoredPropertiesRegex,
1022
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1023
+ )
1024
+ .unknown(false);
1051
1025
 
1052
1026
  this.propertyTypes = {
1027
+ ...this.propertyTypes,
1053
1028
  observerIndex: "number",
1054
1029
  centrelineConcentration: "number",
1055
1030
  downwindDistance: "number",
@@ -1082,16 +1057,11 @@ export class DispersionRecordSchema {
1082
1057
  };
1083
1058
  }
1084
1059
 
1085
- validate(data: DispersionRecordSchemaData): Entities.DispersionRecord {
1086
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1087
- if (error) {
1088
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1089
- }
1090
- return this.makeEntity(value);
1091
- }
1092
-
1093
1060
  makeEntity(data: DispersionRecordSchemaData): Entities.DispersionRecord {
1094
1061
  return new Entities.DispersionRecord(
1062
+ data.id,
1063
+ data.typeId,
1064
+ data.displayName,
1095
1065
  data.observerIndex,
1096
1066
  data.centrelineConcentration,
1097
1067
  data.downwindDistance,
@@ -1125,7 +1095,7 @@ export class DispersionRecordSchema {
1125
1095
  }
1126
1096
  }
1127
1097
 
1128
- export interface ExplosionConfinedVolumeSchemaData {
1098
+ export interface ExplosionConfinedVolumeSchemaData extends SchemaBaseData {
1129
1099
  confinedStrength: number;
1130
1100
  confinedVolume: number;
1131
1101
  }
@@ -1136,44 +1106,40 @@ export interface ExplosionConfinedVolumeSchemaData {
1136
1106
  * Description: Confined explosion volume data.
1137
1107
  * ================================================================================
1138
1108
  */
1139
- export class ExplosionConfinedVolumeSchema {
1140
- schema: Joi.ObjectSchema;
1141
- propertyTypes: Record<string, unknown>;
1142
-
1109
+ export class ExplosionConfinedVolumeSchema extends SchemaBase<ExplosionConfinedVolumeSchemaData> {
1143
1110
  constructor() {
1144
- this.schema = Joi.object({
1145
- confinedStrength: Joi.number().unsafe(),
1146
- confinedVolume: Joi.number().unsafe(),
1147
- })
1148
- .pattern(
1149
- ignoredPropertiesRegex,
1150
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1151
- )
1152
- .unknown(false);
1111
+ super();
1112
+ this.schema = this.schema.concat(
1113
+ Joi.object({
1114
+ confinedStrength: Joi.number().unsafe(),
1115
+ confinedVolume: Joi.number().unsafe(),
1116
+ })
1117
+ )
1118
+ .pattern(
1119
+ ignoredPropertiesRegex,
1120
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1121
+ )
1122
+ .unknown(false);
1153
1123
 
1154
1124
  this.propertyTypes = {
1125
+ ...this.propertyTypes,
1155
1126
  confinedStrength: "number",
1156
1127
  confinedVolume: "number",
1157
1128
  };
1158
1129
  }
1159
1130
 
1160
- validate(data: ExplosionConfinedVolumeSchemaData): Entities.ExplosionConfinedVolume {
1161
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1162
- if (error) {
1163
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1164
- }
1165
- return this.makeEntity(value);
1166
- }
1167
-
1168
1131
  makeEntity(data: ExplosionConfinedVolumeSchemaData): Entities.ExplosionConfinedVolume {
1169
1132
  return new Entities.ExplosionConfinedVolume(
1133
+ data.id,
1134
+ data.typeId,
1135
+ data.displayName,
1170
1136
  data.confinedStrength,
1171
1137
  data.confinedVolume
1172
1138
  );
1173
1139
  }
1174
1140
  }
1175
1141
 
1176
- export interface ExplosionOutputConfigSchemaData {
1142
+ export interface ExplosionOutputConfigSchemaData extends SchemaBaseData {
1177
1143
  overpressureLevel: number;
1178
1144
  meConfinedMethod: Enums.MEConfinedMethod;
1179
1145
  }
@@ -1184,44 +1150,40 @@ export interface ExplosionOutputConfigSchemaData {
1184
1150
  * Description: Explosion plotting and reporting parameters.
1185
1151
  * ================================================================================
1186
1152
  */
1187
- export class ExplosionOutputConfigSchema {
1188
- schema: Joi.ObjectSchema;
1189
- propertyTypes: Record<string, unknown>;
1190
-
1153
+ export class ExplosionOutputConfigSchema extends SchemaBase<ExplosionOutputConfigSchemaData> {
1191
1154
  constructor() {
1192
- this.schema = Joi.object({
1193
- overpressureLevel: Joi.number().unsafe(),
1194
- meConfinedMethod: Joi.string().valid(...Object.values(Enums.MEConfinedMethod)),
1195
- })
1196
- .pattern(
1197
- ignoredPropertiesRegex,
1198
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1199
- )
1200
- .unknown(false);
1155
+ super();
1156
+ this.schema = this.schema.concat(
1157
+ Joi.object({
1158
+ overpressureLevel: Joi.number().unsafe(),
1159
+ meConfinedMethod: Joi.string().valid(...Object.values(Enums.MEConfinedMethod)),
1160
+ })
1161
+ )
1162
+ .pattern(
1163
+ ignoredPropertiesRegex,
1164
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1165
+ )
1166
+ .unknown(false);
1201
1167
 
1202
1168
  this.propertyTypes = {
1169
+ ...this.propertyTypes,
1203
1170
  overpressureLevel: "number",
1204
1171
  meConfinedMethod: "Enums.MEConfinedMethod",
1205
1172
  };
1206
1173
  }
1207
1174
 
1208
- validate(data: ExplosionOutputConfigSchemaData): Entities.ExplosionOutputConfig {
1209
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1210
- if (error) {
1211
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1212
- }
1213
- return this.makeEntity(value);
1214
- }
1215
-
1216
1175
  makeEntity(data: ExplosionOutputConfigSchemaData): Entities.ExplosionOutputConfig {
1217
1176
  return new Entities.ExplosionOutputConfig(
1177
+ data.id,
1178
+ data.typeId,
1179
+ data.displayName,
1218
1180
  data.overpressureLevel,
1219
1181
  data.meConfinedMethod
1220
1182
  );
1221
1183
  }
1222
1184
  }
1223
1185
 
1224
- export interface ExplosionOverpressureResultSchemaData {
1186
+ export interface ExplosionOverpressureResultSchemaData extends SchemaBaseData {
1225
1187
  overpressure: number;
1226
1188
  explosionCentre: number;
1227
1189
  maximumDistance: number;
@@ -1236,26 +1198,27 @@ export interface ExplosionOverpressureResultSchemaData {
1236
1198
  * Description: Worst case explosion summary results for a given overpressure.
1237
1199
  * ================================================================================
1238
1200
  */
1239
- export class ExplosionOverpressureResultSchema {
1240
- schema: Joi.ObjectSchema;
1241
- propertyTypes: Record<string, unknown>;
1242
-
1201
+ export class ExplosionOverpressureResultSchema extends SchemaBase<ExplosionOverpressureResultSchemaData> {
1243
1202
  constructor() {
1244
- this.schema = Joi.object({
1245
- overpressure: Joi.number().unsafe(),
1246
- explosionCentre: Joi.number().unsafe(),
1247
- maximumDistance: Joi.number().unsafe(),
1248
- explodedMass: Joi.number().unsafe(),
1249
- ignitionTime: Joi.number().unsafe(),
1250
- radius: Joi.number().unsafe(),
1251
- })
1252
- .pattern(
1253
- ignoredPropertiesRegex,
1254
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1255
- )
1256
- .unknown(false);
1203
+ super();
1204
+ this.schema = this.schema.concat(
1205
+ Joi.object({
1206
+ overpressure: Joi.number().unsafe(),
1207
+ explosionCentre: Joi.number().unsafe(),
1208
+ maximumDistance: Joi.number().unsafe(),
1209
+ explodedMass: Joi.number().unsafe(),
1210
+ ignitionTime: Joi.number().unsafe(),
1211
+ radius: Joi.number().unsafe(),
1212
+ })
1213
+ )
1214
+ .pattern(
1215
+ ignoredPropertiesRegex,
1216
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1217
+ )
1218
+ .unknown(false);
1257
1219
 
1258
1220
  this.propertyTypes = {
1221
+ ...this.propertyTypes,
1259
1222
  overpressure: "number",
1260
1223
  explosionCentre: "number",
1261
1224
  maximumDistance: "number",
@@ -1265,16 +1228,11 @@ export class ExplosionOverpressureResultSchema {
1265
1228
  };
1266
1229
  }
1267
1230
 
1268
- validate(data: ExplosionOverpressureResultSchemaData): Entities.ExplosionOverpressureResult {
1269
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1270
- if (error) {
1271
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1272
- }
1273
- return this.makeEntity(value);
1274
- }
1275
-
1276
1231
  makeEntity(data: ExplosionOverpressureResultSchemaData): Entities.ExplosionOverpressureResult {
1277
1232
  return new Entities.ExplosionOverpressureResult(
1233
+ data.id,
1234
+ data.typeId,
1235
+ data.displayName,
1278
1236
  data.overpressure,
1279
1237
  data.explosionCentre,
1280
1238
  data.maximumDistance,
@@ -1285,7 +1243,7 @@ export class ExplosionOverpressureResultSchema {
1285
1243
  }
1286
1244
  }
1287
1245
 
1288
- export interface ExplosionParametersSchemaData {
1246
+ export interface ExplosionParametersSchemaData extends SchemaBaseData {
1289
1247
  explosionUniformStrength: number;
1290
1248
  }
1291
1249
 
@@ -1295,41 +1253,37 @@ export interface ExplosionParametersSchemaData {
1295
1253
  * Description: A set of parameters used in explosion calculations.
1296
1254
  * ================================================================================
1297
1255
  */
1298
- export class ExplosionParametersSchema {
1299
- schema: Joi.ObjectSchema;
1300
- propertyTypes: Record<string, unknown>;
1301
-
1256
+ export class ExplosionParametersSchema extends SchemaBase<ExplosionParametersSchemaData> {
1302
1257
  constructor() {
1303
- this.schema = Joi.object({
1304
- explosionUniformStrength: Joi.number().unsafe(),
1305
- })
1306
- .pattern(
1307
- ignoredPropertiesRegex,
1308
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1309
- )
1310
- .unknown(false);
1258
+ super();
1259
+ this.schema = this.schema.concat(
1260
+ Joi.object({
1261
+ explosionUniformStrength: Joi.number().unsafe(),
1262
+ })
1263
+ )
1264
+ .pattern(
1265
+ ignoredPropertiesRegex,
1266
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1267
+ )
1268
+ .unknown(false);
1311
1269
 
1312
1270
  this.propertyTypes = {
1271
+ ...this.propertyTypes,
1313
1272
  explosionUniformStrength: "number",
1314
1273
  };
1315
1274
  }
1316
1275
 
1317
- validate(data: ExplosionParametersSchemaData): Entities.ExplosionParameters {
1318
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1319
- if (error) {
1320
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1321
- }
1322
- return this.makeEntity(value);
1323
- }
1324
-
1325
1276
  makeEntity(data: ExplosionParametersSchemaData): Entities.ExplosionParameters {
1326
1277
  return new Entities.ExplosionParameters(
1278
+ data.id,
1279
+ data.typeId,
1280
+ data.displayName,
1327
1281
  data.explosionUniformStrength
1328
1282
  );
1329
1283
  }
1330
1284
  }
1331
1285
 
1332
- export interface FlameRecordSchemaData {
1286
+ export interface FlameRecordSchemaData extends SchemaBaseData {
1333
1287
  xCoordinate: number;
1334
1288
  zCoordinate: number;
1335
1289
  rCoordinate: number;
@@ -1342,24 +1296,25 @@ export interface FlameRecordSchemaData {
1342
1296
  * Description: A record containing flame geometry data.
1343
1297
  * ================================================================================
1344
1298
  */
1345
- export class FlameRecordSchema {
1346
- schema: Joi.ObjectSchema;
1347
- propertyTypes: Record<string, unknown>;
1348
-
1299
+ export class FlameRecordSchema extends SchemaBase<FlameRecordSchemaData> {
1349
1300
  constructor() {
1350
- this.schema = Joi.object({
1351
- xCoordinate: Joi.number().unsafe(),
1352
- zCoordinate: Joi.number().unsafe(),
1353
- rCoordinate: Joi.number().unsafe(),
1354
- phiCoordinate: Joi.number().unsafe(),
1355
- })
1356
- .pattern(
1357
- ignoredPropertiesRegex,
1358
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1359
- )
1360
- .unknown(false);
1301
+ super();
1302
+ this.schema = this.schema.concat(
1303
+ Joi.object({
1304
+ xCoordinate: Joi.number().unsafe(),
1305
+ zCoordinate: Joi.number().unsafe(),
1306
+ rCoordinate: Joi.number().unsafe(),
1307
+ phiCoordinate: Joi.number().unsafe(),
1308
+ })
1309
+ )
1310
+ .pattern(
1311
+ ignoredPropertiesRegex,
1312
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1313
+ )
1314
+ .unknown(false);
1361
1315
 
1362
1316
  this.propertyTypes = {
1317
+ ...this.propertyTypes,
1363
1318
  xCoordinate: "number",
1364
1319
  zCoordinate: "number",
1365
1320
  rCoordinate: "number",
@@ -1367,16 +1322,11 @@ export class FlameRecordSchema {
1367
1322
  };
1368
1323
  }
1369
1324
 
1370
- validate(data: FlameRecordSchemaData): Entities.FlameRecord {
1371
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1372
- if (error) {
1373
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1374
- }
1375
- return this.makeEntity(value);
1376
- }
1377
-
1378
1325
  makeEntity(data: FlameRecordSchemaData): Entities.FlameRecord {
1379
1326
  return new Entities.FlameRecord(
1327
+ data.id,
1328
+ data.typeId,
1329
+ data.displayName,
1380
1330
  data.xCoordinate,
1381
1331
  data.zCoordinate,
1382
1332
  data.rCoordinate,
@@ -1385,7 +1335,7 @@ export class FlameRecordSchema {
1385
1335
  }
1386
1336
  }
1387
1337
 
1388
- export interface FlameResultSchemaData {
1338
+ export interface FlameResultSchemaData extends SchemaBaseData {
1389
1339
  time: number;
1390
1340
  surfaceEmissivePower: number;
1391
1341
  flameLength: number;
@@ -1399,25 +1349,26 @@ export interface FlameResultSchemaData {
1399
1349
  * Description: A set of flame results.
1400
1350
  * ================================================================================
1401
1351
  */
1402
- export class FlameResultSchema {
1403
- schema: Joi.ObjectSchema;
1404
- propertyTypes: Record<string, unknown>;
1405
-
1352
+ export class FlameResultSchema extends SchemaBase<FlameResultSchemaData> {
1406
1353
  constructor() {
1407
- this.schema = Joi.object({
1408
- time: Joi.number().unsafe(),
1409
- surfaceEmissivePower: Joi.number().unsafe(),
1410
- flameLength: Joi.number().unsafe(),
1411
- flameDiameter: Joi.number().unsafe(),
1412
- fireType: Joi.string().valid(...Object.values(Enums.FireType)),
1413
- })
1414
- .pattern(
1415
- ignoredPropertiesRegex,
1416
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1417
- )
1418
- .unknown(false);
1354
+ super();
1355
+ this.schema = this.schema.concat(
1356
+ Joi.object({
1357
+ time: Joi.number().unsafe(),
1358
+ surfaceEmissivePower: Joi.number().unsafe(),
1359
+ flameLength: Joi.number().unsafe(),
1360
+ flameDiameter: Joi.number().unsafe(),
1361
+ fireType: Joi.string().valid(...Object.values(Enums.FireType)),
1362
+ })
1363
+ )
1364
+ .pattern(
1365
+ ignoredPropertiesRegex,
1366
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1367
+ )
1368
+ .unknown(false);
1419
1369
 
1420
1370
  this.propertyTypes = {
1371
+ ...this.propertyTypes,
1421
1372
  time: "number",
1422
1373
  surfaceEmissivePower: "number",
1423
1374
  flameLength: "number",
@@ -1426,16 +1377,11 @@ export class FlameResultSchema {
1426
1377
  };
1427
1378
  }
1428
1379
 
1429
- validate(data: FlameResultSchemaData): Entities.FlameResult {
1430
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1431
- if (error) {
1432
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1433
- }
1434
- return this.makeEntity(value);
1435
- }
1436
-
1437
1380
  makeEntity(data: FlameResultSchemaData): Entities.FlameResult {
1438
1381
  return new Entities.FlameResult(
1382
+ data.id,
1383
+ data.typeId,
1384
+ data.displayName,
1439
1385
  data.time,
1440
1386
  data.surfaceEmissivePower,
1441
1387
  data.flameLength,
@@ -1445,7 +1391,7 @@ export class FlameResultSchema {
1445
1391
  }
1446
1392
  }
1447
1393
 
1448
- export interface TransectSchemaData {
1394
+ export interface TransectSchemaData extends SchemaBaseData {
1449
1395
  transectStartPoint: Entities.LocalPosition;
1450
1396
  transectEndPoint: Entities.LocalPosition;
1451
1397
  }
@@ -1456,44 +1402,40 @@ export interface TransectSchemaData {
1456
1402
  * Description: A line segment, along which results are provided.
1457
1403
  * ================================================================================
1458
1404
  */
1459
- export class TransectSchema {
1460
- schema: Joi.ObjectSchema;
1461
- propertyTypes: Record<string, unknown>;
1462
-
1405
+ export class TransectSchema extends SchemaBase<TransectSchemaData> {
1463
1406
  constructor() {
1464
- this.schema = Joi.object({
1465
- transectStartPoint: new LocalPositionSchema().schema,
1466
- transectEndPoint: new LocalPositionSchema().schema,
1467
- })
1468
- .pattern(
1469
- ignoredPropertiesRegex,
1470
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1471
- )
1472
- .unknown(false);
1407
+ super();
1408
+ this.schema = this.schema.concat(
1409
+ Joi.object({
1410
+ transectStartPoint: new LocalPositionSchema().schema,
1411
+ transectEndPoint: new LocalPositionSchema().schema,
1412
+ })
1413
+ )
1414
+ .pattern(
1415
+ ignoredPropertiesRegex,
1416
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1417
+ )
1418
+ .unknown(false);
1473
1419
 
1474
1420
  this.propertyTypes = {
1421
+ ...this.propertyTypes,
1475
1422
  transectStartPoint: "LocalPosition",
1476
1423
  transectEndPoint: "LocalPosition",
1477
1424
  };
1478
1425
  }
1479
1426
 
1480
- validate(data: TransectSchemaData): Entities.Transect {
1481
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1482
- if (error) {
1483
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1484
- }
1485
- return this.makeEntity(value);
1486
- }
1487
-
1488
1427
  makeEntity(data: TransectSchemaData): Entities.Transect {
1489
1428
  return new Entities.Transect(
1429
+ data.id,
1430
+ data.typeId,
1431
+ data.displayName,
1490
1432
  data.transectStartPoint,
1491
1433
  data.transectEndPoint
1492
1434
  );
1493
1435
  }
1494
1436
  }
1495
1437
 
1496
- export interface FlammableOutputConfigSchemaData {
1438
+ export interface FlammableOutputConfigSchemaData extends SchemaBaseData {
1497
1439
  position: Entities.LocalPosition;
1498
1440
  transect: Entities.Transect;
1499
1441
  radiationType: Enums.RadiationType;
@@ -1512,30 +1454,31 @@ export interface FlammableOutputConfigSchemaData {
1512
1454
  * Description: Fire and radiation plotting and reporting parameters.
1513
1455
  * ================================================================================
1514
1456
  */
1515
- export class FlammableOutputConfigSchema {
1516
- schema: Joi.ObjectSchema;
1517
- propertyTypes: Record<string, unknown>;
1518
-
1457
+ export class FlammableOutputConfigSchema extends SchemaBase<FlammableOutputConfigSchemaData> {
1519
1458
  constructor() {
1520
- this.schema = Joi.object({
1521
- position: new LocalPositionSchema().schema,
1522
- transect: new TransectSchema().schema,
1523
- radiationType: Joi.string().valid(...Object.values(Enums.RadiationType)),
1524
- contourType: Joi.string().valid(...Object.values(Enums.ContourType)),
1525
- radiationLevel: Joi.number().unsafe(),
1526
- radiationResolution: Joi.string().valid(...Object.values(Enums.Resolution)),
1527
- fixedOrientation: Joi.number().integer(),
1528
- orientation: Joi.number().unsafe(),
1529
- fixedInclination: Joi.number().integer(),
1530
- inclination: Joi.number().unsafe(),
1531
- })
1532
- .pattern(
1533
- ignoredPropertiesRegex,
1534
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1535
- )
1536
- .unknown(false);
1459
+ super();
1460
+ this.schema = this.schema.concat(
1461
+ Joi.object({
1462
+ position: new LocalPositionSchema().schema,
1463
+ transect: new TransectSchema().schema,
1464
+ radiationType: Joi.string().valid(...Object.values(Enums.RadiationType)),
1465
+ contourType: Joi.string().valid(...Object.values(Enums.ContourType)),
1466
+ radiationLevel: Joi.number().unsafe(),
1467
+ radiationResolution: Joi.string().valid(...Object.values(Enums.Resolution)),
1468
+ fixedOrientation: Joi.number().integer(),
1469
+ orientation: Joi.number().unsafe(),
1470
+ fixedInclination: Joi.number().integer(),
1471
+ inclination: Joi.number().unsafe(),
1472
+ })
1473
+ )
1474
+ .pattern(
1475
+ ignoredPropertiesRegex,
1476
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1477
+ )
1478
+ .unknown(false);
1537
1479
 
1538
1480
  this.propertyTypes = {
1481
+ ...this.propertyTypes,
1539
1482
  position: "LocalPosition",
1540
1483
  transect: "Transect",
1541
1484
  radiationType: "Enums.RadiationType",
@@ -1549,16 +1492,11 @@ export class FlammableOutputConfigSchema {
1549
1492
  };
1550
1493
  }
1551
1494
 
1552
- validate(data: FlammableOutputConfigSchemaData): Entities.FlammableOutputConfig {
1553
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1554
- if (error) {
1555
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1556
- }
1557
- return this.makeEntity(value);
1558
- }
1559
-
1560
1495
  makeEntity(data: FlammableOutputConfigSchemaData): Entities.FlammableOutputConfig {
1561
1496
  return new Entities.FlammableOutputConfig(
1497
+ data.id,
1498
+ data.typeId,
1499
+ data.displayName,
1562
1500
  data.position,
1563
1501
  data.transect,
1564
1502
  data.radiationType,
@@ -1573,7 +1511,7 @@ export class FlammableOutputConfigSchema {
1573
1511
  }
1574
1512
  }
1575
1513
 
1576
- export interface FlammableParametersSchemaData {
1514
+ export interface FlammableParametersSchemaData extends SchemaBaseData {
1577
1515
  maxExposureDuration: number;
1578
1516
  radiationRelativeTolerance: number;
1579
1517
  poolFireType: Enums.PoolFireType;
@@ -1588,26 +1526,27 @@ export interface FlammableParametersSchemaData {
1588
1526
  * Description: A set of parameters used in fire and radiation calculations.
1589
1527
  * ================================================================================
1590
1528
  */
1591
- export class FlammableParametersSchema {
1592
- schema: Joi.ObjectSchema;
1593
- propertyTypes: Record<string, unknown>;
1594
-
1529
+ export class FlammableParametersSchema extends SchemaBase<FlammableParametersSchemaData> {
1595
1530
  constructor() {
1596
- this.schema = Joi.object({
1597
- maxExposureDuration: Joi.number().unsafe(),
1598
- radiationRelativeTolerance: Joi.number().unsafe(),
1599
- poolFireType: Joi.string().valid(...Object.values(Enums.PoolFireType)),
1600
- jetFireAutoSelect: Joi.boolean(),
1601
- timeAveraging: Joi.boolean(),
1602
- timeOfInterest: Joi.number().unsafe(),
1603
- })
1604
- .pattern(
1605
- ignoredPropertiesRegex,
1606
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1607
- )
1608
- .unknown(false);
1531
+ super();
1532
+ this.schema = this.schema.concat(
1533
+ Joi.object({
1534
+ maxExposureDuration: Joi.number().unsafe(),
1535
+ radiationRelativeTolerance: Joi.number().unsafe(),
1536
+ poolFireType: Joi.string().valid(...Object.values(Enums.PoolFireType)),
1537
+ jetFireAutoSelect: Joi.boolean(),
1538
+ timeAveraging: Joi.boolean(),
1539
+ timeOfInterest: Joi.number().unsafe(),
1540
+ })
1541
+ )
1542
+ .pattern(
1543
+ ignoredPropertiesRegex,
1544
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1545
+ )
1546
+ .unknown(false);
1609
1547
 
1610
1548
  this.propertyTypes = {
1549
+ ...this.propertyTypes,
1611
1550
  maxExposureDuration: "number",
1612
1551
  radiationRelativeTolerance: "number",
1613
1552
  poolFireType: "Enums.PoolFireType",
@@ -1617,16 +1556,11 @@ export class FlammableParametersSchema {
1617
1556
  };
1618
1557
  }
1619
1558
 
1620
- validate(data: FlammableParametersSchemaData): Entities.FlammableParameters {
1621
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1622
- if (error) {
1623
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1624
- }
1625
- return this.makeEntity(value);
1626
- }
1627
-
1628
1559
  makeEntity(data: FlammableParametersSchemaData): Entities.FlammableParameters {
1629
1560
  return new Entities.FlammableParameters(
1561
+ data.id,
1562
+ data.typeId,
1563
+ data.displayName,
1630
1564
  data.maxExposureDuration,
1631
1565
  data.radiationRelativeTolerance,
1632
1566
  data.poolFireType,
@@ -1637,7 +1571,7 @@ export class FlammableParametersSchema {
1637
1571
  }
1638
1572
  }
1639
1573
 
1640
- export interface FlashResultSchemaData {
1574
+ export interface FlashResultSchemaData extends SchemaBaseData {
1641
1575
  pressure: number;
1642
1576
  temperature: number;
1643
1577
  liquidMoleFraction: number;
@@ -1662,36 +1596,37 @@ export interface FlashResultSchemaData {
1662
1596
  * Description: Physical properties for a material generated at a particular pressure and temperature.
1663
1597
  * ================================================================================
1664
1598
  */
1665
- export class FlashResultSchema {
1666
- schema: Joi.ObjectSchema;
1667
- propertyTypes: Record<string, unknown>;
1668
-
1599
+ export class FlashResultSchema extends SchemaBase<FlashResultSchemaData> {
1669
1600
  constructor() {
1670
- this.schema = Joi.object({
1671
- pressure: Joi.number().unsafe(),
1672
- temperature: Joi.number().unsafe(),
1673
- liquidMoleFraction: Joi.number().unsafe(),
1674
- liquidDensity: Joi.number().unsafe(),
1675
- vapourDensity: Joi.number().unsafe(),
1676
- liquidEntropy: Joi.number().unsafe(),
1677
- vapourEntropy: Joi.number().unsafe(),
1678
- liquidEnthalpy: Joi.number().unsafe(),
1679
- vapourEnthalpy: Joi.number().unsafe(),
1680
- bubblePointPressure: Joi.number().unsafe(),
1681
- bubblePointTemperature: Joi.number().unsafe(),
1682
- dewPointPressure: Joi.number().unsafe(),
1683
- dewPointTemperature: Joi.number().unsafe(),
1684
- totalFluidDensity: Joi.number().unsafe(),
1685
- liquidMassFraction: Joi.number().unsafe(),
1686
- fluidPhase: Joi.string().valid(...Object.values(Enums.Phase)),
1687
- })
1688
- .pattern(
1689
- ignoredPropertiesRegex,
1690
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1691
- )
1692
- .unknown(false);
1601
+ super();
1602
+ this.schema = this.schema.concat(
1603
+ Joi.object({
1604
+ pressure: Joi.number().unsafe(),
1605
+ temperature: Joi.number().unsafe(),
1606
+ liquidMoleFraction: Joi.number().unsafe(),
1607
+ liquidDensity: Joi.number().unsafe(),
1608
+ vapourDensity: Joi.number().unsafe(),
1609
+ liquidEntropy: Joi.number().unsafe(),
1610
+ vapourEntropy: Joi.number().unsafe(),
1611
+ liquidEnthalpy: Joi.number().unsafe(),
1612
+ vapourEnthalpy: Joi.number().unsafe(),
1613
+ bubblePointPressure: Joi.number().unsafe(),
1614
+ bubblePointTemperature: Joi.number().unsafe(),
1615
+ dewPointPressure: Joi.number().unsafe(),
1616
+ dewPointTemperature: Joi.number().unsafe(),
1617
+ totalFluidDensity: Joi.number().unsafe(),
1618
+ liquidMassFraction: Joi.number().unsafe(),
1619
+ fluidPhase: Joi.string().valid(...Object.values(Enums.Phase)),
1620
+ })
1621
+ )
1622
+ .pattern(
1623
+ ignoredPropertiesRegex,
1624
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1625
+ )
1626
+ .unknown(false);
1693
1627
 
1694
1628
  this.propertyTypes = {
1629
+ ...this.propertyTypes,
1695
1630
  pressure: "number",
1696
1631
  temperature: "number",
1697
1632
  liquidMoleFraction: "number",
@@ -1711,16 +1646,11 @@ export class FlashResultSchema {
1711
1646
  };
1712
1647
  }
1713
1648
 
1714
- validate(data: FlashResultSchemaData): Entities.FlashResult {
1715
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1716
- if (error) {
1717
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1718
- }
1719
- return this.makeEntity(value);
1720
- }
1721
-
1722
1649
  makeEntity(data: FlashResultSchemaData): Entities.FlashResult {
1723
1650
  return new Entities.FlashResult(
1651
+ data.id,
1652
+ data.typeId,
1653
+ data.displayName,
1724
1654
  data.pressure,
1725
1655
  data.temperature,
1726
1656
  data.liquidMoleFraction,
@@ -1741,7 +1671,7 @@ export class FlashResultSchema {
1741
1671
  }
1742
1672
  }
1743
1673
 
1744
- export interface ReleaseOverTimeSchemaData {
1674
+ export interface ReleaseOverTimeSchemaData extends SchemaBaseData {
1745
1675
  releaseAngle: number;
1746
1676
  timeVaryingOption: Enums.TimeVaryingOption;
1747
1677
  }
@@ -1752,44 +1682,40 @@ export interface ReleaseOverTimeSchemaData {
1752
1682
  * Description: Scenario representing a release over time.
1753
1683
  * ================================================================================
1754
1684
  */
1755
- export class ReleaseOverTimeSchema {
1756
- schema: Joi.ObjectSchema;
1757
- propertyTypes: Record<string, unknown>;
1758
-
1685
+ export class ReleaseOverTimeSchema extends SchemaBase<ReleaseOverTimeSchemaData> {
1759
1686
  constructor() {
1760
- this.schema = Joi.object({
1761
- releaseAngle: Joi.number().unsafe(),
1762
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1763
- })
1764
- .pattern(
1765
- ignoredPropertiesRegex,
1766
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1767
- )
1768
- .unknown(false);
1687
+ super();
1688
+ this.schema = this.schema.concat(
1689
+ Joi.object({
1690
+ releaseAngle: Joi.number().unsafe(),
1691
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1692
+ })
1693
+ )
1694
+ .pattern(
1695
+ ignoredPropertiesRegex,
1696
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1697
+ )
1698
+ .unknown(false);
1769
1699
 
1770
1700
  this.propertyTypes = {
1701
+ ...this.propertyTypes,
1771
1702
  releaseAngle: "number",
1772
1703
  timeVaryingOption: "Enums.TimeVaryingOption",
1773
1704
  };
1774
1705
  }
1775
1706
 
1776
- validate(data: ReleaseOverTimeSchemaData): Entities.ReleaseOverTime {
1777
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1778
- if (error) {
1779
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1780
- }
1781
- return this.makeEntity(value);
1782
- }
1783
-
1784
1707
  makeEntity(data: ReleaseOverTimeSchemaData): Entities.ReleaseOverTime {
1785
1708
  return new Entities.ReleaseOverTime(
1709
+ data.id,
1710
+ data.typeId,
1711
+ data.displayName,
1786
1712
  data.releaseAngle,
1787
1713
  data.timeVaryingOption
1788
1714
  );
1789
1715
  }
1790
1716
  }
1791
1717
 
1792
- export interface LeakSchemaData {
1718
+ export interface LeakSchemaData extends SchemaBaseData {
1793
1719
  holeDiameter: number;
1794
1720
  releaseAngle: number;
1795
1721
  timeVaryingOption: Enums.TimeVaryingOption;
@@ -1803,25 +1729,26 @@ export interface LeakSchemaData {
1803
1729
  * Description: A storage scenario which models a release of material through a hole in a vessel or pipe.
1804
1730
  * ================================================================================
1805
1731
  */
1806
- export class LeakSchema {
1807
- schema: Joi.ObjectSchema;
1808
- propertyTypes: Record<string, unknown>;
1809
-
1732
+ export class LeakSchema extends SchemaBase<LeakSchemaData> {
1810
1733
  constructor() {
1811
- this.schema = Joi.object({
1812
- holeDiameter: Joi.number().unsafe(),
1813
- releaseAngle: Joi.number().unsafe(),
1814
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1815
- holeHeightFraction: Joi.number().unsafe(),
1816
- releaseElevation: Joi.number().unsafe(),
1817
- })
1818
- .pattern(
1819
- ignoredPropertiesRegex,
1820
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1821
- )
1822
- .unknown(false);
1734
+ super();
1735
+ this.schema = this.schema.concat(
1736
+ Joi.object({
1737
+ holeDiameter: Joi.number().unsafe(),
1738
+ releaseAngle: Joi.number().unsafe(),
1739
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1740
+ holeHeightFraction: Joi.number().unsafe(),
1741
+ releaseElevation: Joi.number().unsafe(),
1742
+ })
1743
+ )
1744
+ .pattern(
1745
+ ignoredPropertiesRegex,
1746
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1747
+ )
1748
+ .unknown(false);
1823
1749
 
1824
1750
  this.propertyTypes = {
1751
+ ...this.propertyTypes,
1825
1752
  holeDiameter: "number",
1826
1753
  releaseAngle: "number",
1827
1754
  timeVaryingOption: "Enums.TimeVaryingOption",
@@ -1830,16 +1757,11 @@ export class LeakSchema {
1830
1757
  };
1831
1758
  }
1832
1759
 
1833
- validate(data: LeakSchemaData): Entities.Leak {
1834
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1835
- if (error) {
1836
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1837
- }
1838
- return this.makeEntity(value);
1839
- }
1840
-
1841
1760
  makeEntity(data: LeakSchemaData): Entities.Leak {
1842
1761
  return new Entities.Leak(
1762
+ data.id,
1763
+ data.typeId,
1764
+ data.displayName,
1843
1765
  data.holeDiameter,
1844
1766
  data.releaseAngle,
1845
1767
  data.timeVaryingOption,
@@ -1849,7 +1771,7 @@ export class LeakSchema {
1849
1771
  }
1850
1772
  }
1851
1773
 
1852
- export interface LineRuptureSchemaData {
1774
+ export interface LineRuptureSchemaData extends SchemaBaseData {
1853
1775
  pipeDiameter: number;
1854
1776
  pipeLength: number;
1855
1777
  releaseAngle: number;
@@ -1864,26 +1786,27 @@ export interface LineRuptureSchemaData {
1864
1786
  * Description: A storage scenario which models a release of material due to rupture of a short length of pipework attached to a vessel or any kind of pressure reservoir.
1865
1787
  * ================================================================================
1866
1788
  */
1867
- export class LineRuptureSchema {
1868
- schema: Joi.ObjectSchema;
1869
- propertyTypes: Record<string, unknown>;
1870
-
1789
+ export class LineRuptureSchema extends SchemaBase<LineRuptureSchemaData> {
1871
1790
  constructor() {
1872
- this.schema = Joi.object({
1873
- pipeDiameter: Joi.number().unsafe(),
1874
- pipeLength: Joi.number().unsafe(),
1875
- releaseAngle: Joi.number().unsafe(),
1876
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1877
- pipeRoughness: Joi.number().unsafe(),
1878
- pipeHeightFraction: Joi.number().unsafe(),
1879
- })
1880
- .pattern(
1881
- ignoredPropertiesRegex,
1882
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1883
- )
1884
- .unknown(false);
1791
+ super();
1792
+ this.schema = this.schema.concat(
1793
+ Joi.object({
1794
+ pipeDiameter: Joi.number().unsafe(),
1795
+ pipeLength: Joi.number().unsafe(),
1796
+ releaseAngle: Joi.number().unsafe(),
1797
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
1798
+ pipeRoughness: Joi.number().unsafe(),
1799
+ pipeHeightFraction: Joi.number().unsafe(),
1800
+ })
1801
+ )
1802
+ .pattern(
1803
+ ignoredPropertiesRegex,
1804
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1805
+ )
1806
+ .unknown(false);
1885
1807
 
1886
1808
  this.propertyTypes = {
1809
+ ...this.propertyTypes,
1887
1810
  pipeDiameter: "number",
1888
1811
  pipeLength: "number",
1889
1812
  releaseAngle: "number",
@@ -1893,16 +1816,11 @@ export class LineRuptureSchema {
1893
1816
  };
1894
1817
  }
1895
1818
 
1896
- validate(data: LineRuptureSchemaData): Entities.LineRupture {
1897
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1898
- if (error) {
1899
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1900
- }
1901
- return this.makeEntity(value);
1902
- }
1903
-
1904
1819
  makeEntity(data: LineRuptureSchemaData): Entities.LineRupture {
1905
1820
  return new Entities.LineRupture(
1821
+ data.id,
1822
+ data.typeId,
1823
+ data.displayName,
1906
1824
  data.pipeDiameter,
1907
1825
  data.pipeLength,
1908
1826
  data.releaseAngle,
@@ -1913,7 +1831,7 @@ export class LineRuptureSchema {
1913
1831
  }
1914
1832
  }
1915
1833
 
1916
- export interface MaterialComponentDataItemSchemaData {
1834
+ export interface MaterialComponentDataItemSchemaData extends SchemaBaseData {
1917
1835
  description: string;
1918
1836
  equationNumber: number;
1919
1837
  equationString: string;
@@ -1929,27 +1847,28 @@ export interface MaterialComponentDataItemSchemaData {
1929
1847
  * Description: Material component data item.
1930
1848
  * ================================================================================
1931
1849
  */
1932
- export class MaterialComponentDataItemSchema {
1933
- schema: Joi.ObjectSchema;
1934
- propertyTypes: Record<string, unknown>;
1935
-
1850
+ export class MaterialComponentDataItemSchema extends SchemaBase<MaterialComponentDataItemSchemaData> {
1936
1851
  constructor() {
1937
- this.schema = Joi.object({
1938
- description: Joi.string().allow(""),
1939
- equationNumber: Joi.number().integer(),
1940
- equationString: Joi.string().allow(""),
1941
- equationCoefficients: Joi.array().items(Joi.number().unsafe()).allow(null),
1942
- calculationLimits: Joi.array().items(Joi.number().unsafe()).allow(null),
1943
- supercriticalExtrapolation: Joi.number().unsafe(),
1944
- fractionTc: Joi.number().unsafe(),
1945
- })
1946
- .pattern(
1947
- ignoredPropertiesRegex,
1948
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1949
- )
1950
- .unknown(false);
1852
+ super();
1853
+ this.schema = this.schema.concat(
1854
+ Joi.object({
1855
+ description: Joi.string().allow(""),
1856
+ equationNumber: Joi.number().integer(),
1857
+ equationString: Joi.string().allow(""),
1858
+ equationCoefficients: Joi.array().items(Joi.number().unsafe()).allow(null),
1859
+ calculationLimits: Joi.array().items(Joi.number().unsafe()).allow(null),
1860
+ supercriticalExtrapolation: Joi.number().unsafe(),
1861
+ fractionTc: Joi.number().unsafe(),
1862
+ })
1863
+ )
1864
+ .pattern(
1865
+ ignoredPropertiesRegex,
1866
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1867
+ )
1868
+ .unknown(false);
1951
1869
 
1952
1870
  this.propertyTypes = {
1871
+ ...this.propertyTypes,
1953
1872
  description: "string",
1954
1873
  equationNumber: "number",
1955
1874
  equationString: "string",
@@ -1960,16 +1879,11 @@ export class MaterialComponentDataItemSchema {
1960
1879
  };
1961
1880
  }
1962
1881
 
1963
- validate(data: MaterialComponentDataItemSchemaData): Entities.MaterialComponentDataItem {
1964
- const { error, value } = this.schema.validate(data, { abortEarly: false });
1965
- if (error) {
1966
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
1967
- }
1968
- return this.makeEntity(value);
1969
- }
1970
-
1971
1882
  makeEntity(data: MaterialComponentDataItemSchemaData): Entities.MaterialComponentDataItem {
1972
1883
  return new Entities.MaterialComponentDataItem(
1884
+ data.id,
1885
+ data.typeId,
1886
+ data.displayName,
1973
1887
  data.description,
1974
1888
  data.equationNumber,
1975
1889
  data.equationString,
@@ -1981,7 +1895,7 @@ export class MaterialComponentDataItemSchema {
1981
1895
  }
1982
1896
  }
1983
1897
 
1984
- export interface MaterialComponentDataSchemaData {
1898
+ export interface MaterialComponentDataSchemaData extends SchemaBaseData {
1985
1899
  name: string;
1986
1900
  dipprVersion: number;
1987
1901
  casId: number;
@@ -1995,25 +1909,26 @@ export interface MaterialComponentDataSchemaData {
1995
1909
  * Description: Data related to a MaterialComponent.
1996
1910
  * ================================================================================
1997
1911
  */
1998
- export class MaterialComponentDataSchema {
1999
- schema: Joi.ObjectSchema;
2000
- propertyTypes: Record<string, unknown>;
2001
-
1912
+ export class MaterialComponentDataSchema extends SchemaBase<MaterialComponentDataSchemaData> {
2002
1913
  constructor() {
2003
- this.schema = Joi.object({
2004
- name: Joi.string().allow(""),
2005
- dipprVersion: Joi.number().integer(),
2006
- casId: Joi.number().integer(),
2007
- dataItem: Joi.array().items(new MaterialComponentDataItemSchema().schema).allow(null),
2008
- nonStandard: Joi.boolean(),
2009
- })
2010
- .pattern(
2011
- ignoredPropertiesRegex,
2012
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2013
- )
2014
- .unknown(false);
1914
+ super();
1915
+ this.schema = this.schema.concat(
1916
+ Joi.object({
1917
+ name: Joi.string().allow(""),
1918
+ dipprVersion: Joi.number().integer(),
1919
+ casId: Joi.number().integer(),
1920
+ dataItem: Joi.array().items(new MaterialComponentDataItemSchema().schema).allow(null),
1921
+ nonStandard: Joi.boolean(),
1922
+ })
1923
+ )
1924
+ .pattern(
1925
+ ignoredPropertiesRegex,
1926
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
1927
+ )
1928
+ .unknown(false);
2015
1929
 
2016
1930
  this.propertyTypes = {
1931
+ ...this.propertyTypes,
2017
1932
  name: "string",
2018
1933
  dipprVersion: "number",
2019
1934
  casId: "number",
@@ -2022,16 +1937,11 @@ export class MaterialComponentDataSchema {
2022
1937
  };
2023
1938
  }
2024
1939
 
2025
- validate(data: MaterialComponentDataSchemaData): Entities.MaterialComponentData {
2026
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2027
- if (error) {
2028
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2029
- }
2030
- return this.makeEntity(value);
2031
- }
2032
-
2033
1940
  makeEntity(data: MaterialComponentDataSchemaData): Entities.MaterialComponentData {
2034
1941
  return new Entities.MaterialComponentData(
1942
+ data.id,
1943
+ data.typeId,
1944
+ data.displayName,
2035
1945
  data.name,
2036
1946
  data.dipprVersion,
2037
1947
  data.casId,
@@ -2041,7 +1951,7 @@ export class MaterialComponentDataSchema {
2041
1951
  }
2042
1952
  }
2043
1953
 
2044
- export interface MixtureConstantPropertiesResultSchemaData {
1954
+ export interface MixtureConstantPropertiesResultSchemaData extends SchemaBaseData {
2045
1955
  lowerFlammabilityLimit: number;
2046
1956
  upperFlammabilityLimit: number;
2047
1957
  criticalPressure: number;
@@ -2066,36 +1976,37 @@ export interface MixtureConstantPropertiesResultSchemaData {
2066
1976
  * Description: Constant properties of a mixture.
2067
1977
  * ================================================================================
2068
1978
  */
2069
- export class MixtureConstantPropertiesResultSchema {
2070
- schema: Joi.ObjectSchema;
2071
- propertyTypes: Record<string, unknown>;
2072
-
1979
+ export class MixtureConstantPropertiesResultSchema extends SchemaBase<MixtureConstantPropertiesResultSchemaData> {
2073
1980
  constructor() {
2074
- this.schema = Joi.object({
2075
- lowerFlammabilityLimit: Joi.number().unsafe(),
2076
- upperFlammabilityLimit: Joi.number().unsafe(),
2077
- criticalPressure: Joi.number().unsafe(),
2078
- criticalTemperature: Joi.number().unsafe(),
2079
- flashPoint: Joi.number().unsafe(),
2080
- heatCombustion: Joi.number().unsafe(),
2081
- maximumBurnRate: Joi.number().unsafe(),
2082
- maximumSEP: Joi.number().unsafe(),
2083
- molecularWeight: Joi.number().unsafe(),
2084
- bubblePoint: Joi.number().unsafe(),
2085
- poolFireBurnRateLength: Joi.number().unsafe(),
2086
- dewPoint: Joi.number().unsafe(),
2087
- emissivePowerLengthScale: Joi.number().unsafe(),
2088
- laminarBurningVelocity: Joi.number().unsafe(),
2089
- flammableToxicFlag: Joi.string().valid(...Object.values(Enums.FlammableToxic)),
2090
- luminousSmokyFlame: Joi.string().valid(...Object.values(Enums.LuminousSmokyFlame)),
2091
- })
2092
- .pattern(
2093
- ignoredPropertiesRegex,
2094
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2095
- )
2096
- .unknown(false);
1981
+ super();
1982
+ this.schema = this.schema.concat(
1983
+ Joi.object({
1984
+ lowerFlammabilityLimit: Joi.number().unsafe(),
1985
+ upperFlammabilityLimit: Joi.number().unsafe(),
1986
+ criticalPressure: Joi.number().unsafe(),
1987
+ criticalTemperature: Joi.number().unsafe(),
1988
+ flashPoint: Joi.number().unsafe(),
1989
+ heatCombustion: Joi.number().unsafe(),
1990
+ maximumBurnRate: Joi.number().unsafe(),
1991
+ maximumSEP: Joi.number().unsafe(),
1992
+ molecularWeight: Joi.number().unsafe(),
1993
+ bubblePoint: Joi.number().unsafe(),
1994
+ poolFireBurnRateLength: Joi.number().unsafe(),
1995
+ dewPoint: Joi.number().unsafe(),
1996
+ emissivePowerLengthScale: Joi.number().unsafe(),
1997
+ laminarBurningVelocity: Joi.number().unsafe(),
1998
+ flammableToxicFlag: Joi.string().valid(...Object.values(Enums.FlammableToxic)),
1999
+ luminousSmokyFlame: Joi.string().valid(...Object.values(Enums.LuminousSmokyFlame)),
2000
+ })
2001
+ )
2002
+ .pattern(
2003
+ ignoredPropertiesRegex,
2004
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2005
+ )
2006
+ .unknown(false);
2097
2007
 
2098
2008
  this.propertyTypes = {
2009
+ ...this.propertyTypes,
2099
2010
  lowerFlammabilityLimit: "number",
2100
2011
  upperFlammabilityLimit: "number",
2101
2012
  criticalPressure: "number",
@@ -2115,16 +2026,11 @@ export class MixtureConstantPropertiesResultSchema {
2115
2026
  };
2116
2027
  }
2117
2028
 
2118
- validate(data: MixtureConstantPropertiesResultSchemaData): Entities.MixtureConstantPropertiesResult {
2119
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2120
- if (error) {
2121
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2122
- }
2123
- return this.makeEntity(value);
2124
- }
2125
-
2126
2029
  makeEntity(data: MixtureConstantPropertiesResultSchemaData): Entities.MixtureConstantPropertiesResult {
2127
2030
  return new Entities.MixtureConstantPropertiesResult(
2031
+ data.id,
2032
+ data.typeId,
2033
+ data.displayName,
2128
2034
  data.lowerFlammabilityLimit,
2129
2035
  data.upperFlammabilityLimit,
2130
2036
  data.criticalPressure,
@@ -2145,7 +2051,7 @@ export class MixtureConstantPropertiesResultSchema {
2145
2051
  }
2146
2052
  }
2147
2053
 
2148
- export interface PipeSchemaData {
2054
+ export interface PipeSchemaData extends SchemaBaseData {
2149
2055
  location: Entities.LocalPosition;
2150
2056
  nodes: Entities.LocalPosition[];
2151
2057
  nodeCount: number;
@@ -2162,28 +2068,29 @@ export interface PipeSchemaData {
2162
2068
  * Description: An asset to model events that involve releases from pressurised pipelines.
2163
2069
  * ================================================================================
2164
2070
  */
2165
- export class PipeSchema {
2166
- schema: Joi.ObjectSchema;
2167
- propertyTypes: Record<string, unknown>;
2168
-
2071
+ export class PipeSchema extends SchemaBase<PipeSchemaData> {
2169
2072
  constructor() {
2170
- this.schema = Joi.object({
2171
- location: new LocalPositionSchema().schema,
2172
- nodes: Joi.array().items(new LocalPositionSchema().schema).allow(null),
2173
- nodeCount: Joi.number().integer(),
2174
- diameter: Joi.number().unsafe(),
2175
- material: new MaterialSchema().schema,
2176
- state: new StateSchema().schema,
2177
- roughness: Joi.number().unsafe(),
2178
- pumpedInflow: Joi.number().unsafe(),
2179
- })
2180
- .pattern(
2181
- ignoredPropertiesRegex,
2182
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2183
- )
2184
- .unknown(false);
2073
+ super();
2074
+ this.schema = this.schema.concat(
2075
+ Joi.object({
2076
+ location: new LocalPositionSchema().schema,
2077
+ nodes: Joi.array().items(new LocalPositionSchema().schema).allow(null),
2078
+ nodeCount: Joi.number().integer(),
2079
+ diameter: Joi.number().unsafe(),
2080
+ material: new MaterialSchema().schema,
2081
+ state: new StateSchema().schema,
2082
+ roughness: Joi.number().unsafe(),
2083
+ pumpedInflow: Joi.number().unsafe(),
2084
+ })
2085
+ )
2086
+ .pattern(
2087
+ ignoredPropertiesRegex,
2088
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2089
+ )
2090
+ .unknown(false);
2185
2091
 
2186
2092
  this.propertyTypes = {
2093
+ ...this.propertyTypes,
2187
2094
  location: "LocalPosition",
2188
2095
  nodes: "LocalPosition[]",
2189
2096
  nodeCount: "number",
@@ -2195,16 +2102,11 @@ export class PipeSchema {
2195
2102
  };
2196
2103
  }
2197
2104
 
2198
- validate(data: PipeSchemaData): Entities.Pipe {
2199
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2200
- if (error) {
2201
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2202
- }
2203
- return this.makeEntity(value);
2204
- }
2205
-
2206
2105
  makeEntity(data: PipeSchemaData): Entities.Pipe {
2207
2106
  return new Entities.Pipe(
2107
+ data.id,
2108
+ data.typeId,
2109
+ data.displayName,
2208
2110
  data.location,
2209
2111
  data.nodes,
2210
2112
  data.nodeCount,
@@ -2217,7 +2119,7 @@ export class PipeSchema {
2217
2119
  }
2218
2120
  }
2219
2121
 
2220
- export interface PipeBreachSchemaData {
2122
+ export interface PipeBreachSchemaData extends SchemaBaseData {
2221
2123
  distanceDownstream: number;
2222
2124
  releaseAngle: number;
2223
2125
  timeVaryingOption: Enums.TimeVaryingOption;
@@ -2230,24 +2132,25 @@ export interface PipeBreachSchemaData {
2230
2132
  * Description: A storage scenario which models a time-dependent release of material from its process or transport conditions in a pipeline.
2231
2133
  * ================================================================================
2232
2134
  */
2233
- export class PipeBreachSchema {
2234
- schema: Joi.ObjectSchema;
2235
- propertyTypes: Record<string, unknown>;
2236
-
2135
+ export class PipeBreachSchema extends SchemaBase<PipeBreachSchemaData> {
2237
2136
  constructor() {
2238
- this.schema = Joi.object({
2239
- distanceDownstream: Joi.number().unsafe(),
2240
- releaseAngle: Joi.number().unsafe(),
2241
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2242
- relativeAperture: Joi.number().unsafe(),
2243
- })
2244
- .pattern(
2245
- ignoredPropertiesRegex,
2246
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2247
- )
2248
- .unknown(false);
2137
+ super();
2138
+ this.schema = this.schema.concat(
2139
+ Joi.object({
2140
+ distanceDownstream: Joi.number().unsafe(),
2141
+ releaseAngle: Joi.number().unsafe(),
2142
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2143
+ relativeAperture: Joi.number().unsafe(),
2144
+ })
2145
+ )
2146
+ .pattern(
2147
+ ignoredPropertiesRegex,
2148
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2149
+ )
2150
+ .unknown(false);
2249
2151
 
2250
2152
  this.propertyTypes = {
2153
+ ...this.propertyTypes,
2251
2154
  distanceDownstream: "number",
2252
2155
  releaseAngle: "number",
2253
2156
  timeVaryingOption: "Enums.TimeVaryingOption",
@@ -2255,16 +2158,11 @@ export class PipeBreachSchema {
2255
2158
  };
2256
2159
  }
2257
2160
 
2258
- validate(data: PipeBreachSchemaData): Entities.PipeBreach {
2259
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2260
- if (error) {
2261
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2262
- }
2263
- return this.makeEntity(value);
2264
- }
2265
-
2266
2161
  makeEntity(data: PipeBreachSchemaData): Entities.PipeBreach {
2267
2162
  return new Entities.PipeBreach(
2163
+ data.id,
2164
+ data.typeId,
2165
+ data.displayName,
2268
2166
  data.distanceDownstream,
2269
2167
  data.releaseAngle,
2270
2168
  data.timeVaryingOption,
@@ -2273,7 +2171,7 @@ export class PipeBreachSchema {
2273
2171
  }
2274
2172
  }
2275
2173
 
2276
- export interface PoolFireFlameResultSchemaData {
2174
+ export interface PoolFireFlameResultSchemaData extends SchemaBaseData {
2277
2175
  time: number;
2278
2176
  surfaceEmissivePower: number;
2279
2177
  flameLength: number;
@@ -2288,26 +2186,27 @@ export interface PoolFireFlameResultSchemaData {
2288
2186
  * Description: Flame results for a pool fire.
2289
2187
  * ================================================================================
2290
2188
  */
2291
- export class PoolFireFlameResultSchema {
2292
- schema: Joi.ObjectSchema;
2293
- propertyTypes: Record<string, unknown>;
2294
-
2189
+ export class PoolFireFlameResultSchema extends SchemaBase<PoolFireFlameResultSchemaData> {
2295
2190
  constructor() {
2296
- this.schema = Joi.object({
2297
- time: Joi.number().unsafe(),
2298
- surfaceEmissivePower: Joi.number().unsafe(),
2299
- flameLength: Joi.number().unsafe(),
2300
- flameDiameter: Joi.number().unsafe(),
2301
- poolZoneSEP: Joi.array().items(Joi.number().unsafe()).allow(null),
2302
- fireType: Joi.string().valid(...Object.values(Enums.FireType)),
2303
- })
2304
- .pattern(
2305
- ignoredPropertiesRegex,
2306
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2307
- )
2308
- .unknown(false);
2191
+ super();
2192
+ this.schema = this.schema.concat(
2193
+ Joi.object({
2194
+ time: Joi.number().unsafe(),
2195
+ surfaceEmissivePower: Joi.number().unsafe(),
2196
+ flameLength: Joi.number().unsafe(),
2197
+ flameDiameter: Joi.number().unsafe(),
2198
+ poolZoneSEP: Joi.array().items(Joi.number().unsafe()).allow(null),
2199
+ fireType: Joi.string().valid(...Object.values(Enums.FireType)),
2200
+ })
2201
+ )
2202
+ .pattern(
2203
+ ignoredPropertiesRegex,
2204
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2205
+ )
2206
+ .unknown(false);
2309
2207
 
2310
2208
  this.propertyTypes = {
2209
+ ...this.propertyTypes,
2311
2210
  time: "number",
2312
2211
  surfaceEmissivePower: "number",
2313
2212
  flameLength: "number",
@@ -2317,16 +2216,11 @@ export class PoolFireFlameResultSchema {
2317
2216
  };
2318
2217
  }
2319
2218
 
2320
- validate(data: PoolFireFlameResultSchemaData): Entities.PoolFireFlameResult {
2321
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2322
- if (error) {
2323
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2324
- }
2325
- return this.makeEntity(value);
2326
- }
2327
-
2328
2219
  makeEntity(data: PoolFireFlameResultSchemaData): Entities.PoolFireFlameResult {
2329
2220
  return new Entities.PoolFireFlameResult(
2221
+ data.id,
2222
+ data.typeId,
2223
+ data.displayName,
2330
2224
  data.time,
2331
2225
  data.surfaceEmissivePower,
2332
2226
  data.flameLength,
@@ -2337,7 +2231,7 @@ export class PoolFireFlameResultSchema {
2337
2231
  }
2338
2232
  }
2339
2233
 
2340
- export interface PoolRecordSchemaData {
2234
+ export interface PoolRecordSchemaData extends SchemaBaseData {
2341
2235
  time: number;
2342
2236
  massSpilt: number;
2343
2237
  massVaporised: number;
@@ -2359,33 +2253,34 @@ export interface PoolRecordSchemaData {
2359
2253
  * Description: A record containing pool results at a given time.
2360
2254
  * ================================================================================
2361
2255
  */
2362
- export class PoolRecordSchema {
2363
- schema: Joi.ObjectSchema;
2364
- propertyTypes: Record<string, unknown>;
2365
-
2256
+ export class PoolRecordSchema extends SchemaBase<PoolRecordSchemaData> {
2366
2257
  constructor() {
2367
- this.schema = Joi.object({
2368
- time: Joi.number().unsafe(),
2369
- massSpilt: Joi.number().unsafe(),
2370
- massVaporised: Joi.number().unsafe(),
2371
- massDissolved: Joi.number().unsafe(),
2372
- massRemaining: Joi.number().unsafe(),
2373
- vapourisationRate: Joi.number().unsafe(),
2374
- solutionRate: Joi.number().unsafe(),
2375
- effectiveRadius: Joi.number().unsafe(),
2376
- depth: Joi.number().unsafe(),
2377
- temperature: Joi.number().unsafe(),
2378
- spillRate: Joi.number().unsafe(),
2379
- actualRadius: Joi.number().unsafe(),
2380
- poolCentre: Joi.number().unsafe(),
2381
- })
2382
- .pattern(
2383
- ignoredPropertiesRegex,
2384
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2385
- )
2386
- .unknown(false);
2258
+ super();
2259
+ this.schema = this.schema.concat(
2260
+ Joi.object({
2261
+ time: Joi.number().unsafe(),
2262
+ massSpilt: Joi.number().unsafe(),
2263
+ massVaporised: Joi.number().unsafe(),
2264
+ massDissolved: Joi.number().unsafe(),
2265
+ massRemaining: Joi.number().unsafe(),
2266
+ vapourisationRate: Joi.number().unsafe(),
2267
+ solutionRate: Joi.number().unsafe(),
2268
+ effectiveRadius: Joi.number().unsafe(),
2269
+ depth: Joi.number().unsafe(),
2270
+ temperature: Joi.number().unsafe(),
2271
+ spillRate: Joi.number().unsafe(),
2272
+ actualRadius: Joi.number().unsafe(),
2273
+ poolCentre: Joi.number().unsafe(),
2274
+ })
2275
+ )
2276
+ .pattern(
2277
+ ignoredPropertiesRegex,
2278
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2279
+ )
2280
+ .unknown(false);
2387
2281
 
2388
2282
  this.propertyTypes = {
2283
+ ...this.propertyTypes,
2389
2284
  time: "number",
2390
2285
  massSpilt: "number",
2391
2286
  massVaporised: "number",
@@ -2402,16 +2297,11 @@ export class PoolRecordSchema {
2402
2297
  };
2403
2298
  }
2404
2299
 
2405
- validate(data: PoolRecordSchemaData): Entities.PoolRecord {
2406
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2407
- if (error) {
2408
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2409
- }
2410
- return this.makeEntity(value);
2411
- }
2412
-
2413
2300
  makeEntity(data: PoolRecordSchemaData): Entities.PoolRecord {
2414
2301
  return new Entities.PoolRecord(
2302
+ data.id,
2303
+ data.typeId,
2304
+ data.displayName,
2415
2305
  data.time,
2416
2306
  data.massSpilt,
2417
2307
  data.massVaporised,
@@ -2429,7 +2319,7 @@ export class PoolRecordSchema {
2429
2319
  }
2430
2320
  }
2431
2321
 
2432
- export interface PoolVapourisationParametersSchemaData {
2322
+ export interface PoolVapourisationParametersSchemaData extends SchemaBaseData {
2433
2323
  toxicsCutoffRate: number;
2434
2324
  flammableCutoffRate: number;
2435
2325
  relativeTolerance: number;
@@ -2441,39 +2331,35 @@ export interface PoolVapourisationParametersSchemaData {
2441
2331
  * Description: Pool vapourisation parameters
2442
2332
  * ================================================================================
2443
2333
  */
2444
- export class PoolVapourisationParametersSchema {
2445
- schema: Joi.ObjectSchema;
2446
- propertyTypes: Record<string, unknown>;
2447
-
2334
+ export class PoolVapourisationParametersSchema extends SchemaBase<PoolVapourisationParametersSchemaData> {
2448
2335
  constructor() {
2449
- this.schema = Joi.object({
2450
- toxicsCutoffRate: Joi.number().unsafe(),
2451
- flammableCutoffRate: Joi.number().unsafe(),
2452
- relativeTolerance: Joi.number().unsafe(),
2453
- })
2454
- .pattern(
2455
- ignoredPropertiesRegex,
2456
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2457
- )
2458
- .unknown(false);
2336
+ super();
2337
+ this.schema = this.schema.concat(
2338
+ Joi.object({
2339
+ toxicsCutoffRate: Joi.number().unsafe(),
2340
+ flammableCutoffRate: Joi.number().unsafe(),
2341
+ relativeTolerance: Joi.number().unsafe(),
2342
+ })
2343
+ )
2344
+ .pattern(
2345
+ ignoredPropertiesRegex,
2346
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2347
+ )
2348
+ .unknown(false);
2459
2349
 
2460
2350
  this.propertyTypes = {
2351
+ ...this.propertyTypes,
2461
2352
  toxicsCutoffRate: "number",
2462
2353
  flammableCutoffRate: "number",
2463
2354
  relativeTolerance: "number",
2464
2355
  };
2465
2356
  }
2466
2357
 
2467
- validate(data: PoolVapourisationParametersSchemaData): Entities.PoolVapourisationParameters {
2468
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2469
- if (error) {
2470
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2471
- }
2472
- return this.makeEntity(value);
2473
- }
2474
-
2475
2358
  makeEntity(data: PoolVapourisationParametersSchemaData): Entities.PoolVapourisationParameters {
2476
2359
  return new Entities.PoolVapourisationParameters(
2360
+ data.id,
2361
+ data.typeId,
2362
+ data.displayName,
2477
2363
  data.toxicsCutoffRate,
2478
2364
  data.flammableCutoffRate,
2479
2365
  data.relativeTolerance
@@ -2481,7 +2367,7 @@ export class PoolVapourisationParametersSchema {
2481
2367
  }
2482
2368
  }
2483
2369
 
2484
- export interface RadiationRecordSchemaData {
2370
+ export interface RadiationRecordSchemaData extends SchemaBaseData {
2485
2371
  position: Entities.LocalPosition;
2486
2372
  radiationResult: number;
2487
2373
  radiationType: Enums.RadiationType;
@@ -2493,39 +2379,35 @@ export interface RadiationRecordSchemaData {
2493
2379
  * Description: A record of the radiation type and level at a specific point (x,y,z).
2494
2380
  * ================================================================================
2495
2381
  */
2496
- export class RadiationRecordSchema {
2497
- schema: Joi.ObjectSchema;
2498
- propertyTypes: Record<string, unknown>;
2499
-
2382
+ export class RadiationRecordSchema extends SchemaBase<RadiationRecordSchemaData> {
2500
2383
  constructor() {
2501
- this.schema = Joi.object({
2502
- position: new LocalPositionSchema().schema,
2503
- radiationResult: Joi.number().unsafe(),
2504
- radiationType: Joi.string().valid(...Object.values(Enums.RadiationType)),
2505
- })
2506
- .pattern(
2507
- ignoredPropertiesRegex,
2508
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2509
- )
2510
- .unknown(false);
2384
+ super();
2385
+ this.schema = this.schema.concat(
2386
+ Joi.object({
2387
+ position: new LocalPositionSchema().schema,
2388
+ radiationResult: Joi.number().unsafe(),
2389
+ radiationType: Joi.string().valid(...Object.values(Enums.RadiationType)),
2390
+ })
2391
+ )
2392
+ .pattern(
2393
+ ignoredPropertiesRegex,
2394
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2395
+ )
2396
+ .unknown(false);
2511
2397
 
2512
2398
  this.propertyTypes = {
2399
+ ...this.propertyTypes,
2513
2400
  position: "LocalPosition",
2514
2401
  radiationResult: "number",
2515
2402
  radiationType: "Enums.RadiationType",
2516
2403
  };
2517
2404
  }
2518
2405
 
2519
- validate(data: RadiationRecordSchemaData): Entities.RadiationRecord {
2520
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2521
- if (error) {
2522
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2523
- }
2524
- return this.makeEntity(value);
2525
- }
2526
-
2527
2406
  makeEntity(data: RadiationRecordSchemaData): Entities.RadiationRecord {
2528
2407
  return new Entities.RadiationRecord(
2408
+ data.id,
2409
+ data.typeId,
2410
+ data.displayName,
2529
2411
  data.position,
2530
2412
  data.radiationResult,
2531
2413
  data.radiationType
@@ -2533,7 +2415,7 @@ export class RadiationRecordSchema {
2533
2415
  }
2534
2416
  }
2535
2417
 
2536
- export interface ReliefValveSchemaData {
2418
+ export interface ReliefValveSchemaData extends SchemaBaseData {
2537
2419
  reliefValveConstrictionDiameter: number;
2538
2420
  pipeDiameter: number;
2539
2421
  pipeLength: number;
@@ -2549,27 +2431,28 @@ export interface ReliefValveSchemaData {
2549
2431
  * Description: A storage scenario which models a release of material from the vapour side of a vessel due to the lifting of a relief valve.
2550
2432
  * ================================================================================
2551
2433
  */
2552
- export class ReliefValveSchema {
2553
- schema: Joi.ObjectSchema;
2554
- propertyTypes: Record<string, unknown>;
2555
-
2434
+ export class ReliefValveSchema extends SchemaBase<ReliefValveSchemaData> {
2556
2435
  constructor() {
2557
- this.schema = Joi.object({
2558
- reliefValveConstrictionDiameter: Joi.number().unsafe(),
2559
- pipeDiameter: Joi.number().unsafe(),
2560
- pipeLength: Joi.number().unsafe(),
2561
- releaseAngle: Joi.number().unsafe(),
2562
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2563
- pipeRoughness: Joi.number().unsafe(),
2564
- pipeHeightFraction: Joi.number().unsafe(),
2565
- })
2566
- .pattern(
2567
- ignoredPropertiesRegex,
2568
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2569
- )
2570
- .unknown(false);
2436
+ super();
2437
+ this.schema = this.schema.concat(
2438
+ Joi.object({
2439
+ reliefValveConstrictionDiameter: Joi.number().unsafe(),
2440
+ pipeDiameter: Joi.number().unsafe(),
2441
+ pipeLength: Joi.number().unsafe(),
2442
+ releaseAngle: Joi.number().unsafe(),
2443
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2444
+ pipeRoughness: Joi.number().unsafe(),
2445
+ pipeHeightFraction: Joi.number().unsafe(),
2446
+ })
2447
+ )
2448
+ .pattern(
2449
+ ignoredPropertiesRegex,
2450
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2451
+ )
2452
+ .unknown(false);
2571
2453
 
2572
2454
  this.propertyTypes = {
2455
+ ...this.propertyTypes,
2573
2456
  reliefValveConstrictionDiameter: "number",
2574
2457
  pipeDiameter: "number",
2575
2458
  pipeLength: "number",
@@ -2580,16 +2463,11 @@ export class ReliefValveSchema {
2580
2463
  };
2581
2464
  }
2582
2465
 
2583
- validate(data: ReliefValveSchemaData): Entities.ReliefValve {
2584
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2585
- if (error) {
2586
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2587
- }
2588
- return this.makeEntity(value);
2589
- }
2590
-
2591
2466
  makeEntity(data: ReliefValveSchemaData): Entities.ReliefValve {
2592
2467
  return new Entities.ReliefValve(
2468
+ data.id,
2469
+ data.typeId,
2470
+ data.displayName,
2593
2471
  data.reliefValveConstrictionDiameter,
2594
2472
  data.pipeDiameter,
2595
2473
  data.pipeLength,
@@ -2601,7 +2479,7 @@ export class ReliefValveSchema {
2601
2479
  }
2602
2480
  }
2603
2481
 
2604
- export interface ScalarUdmOutputsSchemaData {
2482
+ export interface ScalarUdmOutputsSchemaData extends SchemaBaseData {
2605
2483
  observerCount: number;
2606
2484
  recordCount: number;
2607
2485
  minimumConcentration: number;
@@ -2617,27 +2495,28 @@ export interface ScalarUdmOutputsSchemaData {
2617
2495
  * Description: Scalar UDM output values required for post processing dispersion results.
2618
2496
  * ================================================================================
2619
2497
  */
2620
- export class ScalarUdmOutputsSchema {
2621
- schema: Joi.ObjectSchema;
2622
- propertyTypes: Record<string, unknown>;
2623
-
2498
+ export class ScalarUdmOutputsSchema extends SchemaBase<ScalarUdmOutputsSchemaData> {
2624
2499
  constructor() {
2625
- this.schema = Joi.object({
2626
- observerCount: Joi.number().integer(),
2627
- recordCount: Joi.number().integer(),
2628
- minimumConcentration: Joi.number().unsafe(),
2629
- windPower: Joi.number().unsafe(),
2630
- frictionVelocity: Joi.number().unsafe(),
2631
- dispersionReleaseDuration: Joi.number().unsafe(),
2632
- cloudType: Joi.string().valid(...Object.values(Enums.DynamicType)),
2633
- })
2634
- .pattern(
2635
- ignoredPropertiesRegex,
2636
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2637
- )
2638
- .unknown(false);
2500
+ super();
2501
+ this.schema = this.schema.concat(
2502
+ Joi.object({
2503
+ observerCount: Joi.number().integer(),
2504
+ recordCount: Joi.number().integer(),
2505
+ minimumConcentration: Joi.number().unsafe(),
2506
+ windPower: Joi.number().unsafe(),
2507
+ frictionVelocity: Joi.number().unsafe(),
2508
+ dispersionReleaseDuration: Joi.number().unsafe(),
2509
+ cloudType: Joi.string().valid(...Object.values(Enums.DynamicType)),
2510
+ })
2511
+ )
2512
+ .pattern(
2513
+ ignoredPropertiesRegex,
2514
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2515
+ )
2516
+ .unknown(false);
2639
2517
 
2640
2518
  this.propertyTypes = {
2519
+ ...this.propertyTypes,
2641
2520
  observerCount: "number",
2642
2521
  recordCount: "number",
2643
2522
  minimumConcentration: "number",
@@ -2648,16 +2527,11 @@ export class ScalarUdmOutputsSchema {
2648
2527
  };
2649
2528
  }
2650
2529
 
2651
- validate(data: ScalarUdmOutputsSchemaData): Entities.ScalarUdmOutputs {
2652
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2653
- if (error) {
2654
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2655
- }
2656
- return this.makeEntity(value);
2657
- }
2658
-
2659
2530
  makeEntity(data: ScalarUdmOutputsSchemaData): Entities.ScalarUdmOutputs {
2660
2531
  return new Entities.ScalarUdmOutputs(
2532
+ data.id,
2533
+ data.typeId,
2534
+ data.displayName,
2661
2535
  data.observerCount,
2662
2536
  data.recordCount,
2663
2537
  data.minimumConcentration,
@@ -2669,7 +2543,7 @@ export class ScalarUdmOutputsSchema {
2669
2543
  }
2670
2544
  }
2671
2545
 
2672
- export interface ShortPipeRuptureSchemaData {
2546
+ export interface ShortPipeRuptureSchemaData extends SchemaBaseData {
2673
2547
  pipeLength: number;
2674
2548
  pipeDiameter: number;
2675
2549
  releaseAngle: number;
@@ -2684,26 +2558,27 @@ export interface ShortPipeRuptureSchemaData {
2684
2558
  * Description: Short pipe rupture scenario
2685
2559
  * ================================================================================
2686
2560
  */
2687
- export class ShortPipeRuptureSchema {
2688
- schema: Joi.ObjectSchema;
2689
- propertyTypes: Record<string, unknown>;
2690
-
2561
+ export class ShortPipeRuptureSchema extends SchemaBase<ShortPipeRuptureSchemaData> {
2691
2562
  constructor() {
2692
- this.schema = Joi.object({
2693
- pipeLength: Joi.number().unsafe(),
2694
- pipeDiameter: Joi.number().unsafe(),
2695
- releaseAngle: Joi.number().unsafe(),
2696
- timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2697
- pipeRoughness: Joi.number().unsafe(),
2698
- pipeHeightFraction: Joi.number().unsafe(),
2699
- })
2700
- .pattern(
2701
- ignoredPropertiesRegex,
2702
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2703
- )
2704
- .unknown(false);
2563
+ super();
2564
+ this.schema = this.schema.concat(
2565
+ Joi.object({
2566
+ pipeLength: Joi.number().unsafe(),
2567
+ pipeDiameter: Joi.number().unsafe(),
2568
+ releaseAngle: Joi.number().unsafe(),
2569
+ timeVaryingOption: Joi.string().valid(...Object.values(Enums.TimeVaryingOption)),
2570
+ pipeRoughness: Joi.number().unsafe(),
2571
+ pipeHeightFraction: Joi.number().unsafe(),
2572
+ })
2573
+ )
2574
+ .pattern(
2575
+ ignoredPropertiesRegex,
2576
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2577
+ )
2578
+ .unknown(false);
2705
2579
 
2706
2580
  this.propertyTypes = {
2581
+ ...this.propertyTypes,
2707
2582
  pipeLength: "number",
2708
2583
  pipeDiameter: "number",
2709
2584
  releaseAngle: "number",
@@ -2713,16 +2588,11 @@ export class ShortPipeRuptureSchema {
2713
2588
  };
2714
2589
  }
2715
2590
 
2716
- validate(data: ShortPipeRuptureSchemaData): Entities.ShortPipeRupture {
2717
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2718
- if (error) {
2719
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2720
- }
2721
- return this.makeEntity(value);
2722
- }
2723
-
2724
2591
  makeEntity(data: ShortPipeRuptureSchemaData): Entities.ShortPipeRupture {
2725
2592
  return new Entities.ShortPipeRupture(
2593
+ data.id,
2594
+ data.typeId,
2595
+ data.displayName,
2726
2596
  data.pipeLength,
2727
2597
  data.pipeDiameter,
2728
2598
  data.releaseAngle,
@@ -2733,7 +2603,7 @@ export class ShortPipeRuptureSchema {
2733
2603
  }
2734
2604
  }
2735
2605
 
2736
- export interface StructureSchemaData {
2606
+ export interface StructureSchemaData extends SchemaBaseData {
2737
2607
  explosionConfinedVolume: Entities.ExplosionConfinedVolume;
2738
2608
  location: Entities.LocalPosition;
2739
2609
  }
@@ -2744,44 +2614,40 @@ export interface StructureSchemaData {
2744
2614
  * Description: A building or process plant structure.
2745
2615
  * ================================================================================
2746
2616
  */
2747
- export class StructureSchema {
2748
- schema: Joi.ObjectSchema;
2749
- propertyTypes: Record<string, unknown>;
2750
-
2617
+ export class StructureSchema extends SchemaBase<StructureSchemaData> {
2751
2618
  constructor() {
2752
- this.schema = Joi.object({
2753
- explosionConfinedVolume: new ExplosionConfinedVolumeSchema().schema,
2754
- location: new LocalPositionSchema().schema,
2755
- })
2756
- .pattern(
2757
- ignoredPropertiesRegex,
2758
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2759
- )
2760
- .unknown(false);
2619
+ super();
2620
+ this.schema = this.schema.concat(
2621
+ Joi.object({
2622
+ explosionConfinedVolume: new ExplosionConfinedVolumeSchema().schema,
2623
+ location: new LocalPositionSchema().schema,
2624
+ })
2625
+ )
2626
+ .pattern(
2627
+ ignoredPropertiesRegex,
2628
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2629
+ )
2630
+ .unknown(false);
2761
2631
 
2762
2632
  this.propertyTypes = {
2633
+ ...this.propertyTypes,
2763
2634
  explosionConfinedVolume: "ExplosionConfinedVolume",
2764
2635
  location: "LocalPosition",
2765
2636
  };
2766
2637
  }
2767
2638
 
2768
- validate(data: StructureSchemaData): Entities.Structure {
2769
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2770
- if (error) {
2771
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2772
- }
2773
- return this.makeEntity(value);
2774
- }
2775
-
2776
2639
  makeEntity(data: StructureSchemaData): Entities.Structure {
2777
2640
  return new Entities.Structure(
2641
+ data.id,
2642
+ data.typeId,
2643
+ data.displayName,
2778
2644
  data.explosionConfinedVolume,
2779
2645
  data.location
2780
2646
  );
2781
2647
  }
2782
2648
  }
2783
2649
 
2784
- export interface SubstrateSchemaData {
2650
+ export interface SubstrateSchemaData extends SchemaBaseData {
2785
2651
  bund: Entities.Bund;
2786
2652
  surfaceRoughness: number;
2787
2653
  surfaceType: Enums.SurfaceType;
@@ -2794,24 +2660,25 @@ export interface SubstrateSchemaData {
2794
2660
  * Description: The ground over which a release is taking place.
2795
2661
  * ================================================================================
2796
2662
  */
2797
- export class SubstrateSchema {
2798
- schema: Joi.ObjectSchema;
2799
- propertyTypes: Record<string, unknown>;
2800
-
2663
+ export class SubstrateSchema extends SchemaBase<SubstrateSchemaData> {
2801
2664
  constructor() {
2802
- this.schema = Joi.object({
2803
- bund: new BundSchema().schema,
2804
- surfaceRoughness: Joi.number().unsafe(),
2805
- surfaceType: Joi.string().valid(...Object.values(Enums.SurfaceType)),
2806
- poolSurfaceType: Joi.string().valid(...Object.values(Enums.PoolSurfaceType)),
2807
- })
2808
- .pattern(
2809
- ignoredPropertiesRegex,
2810
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2811
- )
2812
- .unknown(false);
2665
+ super();
2666
+ this.schema = this.schema.concat(
2667
+ Joi.object({
2668
+ bund: new BundSchema().schema,
2669
+ surfaceRoughness: Joi.number().unsafe(),
2670
+ surfaceType: Joi.string().valid(...Object.values(Enums.SurfaceType)),
2671
+ poolSurfaceType: Joi.string().valid(...Object.values(Enums.PoolSurfaceType)),
2672
+ })
2673
+ )
2674
+ .pattern(
2675
+ ignoredPropertiesRegex,
2676
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2677
+ )
2678
+ .unknown(false);
2813
2679
 
2814
2680
  this.propertyTypes = {
2681
+ ...this.propertyTypes,
2815
2682
  bund: "Bund",
2816
2683
  surfaceRoughness: "number",
2817
2684
  surfaceType: "Enums.SurfaceType",
@@ -2819,16 +2686,11 @@ export class SubstrateSchema {
2819
2686
  };
2820
2687
  }
2821
2688
 
2822
- validate(data: SubstrateSchemaData): Entities.Substrate {
2823
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2824
- if (error) {
2825
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2826
- }
2827
- return this.makeEntity(value);
2828
- }
2829
-
2830
2689
  makeEntity(data: SubstrateSchemaData): Entities.Substrate {
2831
2690
  return new Entities.Substrate(
2691
+ data.id,
2692
+ data.typeId,
2693
+ data.displayName,
2832
2694
  data.bund,
2833
2695
  data.surfaceRoughness,
2834
2696
  data.surfaceType,
@@ -2837,7 +2699,7 @@ export class SubstrateSchema {
2837
2699
  }
2838
2700
  }
2839
2701
 
2840
- export interface ToxicRecordSchemaData {
2702
+ export interface ToxicRecordSchemaData extends SchemaBaseData {
2841
2703
  position: Entities.LocalPosition;
2842
2704
  toxicResult: number;
2843
2705
  toxicResultType: Enums.ToxicResultType;
@@ -2849,39 +2711,35 @@ export interface ToxicRecordSchemaData {
2849
2711
  * Description: A record of the toxic result type and level at a specific point (x,y,z).
2850
2712
  * ================================================================================
2851
2713
  */
2852
- export class ToxicRecordSchema {
2853
- schema: Joi.ObjectSchema;
2854
- propertyTypes: Record<string, unknown>;
2855
-
2714
+ export class ToxicRecordSchema extends SchemaBase<ToxicRecordSchemaData> {
2856
2715
  constructor() {
2857
- this.schema = Joi.object({
2858
- position: new LocalPositionSchema().schema,
2859
- toxicResult: Joi.number().unsafe(),
2860
- toxicResultType: Joi.string().valid(...Object.values(Enums.ToxicResultType)),
2861
- })
2862
- .pattern(
2863
- ignoredPropertiesRegex,
2864
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2865
- )
2866
- .unknown(false);
2716
+ super();
2717
+ this.schema = this.schema.concat(
2718
+ Joi.object({
2719
+ position: new LocalPositionSchema().schema,
2720
+ toxicResult: Joi.number().unsafe(),
2721
+ toxicResultType: Joi.string().valid(...Object.values(Enums.ToxicResultType)),
2722
+ })
2723
+ )
2724
+ .pattern(
2725
+ ignoredPropertiesRegex,
2726
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2727
+ )
2728
+ .unknown(false);
2867
2729
 
2868
2730
  this.propertyTypes = {
2731
+ ...this.propertyTypes,
2869
2732
  position: "LocalPosition",
2870
2733
  toxicResult: "number",
2871
2734
  toxicResultType: "Enums.ToxicResultType",
2872
2735
  };
2873
2736
  }
2874
2737
 
2875
- validate(data: ToxicRecordSchemaData): Entities.ToxicRecord {
2876
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2877
- if (error) {
2878
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2879
- }
2880
- return this.makeEntity(value);
2881
- }
2882
-
2883
2738
  makeEntity(data: ToxicRecordSchemaData): Entities.ToxicRecord {
2884
2739
  return new Entities.ToxicRecord(
2740
+ data.id,
2741
+ data.typeId,
2742
+ data.displayName,
2885
2743
  data.position,
2886
2744
  data.toxicResult,
2887
2745
  data.toxicResultType
@@ -2889,7 +2747,7 @@ export class ToxicRecordSchema {
2889
2747
  }
2890
2748
  }
2891
2749
 
2892
- export interface VesselSchemaData {
2750
+ export interface VesselSchemaData extends SchemaBaseData {
2893
2751
  location: Entities.LocalPosition;
2894
2752
  state: Entities.State;
2895
2753
  material: Entities.Material;
@@ -2908,30 +2766,31 @@ export interface VesselSchemaData {
2908
2766
  * Description: A pressue vessel asset to represent pressurised containment.
2909
2767
  * ================================================================================
2910
2768
  */
2911
- export class VesselSchema {
2912
- schema: Joi.ObjectSchema;
2913
- propertyTypes: Record<string, unknown>;
2914
-
2769
+ export class VesselSchema extends SchemaBase<VesselSchemaData> {
2915
2770
  constructor() {
2916
- this.schema = Joi.object({
2917
- location: new LocalPositionSchema().schema,
2918
- state: new StateSchema().schema,
2919
- material: new MaterialSchema().schema,
2920
- diameter: Joi.number().unsafe(),
2921
- height: Joi.number().unsafe(),
2922
- length: Joi.number().unsafe(),
2923
- width: Joi.number().unsafe(),
2924
- shape: Joi.string().valid(...Object.values(Enums.VesselShape)),
2925
- vesselConditions: Joi.string().valid(...Object.values(Enums.VesselConditions)),
2926
- liquidFillFractionByVolume: Joi.number().unsafe(),
2927
- })
2928
- .pattern(
2929
- ignoredPropertiesRegex,
2930
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2931
- )
2932
- .unknown(false);
2771
+ super();
2772
+ this.schema = this.schema.concat(
2773
+ Joi.object({
2774
+ location: new LocalPositionSchema().schema,
2775
+ state: new StateSchema().schema,
2776
+ material: new MaterialSchema().schema,
2777
+ diameter: Joi.number().unsafe(),
2778
+ height: Joi.number().unsafe(),
2779
+ length: Joi.number().unsafe(),
2780
+ width: Joi.number().unsafe(),
2781
+ shape: Joi.string().valid(...Object.values(Enums.VesselShape)),
2782
+ vesselConditions: Joi.string().valid(...Object.values(Enums.VesselConditions)),
2783
+ liquidFillFractionByVolume: Joi.number().unsafe(),
2784
+ })
2785
+ )
2786
+ .pattern(
2787
+ ignoredPropertiesRegex,
2788
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2789
+ )
2790
+ .unknown(false);
2933
2791
 
2934
2792
  this.propertyTypes = {
2793
+ ...this.propertyTypes,
2935
2794
  location: "LocalPosition",
2936
2795
  state: "State",
2937
2796
  material: "Material",
@@ -2945,16 +2804,11 @@ export class VesselSchema {
2945
2804
  };
2946
2805
  }
2947
2806
 
2948
- validate(data: VesselSchemaData): Entities.Vessel {
2949
- const { error, value } = this.schema.validate(data, { abortEarly: false });
2950
- if (error) {
2951
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
2952
- }
2953
- return this.makeEntity(value);
2954
- }
2955
-
2956
2807
  makeEntity(data: VesselSchemaData): Entities.Vessel {
2957
2808
  return new Entities.Vessel(
2809
+ data.id,
2810
+ data.typeId,
2811
+ data.displayName,
2958
2812
  data.location,
2959
2813
  data.state,
2960
2814
  data.material,
@@ -2969,7 +2823,7 @@ export class VesselSchema {
2969
2823
  }
2970
2824
  }
2971
2825
 
2972
- export interface VesselLeakMaxFlammableCloudResultsSchemaData {
2826
+ export interface VesselLeakMaxFlammableCloudResultsSchemaData extends SchemaBaseData {
2973
2827
  dischargeRate: number;
2974
2828
  expandedTemperature: number;
2975
2829
  lflExtent: number;
@@ -2984,26 +2838,27 @@ export interface VesselLeakMaxFlammableCloudResultsSchemaData {
2984
2838
  * Description: Results for a linked run of vessel leak followed by dispersion and views from the cloud.
2985
2839
  * ================================================================================
2986
2840
  */
2987
- export class VesselLeakMaxFlammableCloudResultsSchema {
2988
- schema: Joi.ObjectSchema;
2989
- propertyTypes: Record<string, unknown>;
2990
-
2841
+ export class VesselLeakMaxFlammableCloudResultsSchema extends SchemaBase<VesselLeakMaxFlammableCloudResultsSchemaData> {
2991
2842
  constructor() {
2992
- this.schema = Joi.object({
2993
- dischargeRate: Joi.number().unsafe(),
2994
- expandedTemperature: Joi.number().unsafe(),
2995
- lflExtent: Joi.number().unsafe(),
2996
- lflArea: Joi.number().unsafe(),
2997
- lflHeight: Joi.number().unsafe(),
2998
- phase: Joi.string().valid(...Object.values(Enums.Phase)),
2999
- })
3000
- .pattern(
3001
- ignoredPropertiesRegex,
3002
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
3003
- )
3004
- .unknown(false);
2843
+ super();
2844
+ this.schema = this.schema.concat(
2845
+ Joi.object({
2846
+ dischargeRate: Joi.number().unsafe(),
2847
+ expandedTemperature: Joi.number().unsafe(),
2848
+ lflExtent: Joi.number().unsafe(),
2849
+ lflArea: Joi.number().unsafe(),
2850
+ lflHeight: Joi.number().unsafe(),
2851
+ phase: Joi.string().valid(...Object.values(Enums.Phase)),
2852
+ })
2853
+ )
2854
+ .pattern(
2855
+ ignoredPropertiesRegex,
2856
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2857
+ )
2858
+ .unknown(false);
3005
2859
 
3006
2860
  this.propertyTypes = {
2861
+ ...this.propertyTypes,
3007
2862
  dischargeRate: "number",
3008
2863
  expandedTemperature: "number",
3009
2864
  lflExtent: "number",
@@ -3013,16 +2868,11 @@ export class VesselLeakMaxFlammableCloudResultsSchema {
3013
2868
  };
3014
2869
  }
3015
2870
 
3016
- validate(data: VesselLeakMaxFlammableCloudResultsSchemaData): Entities.VesselLeakMaxFlammableCloudResults {
3017
- const { error, value } = this.schema.validate(data, { abortEarly: false });
3018
- if (error) {
3019
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
3020
- }
3021
- return this.makeEntity(value);
3022
- }
3023
-
3024
2871
  makeEntity(data: VesselLeakMaxFlammableCloudResultsSchemaData): Entities.VesselLeakMaxFlammableCloudResults {
3025
2872
  return new Entities.VesselLeakMaxFlammableCloudResults(
2873
+ data.id,
2874
+ data.typeId,
2875
+ data.displayName,
3026
2876
  data.dischargeRate,
3027
2877
  data.expandedTemperature,
3028
2878
  data.lflExtent,
@@ -3033,7 +2883,7 @@ export class VesselLeakMaxFlammableCloudResultsSchema {
3033
2883
  }
3034
2884
  }
3035
2885
 
3036
- export interface VesselSphereSchemaData {
2886
+ export interface VesselSphereSchemaData extends SchemaBaseData {
3037
2887
  location: Entities.LocalPosition;
3038
2888
  state: Entities.State;
3039
2889
  material: Entities.Material;
@@ -3046,24 +2896,25 @@ export interface VesselSphereSchemaData {
3046
2896
  * Description: A spherical pressue vessel asset to represent pressurised containment.
3047
2897
  * ================================================================================
3048
2898
  */
3049
- export class VesselSphereSchema {
3050
- schema: Joi.ObjectSchema;
3051
- propertyTypes: Record<string, unknown>;
3052
-
2899
+ export class VesselSphereSchema extends SchemaBase<VesselSphereSchemaData> {
3053
2900
  constructor() {
3054
- this.schema = Joi.object({
3055
- location: new LocalPositionSchema().schema,
3056
- state: new StateSchema().schema,
3057
- material: new MaterialSchema().schema,
3058
- massInventory: Joi.number().unsafe(),
3059
- })
3060
- .pattern(
3061
- ignoredPropertiesRegex,
3062
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
3063
- )
3064
- .unknown(false);
2901
+ super();
2902
+ this.schema = this.schema.concat(
2903
+ Joi.object({
2904
+ location: new LocalPositionSchema().schema,
2905
+ state: new StateSchema().schema,
2906
+ material: new MaterialSchema().schema,
2907
+ massInventory: Joi.number().unsafe(),
2908
+ })
2909
+ )
2910
+ .pattern(
2911
+ ignoredPropertiesRegex,
2912
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2913
+ )
2914
+ .unknown(false);
3065
2915
 
3066
2916
  this.propertyTypes = {
2917
+ ...this.propertyTypes,
3067
2918
  location: "LocalPosition",
3068
2919
  state: "State",
3069
2920
  material: "Material",
@@ -3071,16 +2922,11 @@ export class VesselSphereSchema {
3071
2922
  };
3072
2923
  }
3073
2924
 
3074
- validate(data: VesselSphereSchemaData): Entities.VesselSphere {
3075
- const { error, value } = this.schema.validate(data, { abortEarly: false });
3076
- if (error) {
3077
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
3078
- }
3079
- return this.makeEntity(value);
3080
- }
3081
-
3082
2925
  makeEntity(data: VesselSphereSchemaData): Entities.VesselSphere {
3083
2926
  return new Entities.VesselSphere(
2927
+ data.id,
2928
+ data.typeId,
2929
+ data.displayName,
3084
2930
  data.location,
3085
2931
  data.state,
3086
2932
  data.material,
@@ -3089,7 +2935,7 @@ export class VesselSphereSchema {
3089
2935
  }
3090
2936
  }
3091
2937
 
3092
- export interface WeatherSchemaData {
2938
+ export interface WeatherSchemaData extends SchemaBaseData {
3093
2939
  windSpeed: number;
3094
2940
  stabilityClass: Enums.AtmosphericStabilityClass;
3095
2941
  temperature: number;
@@ -3104,26 +2950,27 @@ export interface WeatherSchemaData {
3104
2950
  * Description: A set of weather conditions for use in the modelling of a release and its effects.
3105
2951
  * ================================================================================
3106
2952
  */
3107
- export class WeatherSchema {
3108
- schema: Joi.ObjectSchema;
3109
- propertyTypes: Record<string, unknown>;
3110
-
2953
+ export class WeatherSchema extends SchemaBase<WeatherSchemaData> {
3111
2954
  constructor() {
3112
- this.schema = Joi.object({
3113
- windSpeed: Joi.number().unsafe(),
3114
- stabilityClass: Joi.string().valid(...Object.values(Enums.AtmosphericStabilityClass)),
3115
- temperature: Joi.number().unsafe(),
3116
- relativeHumidity: Joi.number().unsafe(),
3117
- mixingLayerHeight: Joi.number().unsafe(),
3118
- solarRadiation: Joi.number().unsafe(),
3119
- })
3120
- .pattern(
3121
- ignoredPropertiesRegex,
3122
- Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
3123
- )
3124
- .unknown(false);
2955
+ super();
2956
+ this.schema = this.schema.concat(
2957
+ Joi.object({
2958
+ windSpeed: Joi.number().unsafe(),
2959
+ stabilityClass: Joi.string().valid(...Object.values(Enums.AtmosphericStabilityClass)),
2960
+ temperature: Joi.number().unsafe(),
2961
+ relativeHumidity: Joi.number().unsafe(),
2962
+ mixingLayerHeight: Joi.number().unsafe(),
2963
+ solarRadiation: Joi.number().unsafe(),
2964
+ })
2965
+ )
2966
+ .pattern(
2967
+ ignoredPropertiesRegex,
2968
+ Joi.alternatives().try(Joi.string(), Joi.number(), Joi.date(), Joi.any())
2969
+ )
2970
+ .unknown(false);
3125
2971
 
3126
2972
  this.propertyTypes = {
2973
+ ...this.propertyTypes,
3127
2974
  windSpeed: "number",
3128
2975
  stabilityClass: "Enums.AtmosphericStabilityClass",
3129
2976
  temperature: "number",
@@ -3133,16 +2980,11 @@ export class WeatherSchema {
3133
2980
  };
3134
2981
  }
3135
2982
 
3136
- validate(data: WeatherSchemaData): Entities.Weather {
3137
- const { error, value } = this.schema.validate(data, { abortEarly: false });
3138
- if (error) {
3139
- throw new Error(`Validation error: ${error.details.map((x) => x.message).join(", ")}`);
3140
- }
3141
- return this.makeEntity(value);
3142
- }
3143
-
3144
2983
  makeEntity(data: WeatherSchemaData): Entities.Weather {
3145
2984
  return new Entities.Weather(
2985
+ data.id,
2986
+ data.typeId,
2987
+ data.displayName,
3146
2988
  data.windSpeed,
3147
2989
  data.stabilityClass,
3148
2990
  data.temperature,