@itwin/core-quantity 5.2.0-dev.8 → 5.3.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -1
- package/lib/cjs/Formatter/Format.d.ts +5 -3
- package/lib/cjs/Formatter/Format.d.ts.map +1 -1
- package/lib/cjs/Formatter/Format.js +97 -50
- package/lib/cjs/Formatter/Format.js.map +1 -1
- package/lib/cjs/Formatter/Interfaces.d.ts +48 -9
- package/lib/cjs/Formatter/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Formatter/Interfaces.js.map +1 -1
- package/lib/esm/Formatter/Format.d.ts +5 -3
- package/lib/esm/Formatter/Format.d.ts.map +1 -1
- package/lib/esm/Formatter/Format.js +97 -50
- package/lib/esm/Formatter/Format.js.map +1 -1
- package/lib/esm/Formatter/Interfaces.d.ts +48 -9
- package/lib/esm/Formatter/Interfaces.d.ts.map +1 -1
- package/lib/esm/Formatter/Interfaces.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
# Change Log - @itwin/core-quantity
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 24 Sep 2025 17:43:58 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.1.9
|
|
6
|
+
Wed, 24 Sep 2025 17:38:08 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 5.1.8
|
|
11
|
+
Wed, 17 Sep 2025 17:17:16 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 5.1.7
|
|
16
|
+
Tue, 09 Sep 2025 19:28:04 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 5.1.6
|
|
21
|
+
Mon, 08 Sep 2025 13:53:47 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 5.1.5
|
|
26
|
+
Thu, 04 Sep 2025 13:51:09 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 5.1.4
|
|
31
|
+
Fri, 22 Aug 2025 14:22:33 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
34
|
+
|
|
35
|
+
## 5.1.3
|
|
36
|
+
Wed, 20 Aug 2025 13:57:10 GMT
|
|
37
|
+
|
|
38
|
+
_Version update only_
|
|
4
39
|
|
|
5
40
|
## 5.1.2
|
|
6
41
|
Thu, 14 Aug 2025 19:38:08 GMT
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { UnitProps, UnitsProvider } from "../Interfaces";
|
|
5
5
|
import { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, RatioType, ScientificType, ShowSignOption } from "./FormatEnums";
|
|
6
|
-
import { CloneOptions, FormatProps } from "./Interfaces";
|
|
6
|
+
import { CloneOptions, FormatProps, ResolvedFormatProps } from "./Interfaces";
|
|
7
7
|
/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes
|
|
8
8
|
* @beta
|
|
9
9
|
*/
|
|
@@ -83,7 +83,7 @@ export declare class BaseFormat {
|
|
|
83
83
|
parseFormatTraits(formatTraitsFromJson: string | string[]): void;
|
|
84
84
|
/** This method returns true if the formatTrait is set in this Format object. */
|
|
85
85
|
hasFormatTraitSet(formatTrait: FormatTraits): boolean;
|
|
86
|
-
loadFormatProperties(formatProps: FormatProps): void;
|
|
86
|
+
loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps): void;
|
|
87
87
|
}
|
|
88
88
|
/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].
|
|
89
89
|
* @beta
|
|
@@ -99,7 +99,6 @@ export declare class Format extends BaseFormat {
|
|
|
99
99
|
get hasUnits(): boolean;
|
|
100
100
|
get customProps(): any;
|
|
101
101
|
static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits): boolean;
|
|
102
|
-
private createUnit;
|
|
103
102
|
/**
|
|
104
103
|
* Clone Format
|
|
105
104
|
*/
|
|
@@ -108,11 +107,14 @@ export declare class Format extends BaseFormat {
|
|
|
108
107
|
* Populates this Format with the values from the provided.
|
|
109
108
|
*/
|
|
110
109
|
fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void>;
|
|
110
|
+
fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void;
|
|
111
111
|
/** Create a Format from FormatProps */
|
|
112
112
|
static createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps): Promise<Format>;
|
|
113
|
+
static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps): Format;
|
|
113
114
|
/**
|
|
114
115
|
* Returns a JSON object that contain the specification for this Format.
|
|
115
116
|
*/
|
|
116
117
|
toJSON(): FormatProps;
|
|
118
|
+
toFullyResolvedJSON(): ResolvedFormatProps;
|
|
117
119
|
}
|
|
118
120
|
//# sourceMappingURL=Format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Format.d.ts","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAuB,UAAU,EAAE,mBAAmB,EAEpF,SAAS,EAAE,cAAc,EACzB,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"Format.d.ts","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAuB,UAAU,EAAE,mBAAmB,EAEpF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AED;;GAEG;AACH,qBAAa,MAAO,SAAQ,UAAU;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC1D,SAAS,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC;IAE7B;;OAEG;gBACS,IAAI,EAAE,MAAM;IAIxB,IAAW,KAAK,IAAI,KAAK,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAwB;IAC9F,IAAW,QAAQ,IAAI,OAAO,CAAgE;IAC9F,IAAW,WAAW,IAAI,GAAG,CAA8B;WAE7C,uBAAuB,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY;IAQnF;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAyD5C;;OAEG;IACU,QAAQ,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjF,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAwDhE,uCAAuC;WACnB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW;WAMzF,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;IAMxF;;OAEG;IACI,MAAM,IAAI,WAAW;IAerB,mBAAmB,IAAI,mBAAmB;CA6ClD"}
|
|
@@ -11,7 +11,6 @@ exports.Format = exports.BaseFormat = void 0;
|
|
|
11
11
|
const Constants_1 = require("../Constants");
|
|
12
12
|
const Exception_1 = require("../Exception");
|
|
13
13
|
const FormatEnums_1 = require("./FormatEnums");
|
|
14
|
-
const Interfaces_1 = require("./Interfaces");
|
|
15
14
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
16
15
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
17
16
|
/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes
|
|
@@ -225,19 +224,6 @@ class Format extends BaseFormat {
|
|
|
225
224
|
const traitStr = (0, FormatEnums_1.getTraitString)(trait);
|
|
226
225
|
return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;
|
|
227
226
|
}
|
|
228
|
-
async createUnit(unitsProvider, name, label) {
|
|
229
|
-
if (name === undefined || typeof (name) !== "string" || (label !== undefined && typeof (label) !== "string")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string
|
|
230
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);
|
|
231
|
-
for (const unit of this.units) {
|
|
232
|
-
const unitObj = unit[0].name;
|
|
233
|
-
if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed
|
|
234
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);
|
|
235
|
-
}
|
|
236
|
-
const newUnit = await unitsProvider.findUnitByName(name);
|
|
237
|
-
if (!newUnit || !newUnit.isValid)
|
|
238
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);
|
|
239
|
-
this.units.push([newUnit, label]);
|
|
240
|
-
}
|
|
241
227
|
/**
|
|
242
228
|
* Clone Format
|
|
243
229
|
*/
|
|
@@ -297,9 +283,12 @@ class Format extends BaseFormat {
|
|
|
297
283
|
* Populates this Format with the values from the provided.
|
|
298
284
|
*/
|
|
299
285
|
async fromJSON(unitsProvider, jsonObj) {
|
|
286
|
+
const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);
|
|
287
|
+
return this.fromFullyResolvedJSON(json);
|
|
288
|
+
}
|
|
289
|
+
fromFullyResolvedJSON(jsonObj) {
|
|
300
290
|
this.loadFormatProperties(jsonObj);
|
|
301
|
-
|
|
302
|
-
this._customProps = jsonObj.custom;
|
|
291
|
+
this._customProps = jsonObj.custom;
|
|
303
292
|
if (undefined !== jsonObj.composite) { // optional
|
|
304
293
|
this._units = new Array();
|
|
305
294
|
if (jsonObj.composite.includeZero !== undefined) {
|
|
@@ -319,15 +308,19 @@ class Format extends BaseFormat {
|
|
|
319
308
|
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);
|
|
320
309
|
}
|
|
321
310
|
if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
311
|
+
for (const nextUnit of jsonObj.composite.units) {
|
|
312
|
+
if (this._units) {
|
|
313
|
+
for (const existingUnit of this._units) {
|
|
314
|
+
const unitObj = existingUnit[0].name;
|
|
315
|
+
if (unitObj.toLowerCase() === nextUnit.unit.name.toLowerCase()) {
|
|
316
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
326
319
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
320
|
+
if (undefined === this._units) {
|
|
321
|
+
this._units = [];
|
|
322
|
+
}
|
|
323
|
+
this._units.push([nextUnit.unit, nextUnit.label]);
|
|
331
324
|
}
|
|
332
325
|
}
|
|
333
326
|
}
|
|
@@ -335,23 +328,8 @@ class Format extends BaseFormat {
|
|
|
335
328
|
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);
|
|
336
329
|
}
|
|
337
330
|
if (this.type === FormatEnums_1.FormatType.Azimuth || this.type === FormatEnums_1.FormatType.Bearing) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (typeof (jsonObj.azimuthBaseUnit) !== "string")
|
|
341
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBaseUnit' attribute. It should be of type 'string'.`);
|
|
342
|
-
const baseUnit = await unitsProvider.findUnitByName(jsonObj.azimuthBaseUnit);
|
|
343
|
-
if (!baseUnit || !baseUnit.isValid)
|
|
344
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.azimuthBaseUnit}' for azimuthBaseUnit in Format '${this.name}'.`);
|
|
345
|
-
this._azimuthBaseUnit = baseUnit;
|
|
346
|
-
}
|
|
347
|
-
if (undefined !== jsonObj.revolutionUnit) {
|
|
348
|
-
if (typeof (jsonObj.revolutionUnit) !== "string")
|
|
349
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'revolutionUnit' attribute. It should be of type 'string'.`);
|
|
350
|
-
const revolutionUnit = await unitsProvider.findUnitByName(jsonObj.revolutionUnit);
|
|
351
|
-
if (!revolutionUnit || !revolutionUnit.isValid)
|
|
352
|
-
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.revolutionUnit}' for revolutionUnit in Format '${this.name}'.`);
|
|
353
|
-
this._revolutionUnit = revolutionUnit;
|
|
354
|
-
}
|
|
331
|
+
this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;
|
|
332
|
+
this._revolutionUnit = jsonObj.revolutionUnit;
|
|
355
333
|
if (this._revolutionUnit === undefined)
|
|
356
334
|
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);
|
|
357
335
|
if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)
|
|
@@ -364,17 +342,36 @@ class Format extends BaseFormat {
|
|
|
364
342
|
await actualFormat.fromJSON(unitsProvider, formatProps);
|
|
365
343
|
return actualFormat;
|
|
366
344
|
}
|
|
345
|
+
static createFromFullyResolvedJSON(name, formatProps) {
|
|
346
|
+
const actualFormat = new Format(name);
|
|
347
|
+
actualFormat.fromFullyResolvedJSON(formatProps);
|
|
348
|
+
return actualFormat;
|
|
349
|
+
}
|
|
367
350
|
/**
|
|
368
351
|
* Returns a JSON object that contain the specification for this Format.
|
|
369
352
|
*/
|
|
370
353
|
toJSON() {
|
|
354
|
+
const json = this.toFullyResolvedJSON();
|
|
355
|
+
return {
|
|
356
|
+
...json,
|
|
357
|
+
azimuthBaseUnit: json.azimuthBaseUnit?.name,
|
|
358
|
+
revolutionUnit: json.revolutionUnit?.name,
|
|
359
|
+
composite: json.composite ? {
|
|
360
|
+
...json.composite,
|
|
361
|
+
units: json.composite.units.map((unit) => {
|
|
362
|
+
return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };
|
|
363
|
+
}),
|
|
364
|
+
} : undefined,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
toFullyResolvedJSON() {
|
|
371
368
|
let composite;
|
|
372
369
|
if (this.units) {
|
|
373
370
|
const units = this.units.map((value) => {
|
|
374
371
|
if (undefined !== value[1])
|
|
375
|
-
return {
|
|
372
|
+
return { unit: value[0], label: value[1] };
|
|
376
373
|
else
|
|
377
|
-
return {
|
|
374
|
+
return { unit: value[0] };
|
|
378
375
|
});
|
|
379
376
|
composite = {
|
|
380
377
|
spacer: this.spacer,
|
|
@@ -382,8 +379,8 @@ class Format extends BaseFormat {
|
|
|
382
379
|
units,
|
|
383
380
|
};
|
|
384
381
|
}
|
|
385
|
-
const azimuthBaseUnit = this.azimuthBaseUnit
|
|
386
|
-
const revolutionUnit = this.revolutionUnit
|
|
382
|
+
const azimuthBaseUnit = this.azimuthBaseUnit;
|
|
383
|
+
const revolutionUnit = this.revolutionUnit;
|
|
387
384
|
const baseFormatProps = {
|
|
388
385
|
type: this.type,
|
|
389
386
|
precision: this.precision,
|
|
@@ -404,14 +401,64 @@ class Format extends BaseFormat {
|
|
|
404
401
|
azimuthCounterClockwise: this.azimuthCounterClockwise,
|
|
405
402
|
revolutionUnit,
|
|
406
403
|
composite,
|
|
404
|
+
custom: this.customProps,
|
|
407
405
|
};
|
|
408
|
-
if (this.customProps)
|
|
409
|
-
return {
|
|
410
|
-
...baseFormatProps,
|
|
411
|
-
custom: this.customProps,
|
|
412
|
-
};
|
|
413
406
|
return baseFormatProps;
|
|
414
407
|
}
|
|
415
408
|
}
|
|
416
409
|
exports.Format = Format;
|
|
410
|
+
async function resolveCompositeUnit(provider, name, label) {
|
|
411
|
+
if (typeof name !== "string" || (undefined !== label && typeof label !== "string")) {
|
|
412
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);
|
|
413
|
+
}
|
|
414
|
+
const unit = await provider.findUnitByName(name);
|
|
415
|
+
if (!unit || !unit.isValid) {
|
|
416
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);
|
|
417
|
+
}
|
|
418
|
+
return unit;
|
|
419
|
+
}
|
|
420
|
+
async function resolveAzimuthBearingUnit(formatName, jsonObj, key, provider) {
|
|
421
|
+
const unitName = jsonObj[key];
|
|
422
|
+
if (undefined !== unitName) {
|
|
423
|
+
if (typeof unitName !== "string") {
|
|
424
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);
|
|
425
|
+
}
|
|
426
|
+
const unit = await provider.findUnitByName(unitName);
|
|
427
|
+
if (!unit || !unit.isValid) {
|
|
428
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);
|
|
429
|
+
}
|
|
430
|
+
return unit;
|
|
431
|
+
}
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
async function resolveFormatProps(formatName, unitsProvider, jsonObj) {
|
|
435
|
+
let units;
|
|
436
|
+
if (undefined !== jsonObj.composite?.units) {
|
|
437
|
+
units = await Promise.all(jsonObj.composite.units.map(async (entry) => {
|
|
438
|
+
const unit = await resolveCompositeUnit(unitsProvider, entry.name);
|
|
439
|
+
return { unit, label: entry.label };
|
|
440
|
+
}));
|
|
441
|
+
}
|
|
442
|
+
let azimuthBaseUnit, revolutionUnit;
|
|
443
|
+
const type = (0, FormatEnums_1.parseFormatType)(jsonObj.type, formatName);
|
|
444
|
+
if (type === FormatEnums_1.FormatType.Azimuth || type === FormatEnums_1.FormatType.Bearing) {
|
|
445
|
+
azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, "azimuthBaseUnit", unitsProvider);
|
|
446
|
+
revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, "revolutionUnit", unitsProvider);
|
|
447
|
+
if (!revolutionUnit) {
|
|
448
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);
|
|
449
|
+
}
|
|
450
|
+
if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {
|
|
451
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
...jsonObj,
|
|
456
|
+
azimuthBaseUnit,
|
|
457
|
+
revolutionUnit,
|
|
458
|
+
composite: units ? {
|
|
459
|
+
...jsonObj.composite,
|
|
460
|
+
units,
|
|
461
|
+
} : undefined,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
417
464
|
//# sourceMappingURL=Format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter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C,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAElF,MAAM,eAAe,GAAgB;YACnC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,YAAY,EAAE,IAAA,iCAAmB,EAAC,IAAI,CAAC,YAAY,CAAC;YACpD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;YACrE,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,eAAe;YACf,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,cAAc;YACd,SAAS;SACV,CAAC;QAEF,IAAI,IAAI,CAAC,WAAW;YAClB,OAAO;gBACL,GAAG,eAAe;gBAClB,MAAM,EAAE,IAAI,CAAC,WAAW;aACJ,CAAC;QAEzB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAzOD,wBAyOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\nimport {\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n getTraitString, parseFormatTrait, parseFormatType, parsePrecision, parseRatioType, parseScientificType, parseShowSignOption,\n RatioType, ScientificType,\n ShowSignOption,\n} from \"./FormatEnums\";\nimport { CloneOptions, CustomFormatProps, FormatProps, isCustomFormatProps } from \"./Interfaces\";\n\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\n\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\n * @beta\n */\nexport class BaseFormat {\n private _name = \"\";\n protected _roundFactor: number = 0.0;\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\n protected _precision: number = DecimalPrecision.Six; // required\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\n protected _spacer: string = \" \"; // optional; default is \" \"\n protected _includeZero: boolean = true; // optional; default is true\n protected _minWidth?: number; // optional; positive int\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\n protected _azimuthBase?: number; // value always clockwise from north\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\n\n constructor(name: string) {\n this._name = name;\n }\n\n public get name(): string { return this._name; }\n\n public get roundFactor(): number { return this._roundFactor; }\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\n\n public get type(): FormatType { return this._type; }\n public set type(formatType: FormatType) { this._type = formatType; }\n\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\n\n public get minWidth(): number | undefined { return this._minWidth; }\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\n\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\n\n public get ratioType(): RatioType | undefined { return this._ratioType; }\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\n\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\n\n public get decimalSeparator(): string { return this._decimalSeparator; }\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\n\n public get thousandSeparator(): string { return this._thousandSeparator; }\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\n\n public get uomSeparator(): string { return this._uomSeparator; }\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\n\n public get stationSeparator(): string { return this._stationSeparator; }\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\n\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\n\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\n * for the base offset calculation. The default value is 1.\n */\n public get stationBaseFactor(): number | undefined {\n return this._stationBaseFactor;\n }\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\n this._stationBaseFactor = stationBaseFactor;\n }\n\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\n\n public get formatTraits(): FormatTraits { return this._formatTraits; }\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\n\n public get spacer(): string | undefined { return this._spacer; }\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\n\n public get includeZero(): boolean | undefined { return this._includeZero; }\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\n\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\n\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\n\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\n\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\n this._formatTraits = this.formatTraits | formatTrait;\n });\n }\n\n /** This method returns true if the formatTrait is set in this Format object. */\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\n return (this._formatTraits & formatTrait) === formatTrait;\n }\n\n public loadFormatProperties(formatProps: FormatProps) {\n this._type = parseFormatType(formatProps.type, this.name);\n\n if (formatProps.precision !== undefined) {\n if (!Number.isInteger(formatProps.precision)) // mut be an integer\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\n\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\n }\n if (this.type === FormatType.Scientific) {\n if (undefined === formatProps.scientificType) // if format type is scientific and scientific type is undefined, throw\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\n\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\n }\n\n if (this.type === FormatType.Ratio){\n if (undefined === formatProps.ratioType)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\n\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\n }\n\n if (undefined !== formatProps.roundFactor) { // optional; default is 0.0\n if (typeof (formatProps.roundFactor) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\n this._roundFactor = formatProps.roundFactor;\n }\n\n if (undefined !== formatProps.minWidth) { // optional\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0) // must be a positive int\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\n this._minWidth = formatProps.minWidth;\n }\n if (FormatType.Station === this.type) {\n if (undefined === formatProps.stationOffsetSize)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0) // must be a positive int > 0\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\n this._stationOffsetSize = formatProps.stationOffsetSize;\n\n if (undefined !== formatProps.stationBaseFactor) {\n // optional - must be a positive integer\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\n this._stationBaseFactor = formatProps.stationBaseFactor;\n }\n }\n\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\n }\n\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) { // FormatTraits is optional\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\") // must be either an array of strings or a string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\n this.parseFormatTraits(formatProps.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\n }\n\n if (undefined !== formatProps.decimalSeparator) { // optional\n if (typeof (formatProps.decimalSeparator) !== \"string\") // not a string or not a one character string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.decimalSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\n this._decimalSeparator = formatProps.decimalSeparator;\n }\n\n if (undefined !== formatProps.thousandSeparator) { // optional\n if (typeof (formatProps.thousandSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.thousandSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\n this._thousandSeparator = formatProps.thousandSeparator;\n }\n\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\n if (typeof (formatProps.uomSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\n this._uomSeparator = formatProps.uomSeparator;\n }\n\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\n if (typeof (formatProps.stationSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.stationSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\n this._stationSeparator = formatProps.stationSeparator;\n }\n\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\n if (typeof (formatProps.azimuthBase) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\n this._azimuthBase = formatProps.azimuthBase;\n }\n\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\n }\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\n }\n }\n}\n\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\n * @beta\n */\nexport class Format extends BaseFormat {\n protected _units?: Array<[UnitProps, string | undefined]>;\n protected _customProps?: any; // used by custom formatters and parsers\n\n /** Constructor\n * @param name The name of a format specification. TODO: make optional or remove\n */\n constructor(name: string) {\n super(name);\n }\n\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\n public get customProps(): any { return this._customProps; }\n\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\n if (!formatProps.formatTraits)\n return false;\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\n const traitStr = getTraitString(trait);\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\n }\n\n private async createUnit(unitsProvider: UnitsProvider, name: string, label?: string): Promise<void> {\n if (name === undefined || typeof (name) !== \"string\" || (label !== undefined && typeof (label) !== \"string\")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\n for (const unit of this.units!) {\n const unitObj = unit[0].name;\n if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\n }\n const newUnit: UnitProps = await unitsProvider.findUnitByName(name);\n if (!newUnit || !newUnit.isValid)\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\n this.units!.push([newUnit, label]);\n }\n\n /**\n * Clone Format\n */\n public clone(options?: CloneOptions): Format {\n const newFormat = new Format(this.name);\n newFormat._roundFactor = this._roundFactor;\n newFormat._type = this._type;\n newFormat._precision = this._precision;\n newFormat._minWidth = this._minWidth;\n newFormat._scientificType = this._scientificType;\n newFormat._showSignOption = this._showSignOption;\n newFormat._decimalSeparator = this._decimalSeparator;\n newFormat._thousandSeparator = this._thousandSeparator;\n newFormat._uomSeparator = this._uomSeparator;\n newFormat._stationSeparator = this._stationSeparator;\n newFormat._stationOffsetSize = this._stationOffsetSize;\n newFormat._stationBaseFactor = this._stationBaseFactor;\n newFormat._formatTraits = this._formatTraits;\n newFormat._spacer = this._spacer;\n newFormat._includeZero = this._includeZero;\n newFormat._azimuthBase = this._azimuthBase;\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\n newFormat._ratioType = this._ratioType;\n newFormat._revolutionUnit = this._revolutionUnit;\n newFormat._customProps = this._customProps;\n this._units && (newFormat._units = [...this._units]);\n\n if (newFormat._units) {\n if (options?.showOnlyPrimaryUnit) {\n if (newFormat._units.length > 1)\n newFormat._units.length = 1;\n }\n }\n\n if (undefined !== options?.traits)\n newFormat._formatTraits = options?.traits;\n\n if (undefined !== options?.type)\n newFormat._type = options.type;\n\n if (undefined !== options?.precision) {\n // ensure specified precision is valid\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\n newFormat._precision = precision;\n }\n\n if (undefined !== options?.primaryUnit) {\n if (options.primaryUnit.unit) {\n const newUnits = new Array<[UnitProps, string | undefined]>();\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\n newFormat._units = newUnits;\n } else if (options.primaryUnit.label && newFormat._units?.length) {\n // update label only\n newFormat._units[0][1] = options.primaryUnit.label;\n }\n }\n return newFormat;\n }\n\n /**\n * Populates this Format with the values from the provided.\n */\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\n this.loadFormatProperties(jsonObj);\n\n if (isCustomFormatProps(jsonObj))\n this._customProps = jsonObj.custom;\n\n if (undefined !== jsonObj.composite) { // optional\n this._units = new Array<[UnitProps, string | undefined]>();\n if (jsonObj.composite.includeZero !== undefined) {\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\n this._includeZero = jsonObj.composite.includeZero;\n }\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\n if (typeof (jsonObj.composite.spacer) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\n if (jsonObj.composite.spacer.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._spacer = jsonObj.composite.spacer;\n }\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\n }\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\n try {\n const createUnitPromises: Array<Promise<void>> = [];\n for (const unit of jsonObj.composite.units) {\n createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));\n }\n\n await Promise.all(createUnitPromises);\n } catch (e) {\n throw e;\n }\n }\n }\n if (undefined === this.units || this.units.length === 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\n }\n\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\n // these units cannot be loaded from loadFormatProperties() because they require an async call, and the method signature is already public\n\n if (undefined !== jsonObj.azimuthBaseUnit) {\n if (typeof (jsonObj.azimuthBaseUnit) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBaseUnit' attribute. It should be of type 'string'.`);\n\n const baseUnit: UnitProps = await unitsProvider.findUnitByName(jsonObj.azimuthBaseUnit);\n if (!baseUnit || !baseUnit.isValid)\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.azimuthBaseUnit}' for azimuthBaseUnit in Format '${this.name}'.`);\n\n this._azimuthBaseUnit = baseUnit;\n }\n\n if (undefined !== jsonObj.revolutionUnit) {\n if (typeof (jsonObj.revolutionUnit) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'revolutionUnit' attribute. It should be of type 'string'.`);\n\n const revolutionUnit: UnitProps = await unitsProvider.findUnitByName(jsonObj.revolutionUnit);\n if (!revolutionUnit || !revolutionUnit.isValid)\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.revolutionUnit}' for revolutionUnit in Format '${this.name}'.`);\n\n this._revolutionUnit = revolutionUnit;\n }\n\n if (this._revolutionUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\n }\n }\n\n /** Create a Format from FormatProps */\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\n const actualFormat = new Format(name);\n await actualFormat.fromJSON(unitsProvider, formatProps);\n return actualFormat;\n }\n\n /**\n * Returns a JSON object that contain the specification for this Format.\n */\n public toJSON(): FormatProps {\n let composite;\n if (this.units) {\n const units = this.units.map((value) => {\n if (undefined !== value[1])\n return { name: value[0].name, label: value[1] };\n else\n return { name: value[0].name };\n });\n\n composite = {\n spacer: this.spacer,\n includeZero: this.includeZero,\n units,\n };\n }\n\n const azimuthBaseUnit = this.azimuthBaseUnit ? this.azimuthBaseUnit.name : undefined;\n const revolutionUnit = this.revolutionUnit ? this.revolutionUnit.name : undefined;\n\n const baseFormatProps: FormatProps = {\n type: this.type,\n precision: this.precision,\n roundFactor: this.roundFactor,\n minWidth: this.minWidth,\n showSignOption: this.showSignOption,\n formatTraits: formatTraitsToArray(this.formatTraits),\n decimalSeparator: this.decimalSeparator,\n thousandSeparator: this.thousandSeparator,\n uomSeparator: this.uomSeparator,\n scientificType: this.scientificType ? this.scientificType : undefined,\n ratioType: this.ratioType,\n stationOffsetSize: this.stationOffsetSize,\n stationSeparator: this.stationSeparator,\n stationBaseFactor: this.stationBaseFactor,\n azimuthBase: this.azimuthBase,\n azimuthBaseUnit,\n azimuthCounterClockwise: this.azimuthCounterClockwise,\n revolutionUnit,\n composite,\n };\n\n if (this.customProps)\n return {\n ...baseFormatProps,\n custom: this.customProps,\n } as CustomFormatProps;\n\n return baseFormatProps;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,4CAAiD;AACjD,4CAA6D;AAE7D,+CAKuB;AAGvB,sFAAsF;AACtF,6JAA6J;AAE7J;;GAEG;AACH,MAAa,UAAU;IACb,KAAK,GAAG,EAAE,CAAC;IACT,YAAY,GAAW,GAAG,CAAC;IAC3B,KAAK,GAAe,wBAAU,CAAC,OAAO,CAAC,CAAC,iEAAiE;IACzG,UAAU,GAAW,8BAAgB,CAAC,GAAG,CAAC,CAAC,WAAW;IACtD,eAAe,GAAmB,4BAAc,CA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,KAAK;SACN,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\nimport {\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n getTraitString, parseFormatTrait, parseFormatType, parsePrecision, parseRatioType, parseScientificType, parseShowSignOption,\n RatioType, ScientificType,\n ShowSignOption,\n} from \"./FormatEnums\";\nimport { CloneOptions, FormatProps, ResolvedFormatProps } from \"./Interfaces\";\n\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\n\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\n * @beta\n */\nexport class BaseFormat {\n private _name = \"\";\n protected _roundFactor: number = 0.0;\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\n protected _precision: number = DecimalPrecision.Six; // required\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\n protected _spacer: string = \" \"; // optional; default is \" \"\n protected _includeZero: boolean = true; // optional; default is true\n protected _minWidth?: number; // optional; positive int\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\n protected _azimuthBase?: number; // value always clockwise from north\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\n\n constructor(name: string) {\n this._name = name;\n }\n\n public get name(): string { return this._name; }\n\n public get roundFactor(): number { return this._roundFactor; }\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\n\n public get type(): FormatType { return this._type; }\n public set type(formatType: FormatType) { this._type = formatType; }\n\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\n\n public get minWidth(): number | undefined { return this._minWidth; }\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\n\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\n\n public get ratioType(): RatioType | undefined { return this._ratioType; }\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\n\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\n\n public get decimalSeparator(): string { return this._decimalSeparator; }\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\n\n public get thousandSeparator(): string { return this._thousandSeparator; }\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\n\n public get uomSeparator(): string { return this._uomSeparator; }\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\n\n public get stationSeparator(): string { return this._stationSeparator; }\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\n\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\n\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\n * for the base offset calculation. The default value is 1.\n */\n public get stationBaseFactor(): number | undefined {\n return this._stationBaseFactor;\n }\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\n this._stationBaseFactor = stationBaseFactor;\n }\n\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\n\n public get formatTraits(): FormatTraits { return this._formatTraits; }\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\n\n public get spacer(): string | undefined { return this._spacer; }\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\n\n public get includeZero(): boolean | undefined { return this._includeZero; }\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\n\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\n\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\n\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\n\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\n this._formatTraits = this.formatTraits | formatTrait;\n });\n }\n\n /** This method returns true if the formatTrait is set in this Format object. */\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\n return (this._formatTraits & formatTrait) === formatTrait;\n }\n\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\n this._type = parseFormatType(formatProps.type, this.name);\n\n if (formatProps.precision !== undefined) {\n if (!Number.isInteger(formatProps.precision)) // mut be an integer\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\n\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\n }\n if (this.type === FormatType.Scientific) {\n if (undefined === formatProps.scientificType) // if format type is scientific and scientific type is undefined, throw\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\n\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\n }\n\n if (this.type === FormatType.Ratio){\n if (undefined === formatProps.ratioType)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\n\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\n }\n\n if (undefined !== formatProps.roundFactor) { // optional; default is 0.0\n if (typeof (formatProps.roundFactor) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\n this._roundFactor = formatProps.roundFactor;\n }\n\n if (undefined !== formatProps.minWidth) { // optional\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0) // must be a positive int\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\n this._minWidth = formatProps.minWidth;\n }\n if (FormatType.Station === this.type) {\n if (undefined === formatProps.stationOffsetSize)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0) // must be a positive int > 0\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\n this._stationOffsetSize = formatProps.stationOffsetSize;\n\n if (undefined !== formatProps.stationBaseFactor) {\n // optional - must be a positive integer\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\n this._stationBaseFactor = formatProps.stationBaseFactor;\n }\n }\n\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\n }\n\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) { // FormatTraits is optional\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\") // must be either an array of strings or a string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\n this.parseFormatTraits(formatProps.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\n }\n\n if (undefined !== formatProps.decimalSeparator) { // optional\n if (typeof (formatProps.decimalSeparator) !== \"string\") // not a string or not a one character string\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.decimalSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\n this._decimalSeparator = formatProps.decimalSeparator;\n }\n\n if (undefined !== formatProps.thousandSeparator) { // optional\n if (typeof (formatProps.thousandSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.thousandSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\n this._thousandSeparator = formatProps.thousandSeparator;\n }\n\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\n if (typeof (formatProps.uomSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\n this._uomSeparator = formatProps.uomSeparator;\n }\n\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\n if (typeof (formatProps.stationSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.stationSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\n this._stationSeparator = formatProps.stationSeparator;\n }\n\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\n if (typeof (formatProps.azimuthBase) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\n this._azimuthBase = formatProps.azimuthBase;\n }\n\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\n }\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\n }\n }\n}\n\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\n * @beta\n */\nexport class Format extends BaseFormat {\n protected _units?: Array<[UnitProps, string | undefined]>;\n protected _customProps?: any; // used by custom formatters and parsers\n\n /** Constructor\n * @param name The name of a format specification. TODO: make optional or remove\n */\n constructor(name: string) {\n super(name);\n }\n\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\n public get customProps(): any { return this._customProps; }\n\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\n if (!formatProps.formatTraits)\n return false;\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\n const traitStr = getTraitString(trait);\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\n }\n\n /**\n * Clone Format\n */\n public clone(options?: CloneOptions): Format {\n const newFormat = new Format(this.name);\n newFormat._roundFactor = this._roundFactor;\n newFormat._type = this._type;\n newFormat._precision = this._precision;\n newFormat._minWidth = this._minWidth;\n newFormat._scientificType = this._scientificType;\n newFormat._showSignOption = this._showSignOption;\n newFormat._decimalSeparator = this._decimalSeparator;\n newFormat._thousandSeparator = this._thousandSeparator;\n newFormat._uomSeparator = this._uomSeparator;\n newFormat._stationSeparator = this._stationSeparator;\n newFormat._stationOffsetSize = this._stationOffsetSize;\n newFormat._stationBaseFactor = this._stationBaseFactor;\n newFormat._formatTraits = this._formatTraits;\n newFormat._spacer = this._spacer;\n newFormat._includeZero = this._includeZero;\n newFormat._azimuthBase = this._azimuthBase;\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\n newFormat._ratioType = this._ratioType;\n newFormat._revolutionUnit = this._revolutionUnit;\n newFormat._customProps = this._customProps;\n this._units && (newFormat._units = [...this._units]);\n\n if (newFormat._units) {\n if (options?.showOnlyPrimaryUnit) {\n if (newFormat._units.length > 1)\n newFormat._units.length = 1;\n }\n }\n\n if (undefined !== options?.traits)\n newFormat._formatTraits = options?.traits;\n\n if (undefined !== options?.type)\n newFormat._type = options.type;\n\n if (undefined !== options?.precision) {\n // ensure specified precision is valid\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\n newFormat._precision = precision;\n }\n\n if (undefined !== options?.primaryUnit) {\n if (options.primaryUnit.unit) {\n const newUnits = new Array<[UnitProps, string | undefined]>();\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\n newFormat._units = newUnits;\n } else if (options.primaryUnit.label && newFormat._units?.length) {\n // update label only\n newFormat._units[0][1] = options.primaryUnit.label;\n }\n }\n return newFormat;\n }\n\n /**\n * Populates this Format with the values from the provided.\n */\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\n return this.fromFullyResolvedJSON(json);\n }\n\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\n this.loadFormatProperties(jsonObj);\n this._customProps = jsonObj.custom;\n\n if (undefined !== jsonObj.composite) { // optional\n this._units = new Array<[UnitProps, string | undefined]>();\n if (jsonObj.composite.includeZero !== undefined) {\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\n this._includeZero = jsonObj.composite.includeZero;\n }\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\n if (typeof (jsonObj.composite.spacer) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\n if (jsonObj.composite.spacer.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._spacer = jsonObj.composite.spacer;\n }\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\n }\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\n for (const nextUnit of jsonObj.composite.units) {\n if (this._units) {\n for (const existingUnit of this._units) {\n const unitObj = existingUnit[0].name;\n if (unitObj.toLowerCase() === nextUnit.unit.name.toLowerCase()) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\n }\n }\n }\n\n if (undefined === this._units) {\n this._units = [];\n }\n\n this._units.push([nextUnit.unit, nextUnit.label]);\n }\n }\n }\n if (undefined === this.units || this.units.length === 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\n }\n\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\n this._revolutionUnit = jsonObj.revolutionUnit;\n\n if (this._revolutionUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\n }\n }\n\n /** Create a Format from FormatProps */\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\n const actualFormat = new Format(name);\n await actualFormat.fromJSON(unitsProvider, formatProps);\n return actualFormat;\n }\n\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\n const actualFormat = new Format(name);\n actualFormat.fromFullyResolvedJSON(formatProps);\n return actualFormat;\n }\n\n /**\n * Returns a JSON object that contain the specification for this Format.\n */\n public toJSON(): FormatProps {\n const json = this.toFullyResolvedJSON();\n return {\n ...json,\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\n revolutionUnit: json.revolutionUnit?.name,\n composite: json.composite ? {\n ...json.composite,\n units: json.composite.units.map((unit) => {\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\n }),\n } : undefined,\n }\n }\n\n public toFullyResolvedJSON(): ResolvedFormatProps {\n let composite;\n if (this.units) {\n const units = this.units.map((value) => {\n if (undefined !== value[1])\n return { unit: value[0], label: value[1] };\n else\n return { unit: value[0] };\n });\n\n composite = {\n spacer: this.spacer,\n includeZero: this.includeZero,\n units,\n };\n }\n\n const azimuthBaseUnit = this.azimuthBaseUnit;\n const revolutionUnit = this.revolutionUnit;\n\n const baseFormatProps: ResolvedFormatProps = {\n type: this.type,\n precision: this.precision,\n roundFactor: this.roundFactor,\n minWidth: this.minWidth,\n showSignOption: this.showSignOption,\n formatTraits: formatTraitsToArray(this.formatTraits),\n decimalSeparator: this.decimalSeparator,\n thousandSeparator: this.thousandSeparator,\n uomSeparator: this.uomSeparator,\n scientificType: this.scientificType ? this.scientificType : undefined,\n ratioType: this.ratioType,\n stationOffsetSize: this.stationOffsetSize,\n stationSeparator: this.stationSeparator,\n stationBaseFactor: this.stationBaseFactor,\n azimuthBase: this.azimuthBase,\n azimuthBaseUnit,\n azimuthCounterClockwise: this.azimuthCounterClockwise,\n revolutionUnit,\n composite,\n custom: this.customProps,\n };\n\n return baseFormatProps;\n }\n}\n\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\n }\n\n const unit = await provider.findUnitByName(name);\n if (!unit || !unit.isValid) {\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\n }\n\n return unit;\n}\n\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\n const unitName = jsonObj[key];\n if (undefined !== unitName) {\n if (typeof unitName !== \"string\") {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\n }\n\n const unit = await provider.findUnitByName(unitName);\n if (!unit || !unit.isValid) {\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\n }\n\n return unit;\n }\n\n return undefined;\n}\n\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\n let units: Array<{ unit: UnitProps, label?: string }> | undefined;\n if (undefined !== jsonObj.composite?.units) {\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\n return { unit, label: entry.label };\n }));\n }\n\n let azimuthBaseUnit, revolutionUnit;\n const type = parseFormatType(jsonObj.type, formatName);\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\n\n if (!revolutionUnit) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\n }\n\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\n }\n }\n\n return {\n ...jsonObj,\n azimuthBaseUnit,\n revolutionUnit,\n composite: units ? {\n ...jsonObj.composite,\n units,\n } : undefined,\n };\n}\n"]}
|