@itwin/core-quantity 5.2.0-dev.8 → 5.2.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/Exception.js.map +1 -1
  4. package/lib/cjs/Formatter/Format.d.ts +5 -3
  5. package/lib/cjs/Formatter/Format.d.ts.map +1 -1
  6. package/lib/cjs/Formatter/Format.js +97 -50
  7. package/lib/cjs/Formatter/Format.js.map +1 -1
  8. package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
  9. package/lib/cjs/Formatter/Formatter.d.ts +7 -0
  10. package/lib/cjs/Formatter/Formatter.d.ts.map +1 -1
  11. package/lib/cjs/Formatter/Formatter.js +60 -38
  12. package/lib/cjs/Formatter/Formatter.js.map +1 -1
  13. package/lib/cjs/Formatter/FormatterSpec.js.map +1 -1
  14. package/lib/cjs/Formatter/Interfaces.d.ts +48 -9
  15. package/lib/cjs/Formatter/Interfaces.d.ts.map +1 -1
  16. package/lib/cjs/Formatter/Interfaces.js.map +1 -1
  17. package/lib/cjs/Interfaces.js.map +1 -1
  18. package/lib/cjs/Parser.js.map +1 -1
  19. package/lib/cjs/ParserSpec.js.map +1 -1
  20. package/lib/cjs/Quantity.js.map +1 -1
  21. package/lib/cjs/Unit.js.map +1 -1
  22. package/lib/cjs/core-quantity.js.map +1 -1
  23. package/lib/esm/Constants.js.map +1 -1
  24. package/lib/esm/Exception.js.map +1 -1
  25. package/lib/esm/Formatter/Format.d.ts +5 -3
  26. package/lib/esm/Formatter/Format.d.ts.map +1 -1
  27. package/lib/esm/Formatter/Format.js +97 -50
  28. package/lib/esm/Formatter/Format.js.map +1 -1
  29. package/lib/esm/Formatter/FormatEnums.js.map +1 -1
  30. package/lib/esm/Formatter/Formatter.d.ts +7 -0
  31. package/lib/esm/Formatter/Formatter.d.ts.map +1 -1
  32. package/lib/esm/Formatter/Formatter.js +60 -38
  33. package/lib/esm/Formatter/Formatter.js.map +1 -1
  34. package/lib/esm/Formatter/FormatterSpec.js.map +1 -1
  35. package/lib/esm/Formatter/Interfaces.d.ts +48 -9
  36. package/lib/esm/Formatter/Interfaces.d.ts.map +1 -1
  37. package/lib/esm/Formatter/Interfaces.js.map +1 -1
  38. package/lib/esm/Interfaces.js.map +1 -1
  39. package/lib/esm/Parser.js.map +1 -1
  40. package/lib/esm/ParserSpec.js.map +1 -1
  41. package/lib/esm/Quantity.js.map +1 -1
  42. package/lib/esm/Unit.js.map +1 -1
  43. package/lib/esm/core-quantity.js.map +1 -1
  44. package/package.json +4 -4
@@ -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,EAAqB,WAAW,EAAuB,MAAM,cAAc,CAAC;AAKjG;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAM;IACnB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAO;IACrC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAsB;IACjD,SAAS,CAAC,UAAU,EAAE,MAAM,CAAwB;IACpD,SAAS,CAAC,eAAe,EAAE,cAAc,CAA+B;IACxE,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAoD;IACvF,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAqD;IACzF,SAAS,CAAC,aAAa,SAAO;IAC9B,SAAS,CAAC,iBAAiB,SAAO;IAClC,SAAS,CAAC,aAAa,EAAE,YAAY,CAA8B;IACnE,SAAS,CAAC,OAAO,EAAE,MAAM,CAAO;I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A2B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;IAMxF;;OAEG;IACI,MAAM,IAAI,WAAW;IAerB,mBAAmB,IAAI,mBAAmB;CA6ClD"}
@@ -8,7 +8,6 @@
8
8
  import { QuantityConstants } from "../Constants";
9
9
  import { QuantityError, QuantityStatus } from "../Exception";
10
10
  import { DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, getTraitString, parseFormatTrait, parseFormatType, parsePrecision, parseRatioType, parseScientificType, parseShowSignOption, ShowSignOption, } from "./FormatEnums";
11
- import { isCustomFormatProps } from "./Interfaces";
12
11
  // cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
13
12
  // cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
14
13
  /** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes
@@ -221,19 +220,6 @@ export class Format extends BaseFormat {
221
220
  const traitStr = getTraitString(trait);
222
221
  return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;
223
222
  }
224
- async createUnit(unitsProvider, name, label) {
225
- 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
226
- throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);
227
- for (const unit of this.units) {
228
- const unitObj = unit[0].name;
229
- if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed
230
- throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);
231
- }
232
- const newUnit = await unitsProvider.findUnitByName(name);
233
- if (!newUnit || !newUnit.isValid)
234
- throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);
235
- this.units.push([newUnit, label]);
236
- }
237
223
  /**
238
224
  * Clone Format
239
225
  */
@@ -293,9 +279,12 @@ export class Format extends BaseFormat {
293
279
  * Populates this Format with the values from the provided.
294
280
  */
295
281
  async fromJSON(unitsProvider, jsonObj) {
282
+ const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);
283
+ return this.fromFullyResolvedJSON(json);
284
+ }
285
+ fromFullyResolvedJSON(jsonObj) {
296
286
  this.loadFormatProperties(jsonObj);
297
- if (isCustomFormatProps(jsonObj))
298
- this._customProps = jsonObj.custom;
287
+ this._customProps = jsonObj.custom;
299
288
  if (undefined !== jsonObj.composite) { // optional
300
289
  this._units = new Array();
301
290
  if (jsonObj.composite.includeZero !== undefined) {
@@ -315,15 +304,19 @@ export class Format extends BaseFormat {
315
304
  throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);
316
305
  }
317
306
  if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units
318
- try {
319
- const createUnitPromises = [];
320
- for (const unit of jsonObj.composite.units) {
321
- createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));
307
+ for (const nextUnit of jsonObj.composite.units) {
308
+ if (this._units) {
309
+ for (const existingUnit of this._units) {
310
+ const unitObj = existingUnit[0].name;
311
+ if (unitObj.toLowerCase() === nextUnit.unit.name.toLowerCase()) {
312
+ throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);
313
+ }
314
+ }
322
315
  }
323
- await Promise.all(createUnitPromises);
324
- }
325
- catch (e) {
326
- throw e;
316
+ if (undefined === this._units) {
317
+ this._units = [];
318
+ }
319
+ this._units.push([nextUnit.unit, nextUnit.label]);
327
320
  }
328
321
  }
329
322
  }
@@ -331,23 +324,8 @@ export class Format extends BaseFormat {
331
324
  throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);
332
325
  }
333
326
  if (this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {
334
- // these units cannot be loaded from loadFormatProperties() because they require an async call, and the method signature is already public
335
- if (undefined !== jsonObj.azimuthBaseUnit) {
336
- if (typeof (jsonObj.azimuthBaseUnit) !== "string")
337
- throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBaseUnit' attribute. It should be of type 'string'.`);
338
- const baseUnit = await unitsProvider.findUnitByName(jsonObj.azimuthBaseUnit);
339
- if (!baseUnit || !baseUnit.isValid)
340
- throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.azimuthBaseUnit}' for azimuthBaseUnit in Format '${this.name}'.`);
341
- this._azimuthBaseUnit = baseUnit;
342
- }
343
- if (undefined !== jsonObj.revolutionUnit) {
344
- if (typeof (jsonObj.revolutionUnit) !== "string")
345
- throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'revolutionUnit' attribute. It should be of type 'string'.`);
346
- const revolutionUnit = await unitsProvider.findUnitByName(jsonObj.revolutionUnit);
347
- if (!revolutionUnit || !revolutionUnit.isValid)
348
- throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${jsonObj.revolutionUnit}' for revolutionUnit in Format '${this.name}'.`);
349
- this._revolutionUnit = revolutionUnit;
350
- }
327
+ this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;
328
+ this._revolutionUnit = jsonObj.revolutionUnit;
351
329
  if (this._revolutionUnit === undefined)
352
330
  throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);
353
331
  if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)
@@ -360,17 +338,36 @@ export class Format extends BaseFormat {
360
338
  await actualFormat.fromJSON(unitsProvider, formatProps);
361
339
  return actualFormat;
362
340
  }
341
+ static createFromFullyResolvedJSON(name, formatProps) {
342
+ const actualFormat = new Format(name);
343
+ actualFormat.fromFullyResolvedJSON(formatProps);
344
+ return actualFormat;
345
+ }
363
346
  /**
364
347
  * Returns a JSON object that contain the specification for this Format.
365
348
  */
366
349
  toJSON() {
350
+ const json = this.toFullyResolvedJSON();
351
+ return {
352
+ ...json,
353
+ azimuthBaseUnit: json.azimuthBaseUnit?.name,
354
+ revolutionUnit: json.revolutionUnit?.name,
355
+ composite: json.composite ? {
356
+ ...json.composite,
357
+ units: json.composite.units.map((unit) => {
358
+ return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };
359
+ }),
360
+ } : undefined,
361
+ };
362
+ }
363
+ toFullyResolvedJSON() {
367
364
  let composite;
368
365
  if (this.units) {
369
366
  const units = this.units.map((value) => {
370
367
  if (undefined !== value[1])
371
- return { name: value[0].name, label: value[1] };
368
+ return { unit: value[0], label: value[1] };
372
369
  else
373
- return { name: value[0].name };
370
+ return { unit: value[0] };
374
371
  });
375
372
  composite = {
376
373
  spacer: this.spacer,
@@ -378,8 +375,8 @@ export class Format extends BaseFormat {
378
375
  units,
379
376
  };
380
377
  }
381
- const azimuthBaseUnit = this.azimuthBaseUnit ? this.azimuthBaseUnit.name : undefined;
382
- const revolutionUnit = this.revolutionUnit ? this.revolutionUnit.name : undefined;
378
+ const azimuthBaseUnit = this.azimuthBaseUnit;
379
+ const revolutionUnit = this.revolutionUnit;
383
380
  const baseFormatProps = {
384
381
  type: this.type,
385
382
  precision: this.precision,
@@ -400,13 +397,63 @@ export class Format extends BaseFormat {
400
397
  azimuthCounterClockwise: this.azimuthCounterClockwise,
401
398
  revolutionUnit,
402
399
  composite,
400
+ custom: this.customProps,
403
401
  };
404
- if (this.customProps)
405
- return {
406
- ...baseFormatProps,
407
- custom: this.customProps,
408
- };
409
402
  return baseFormatProps;
410
403
  }
411
404
  }
405
+ async function resolveCompositeUnit(provider, name, label) {
406
+ if (typeof name !== "string" || (undefined !== label && typeof label !== "string")) {
407
+ throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);
408
+ }
409
+ const unit = await provider.findUnitByName(name);
410
+ if (!unit || !unit.isValid) {
411
+ throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);
412
+ }
413
+ return unit;
414
+ }
415
+ async function resolveAzimuthBearingUnit(formatName, jsonObj, key, provider) {
416
+ const unitName = jsonObj[key];
417
+ if (undefined !== unitName) {
418
+ if (typeof unitName !== "string") {
419
+ throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);
420
+ }
421
+ const unit = await provider.findUnitByName(unitName);
422
+ if (!unit || !unit.isValid) {
423
+ throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);
424
+ }
425
+ return unit;
426
+ }
427
+ return undefined;
428
+ }
429
+ async function resolveFormatProps(formatName, unitsProvider, jsonObj) {
430
+ let units;
431
+ if (undefined !== jsonObj.composite?.units) {
432
+ units = await Promise.all(jsonObj.composite.units.map(async (entry) => {
433
+ const unit = await resolveCompositeUnit(unitsProvider, entry.name);
434
+ return { unit, label: entry.label };
435
+ }));
436
+ }
437
+ let azimuthBaseUnit, revolutionUnit;
438
+ const type = parseFormatType(jsonObj.type, formatName);
439
+ if (type === FormatType.Azimuth || type === FormatType.Bearing) {
440
+ azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, "azimuthBaseUnit", unitsProvider);
441
+ revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, "revolutionUnit", unitsProvider);
442
+ if (!revolutionUnit) {
443
+ throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);
444
+ }
445
+ if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {
446
+ throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);
447
+ }
448
+ }
449
+ return {
450
+ ...jsonObj,
451
+ azimuthBaseUnit,
452
+ revolutionUnit,
453
+ composite: units ? {
454
+ ...jsonObj.composite,
455
+ units,
456
+ } : undefined,
457
+ };
458
+ }
412
459
  //# sourceMappingURL=Format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAC/D,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,mBAAmB,EAE3H,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAgD,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjG,sFAAsF;AACtF,6JAA6J;AAE7J;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,KAAK,GAAG,EAAE,CAAC;IACT,YAAY,GAAW,GAAG,CAAC;IAC3B,KAAK,GAAe,UAAU,CAAC,OAAO,CAAC,CAAC,iEAAiE;IACzG,UAAU,GAAW,gBAAgB,CAAC,GAAG,CAAC,CAAC,WAAW;IACtD,eAAe,GAAmB,cAAc,CAAC,YAAY,CAAC,CAAC,iEAAiE;IAChI,iBAAiB,GAAW,iBAAiB,CAAC,8BAA8B,CAAC;IAC7E,kBAAkB,GAAW,iBAAiB,CAAC,+BAA+B,CAAC;IAC/E,aAAa,GAAG,GAAG,CAAC,CAAC,6EAA6E;IAClG,iBAAiB,GAAG,GAAG,CAAC,CAAC,2BAA2B;IACpD,aAAa,GAAiB,YAAY,CAAC,aAAa,CAAC;IACzD,OAAO,GAAW,GAAG,CAAC,CAAC,2BAA2B;IAClD,YAAY,GAAY,IAAI,CAAC,CAAC,4BAA4B;IAC1D,SAAS,CAAU,CAAC,yBAAyB;IAC7C,eAAe,CAAkB,CAAC,sEAAsE;I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,IAAI,IAAI,CAAC,WAAW;YAClB,OAAO;gBACL,GAAG,eAAe;gBAClB,MAAM,EAAE,IAAI,CAAC,WAAW;aACJ,CAAC;QAEzB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF","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,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,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QACvK,CAAC;QAED,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1D,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wFAAwF,CAAC,CAAC;QACxK,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,eAAe;QACf,cAAc;QACd,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACjB,GAAG,OAAO,CAAC,SAAS;YACpB,KAAK;SACN,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport {\r\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\r\n getTraitString, parseFormatTrait, parseFormatType, parsePrecision, parseRatioType, parseScientificType, parseShowSignOption,\r\n RatioType, ScientificType,\r\n ShowSignOption,\r\n} from \"./FormatEnums\";\r\nimport { CloneOptions, FormatProps, ResolvedFormatProps } from \"./Interfaces\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\r\n * @beta\r\n */\r\nexport class BaseFormat {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\r\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\r\n protected _azimuthBase?: number; // value always clockwise from north\r\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\r\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\r\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\r\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\r\n\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\r\n\r\n public get type(): FormatType { return this._type; }\r\n public set type(formatType: FormatType) { this._type = formatType; }\r\n\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\r\n\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\r\n\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\r\n\r\n public get ratioType(): RatioType | undefined { return this._ratioType; }\r\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\r\n\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\r\n\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\r\n\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\r\n\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\r\n\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\r\n\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\r\n\r\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\r\n * for the base offset calculation. The default value is 1.\r\n */\r\n public get stationBaseFactor(): number | undefined {\r\n return this._stationBaseFactor;\r\n }\r\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\r\n this._stationBaseFactor = stationBaseFactor;\r\n }\r\n\r\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\r\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\r\n\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\r\n\r\n public get spacer(): string | undefined { return this._spacer; }\r\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\r\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\r\n\r\n public get includeZero(): boolean | undefined { return this._includeZero; }\r\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\r\n\r\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\r\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\r\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\r\n\r\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\r\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\r\n\r\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\r\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\r\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\r\n\r\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\r\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\r\n\r\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. */\r\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\r\n this._formatTraits = this.formatTraits | formatTrait;\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\r\n this._type = parseFormatType(formatProps.type, this.name);\r\n\r\n if (formatProps.precision !== undefined) {\r\n if (!Number.isInteger(formatProps.precision)) // mut be an integer\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n\r\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\r\n }\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === formatProps.scientificType) // if format type is scientific and scientific type is undefined, throw\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\r\n\r\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\r\n }\r\n\r\n if (this.type === FormatType.Ratio){\r\n if (undefined === formatProps.ratioType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\r\n\r\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.roundFactor) { // optional; default is 0.0\r\n if (typeof (formatProps.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = formatProps.roundFactor;\r\n }\r\n\r\n if (undefined !== formatProps.minWidth) { // optional\r\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0) // must be a positive int\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = formatProps.minWidth;\r\n }\r\n if (FormatType.Station === this.type) {\r\n if (undefined === formatProps.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\r\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0) // must be a positive int > 0\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = formatProps.stationOffsetSize;\r\n\r\n if (undefined !== formatProps.stationBaseFactor) {\r\n // optional - must be a positive integer\r\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\r\n this._stationBaseFactor = formatProps.stationBaseFactor;\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\r\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) { // FormatTraits is optional\r\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\") // must be either an array of strings or a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.parseFormatTraits(formatProps.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\r\n }\r\n\r\n if (undefined !== formatProps.decimalSeparator) { // optional\r\n if (typeof (formatProps.decimalSeparator) !== \"string\") // not a string or not a one character string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.decimalSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\r\n this._decimalSeparator = formatProps.decimalSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.thousandSeparator) { // optional\r\n if (typeof (formatProps.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.thousandSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\r\n this._thousandSeparator = formatProps.thousandSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\r\n if (typeof (formatProps.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\r\n this._uomSeparator = formatProps.uomSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (formatProps.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.stationSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\r\n this._stationSeparator = formatProps.stationSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\r\n if (typeof (formatProps.azimuthBase) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\r\n this._azimuthBase = formatProps.azimuthBase;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false\r\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\r\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\r\n }\r\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\r\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\r\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\r\n }\r\n }\r\n}\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format extends BaseFormat {\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n super(name);\r\n }\r\n\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._stationBaseFactor = this._stationBaseFactor;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._azimuthBase = this._azimuthBase;\r\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\r\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\r\n newFormat._ratioType = this._ratioType;\r\n newFormat._revolutionUnit = this._revolutionUnit;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\r\n return this.fromFullyResolvedJSON(json);\r\n }\r\n\r\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\r\n this.loadFormatProperties(jsonObj);\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined !== jsonObj.composite) { // optional\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length > 1)\r\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.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\r\n for (const nextUnit of jsonObj.composite.units) {\r\n if (this._units) {\r\n for (const existingUnit of this._units) {\r\n const unitObj = existingUnit[0].name;\r\n if (unitObj.toLowerCase() === nextUnit.unit.name.toLowerCase()) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\r\n }\r\n }\r\n }\r\n\r\n if (undefined === this._units) {\r\n this._units = [];\r\n }\r\n\r\n this._units.push([nextUnit.unit, nextUnit.label]);\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n\r\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\r\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\r\n this._revolutionUnit = jsonObj.revolutionUnit;\r\n\r\n if (this._revolutionUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\r\n const actualFormat = new Format(name);\r\n actualFormat.fromFullyResolvedJSON(formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n const json = this.toFullyResolvedJSON();\r\n return {\r\n ...json,\r\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\r\n revolutionUnit: json.revolutionUnit?.name,\r\n composite: json.composite ? {\r\n ...json.composite,\r\n units: json.composite.units.map((unit) => {\r\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\r\n }),\r\n } : undefined,\r\n }\r\n }\r\n\r\n public toFullyResolvedJSON(): ResolvedFormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { unit: value[0], label: value[1] };\r\n else\r\n return { unit: value[0] };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n const azimuthBaseUnit = this.azimuthBaseUnit;\r\n const revolutionUnit = this.revolutionUnit;\r\n\r\n const baseFormatProps: ResolvedFormatProps = {\r\n type: this.type,\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: this.showSignOption,\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? this.scientificType : undefined,\r\n ratioType: this.ratioType,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n stationBaseFactor: this.stationBaseFactor,\r\n azimuthBase: this.azimuthBase,\r\n azimuthBaseUnit,\r\n azimuthCounterClockwise: this.azimuthCounterClockwise,\r\n revolutionUnit,\r\n composite,\r\n custom: this.customProps,\r\n };\r\n\r\n return baseFormatProps;\r\n }\r\n}\r\n\r\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\r\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(name);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n }\r\n\r\n return unit;\r\n}\r\n\r\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\r\n const unitName = jsonObj[key];\r\n if (undefined !== unitName) {\r\n if (typeof unitName !== \"string\") {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(unitName);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\r\n }\r\n\r\n return unit;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\r\n let units: Array<{ unit: UnitProps, label?: string }> | undefined;\r\n if (undefined !== jsonObj.composite?.units) {\r\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\r\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\r\n return { unit, label: entry.label };\r\n }));\r\n }\r\n\r\n let azimuthBaseUnit, revolutionUnit;\r\n const type = parseFormatType(jsonObj.type, formatName);\r\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\r\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\r\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\r\n\r\n if (!revolutionUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n }\r\n\r\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n return {\r\n ...jsonObj,\r\n azimuthBaseUnit,\r\n revolutionUnit,\r\n composite: units ? {\r\n ...jsonObj.composite,\r\n units,\r\n } : undefined,\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,8JAA8J,CAAC;AAE9L,gBAAgB;A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CAAC,OAAO,mBAAmB,CAAC,GAAG,CAAC;QACvC,KAAK,CAAC,CAAC,CAAC,OAAO,mBAAmB,CAAC,IAAI,CAAC;QACxC,KAAK,CAAC,CAAC,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC;QACzC,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,OAAO,CAAC;QAC5C,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC;QAC9C,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC;QAC9C,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,qBAAqB,CAAC;QAC3D,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,kBAAkB,CAAC;QACxD;YACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,CAAC;AAED,iJAAiJ;AACjJ,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,IAAgB,EAAE,UAAkB;IACpF,QAAQ,IAAI,EAAE,CAAC,CAAC,2DAA2D;QACzE,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtD,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,wBAAwB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACzD;YACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,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 { QuantityError, QuantityStatus } from \"../Exception\";\n\n/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)\n * provided in serialized formats as well as the full name of an [[OverrideFormat]].\n *\n * `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`\n *\n * Explanation of the regex:\n * - ([\\w.:]+)\n * - Grabs the format full name\n * - (\\(([^\\)]+)\\))?\n * - Grabs the precision part with and without the `()`.\n * - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)\n * - (\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?\n * - 4 of these make up the rest of the regex, none of them are required so each end in `?`\n * - Grabs the unit name and label including the `[]`\n * - Grabs the unit name, `|` and label separately\n * @internal\n */\nexport const formatStringRgx = /([\\w.:]+)(\\(([^\\)]+)\\))?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?/;\n\n/** @internal */\nexport function* getItemNamesFromFormatString(formatString: string): Iterable<string> {\n const match = formatString.split(formatStringRgx);\n yield match[1]; // the Format Name\n let index = 4;\n while (index < match.length - 1) { // index 0 and 21 are empty strings\n if (match[index] !== undefined)\n yield match[index + 1]; // Unit Name\n else\n break;\n index += 4;\n }\n}\n/** @beta */\nexport enum FormatTraits {\n Uninitialized = 0,\n /** Show trailing zeroes to requested precision. */\n TrailZeroes = 1 << 0,\n /** Indicates that the fractional part of the number is required when the fraction is zero */\n KeepSingleZero = 1 << 1,\n /** Zero magnitude returns blank display value */\n ZeroEmpty = 1 << 2,\n /** Show decimal point when value to right of decimal is empty */\n KeepDecimalPoint = 1 << 3,\n /** Use the rounding factor. Not yet supported */\n ApplyRounding = 1 << 4,\n /** Show a dash between whole value and fractional value */\n FractionDash = 1 << 5,\n /** Append the quantity's unit label */\n ShowUnitLabel = 1 << 6,\n /** Prepend unit label. Not yet supported */\n PrependUnitLabel = 1 << 7,\n /** show a grouping in each group of 1000. */\n Use1000Separator = 1 << 8,\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\n ExponentOnlyNegative = 1 << 9,\n}\n\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\n * @beta */\nexport enum FractionalPrecision {\n One = 1,\n Two = 2,\n Four = 4,\n Eight = 8,\n Sixteen = 16,\n ThirtyTwo = 32,\n SixtyFour = 64,\n OneHundredTwentyEight = 128,\n TwoHundredFiftySix = 256,\n}\n\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\n * @beta */\nexport enum DecimalPrecision {\n Zero = 0,\n One = 1,\n Two = 2,\n Three = 3,\n Four = 4,\n Five = 5,\n Six = 6,\n Seven = 7,\n Eight = 8,\n Nine = 9,\n Ten = 10,\n Eleven = 11,\n Twelve = 12,\n}\n\n/** Supported format types\n * @beta */\nexport enum FormatType {\n /** Decimal display (ie 2.125) */\n Decimal = \"Decimal\",\n /** Fractional display (ie 2-1/8) */\n Fractional = \"Fractional\",\n /** Scientific Notation (ie 1.04e3) */\n Scientific = \"Scientific\",\n /** Civil Engineering Stationing (ie 1+00). */\n Station = \"Station\",\n /** Bearing angle e.g. N05:00:00E. Requires provided quantities to be of the angle phenomenon */\n Bearing = \"Bearing\",\n /** Azimuth angle e.g. 45°30'00\". Requires provided quantities to be of the angle phenomenon */\n Azimuth = \"Azimuth\",\n /** Ratio display e,g. 1:2 or 0.3:1. */\n Ratio = \"Ratio\",\n}\n\n/** required if type is scientific\n * @beta */\nexport enum ScientificType {\n /** Non-zero value left of decimal point (ie 1.2345e3) */\n Normalized = \"Normalized\",\n /** Zero value left of decimal point (ie 0.12345e4) */\n ZeroNormalized = \"ZeroNormalized\",\n}\n\n/** required if type is ratio\n * @beta */\nexport enum RatioType {\n /** One to N ratio (ie 1:N) */\n OneToN = \"OneToN\",\n /** N to One ratio (ie N:1) */\n NToOne = \"NToOne\",\n /** the lesser value scales to 1. e.g. input 0.5 turns into 2:1 | input 2 turns into 1:2 */\n ValueBased = \"ValueBased\",\n /** scales the input ratio to its simplest integer form using the greatest common divisor (GCD) of the values. e.g. 0.3 turns into 3:10 */\n UseGreatestCommonDivisor = \"UseGreatestCommonDivisor\",\n}\n\n/** Determines how the sign of values are displayed\n * @beta */\nexport enum ShowSignOption {\n /** Never show a sign even if the value is negative. */\n NoSign = \"NoSign\",\n /** Only show a sign when the value is negative. */\n OnlyNegative = \"OnlyNegative\",\n /** Always show a sign whether the value is positive or negative. */\n SignAlways = \"SignAlways\",\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\n NegativeParentheses = \"NegativeParentheses\",\n}\n\n// parse and toString methods\n\n/**\n * @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function scientificTypeToString(scientificType: ScientificType): string {\n return (scientificType === ScientificType.Normalized) ? \"Normalized\" : \"ZeroNormalized\";\n}\n\n/**\n * @beta\n*/\nexport function parseScientificType(scientificType: string, formatName: string): ScientificType {\n switch (scientificType.toLowerCase()) {\n case \"normalized\": return ScientificType.Normalized;\n case \"zeronormalized\": return ScientificType.ZeroNormalized;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);\n }\n}\n\n/** @beta */\nexport function parseRatioType(ratioType: string, formatName: string): RatioType {\n const normalizedValue = ratioType.toLowerCase();\n for (const key in RatioType) {\n if (RatioType.hasOwnProperty(key)) {\n const enumValue = RatioType[key as keyof typeof RatioType];\n if (enumValue.toLowerCase() === normalizedValue) {\n return enumValue as RatioType;\n }\n }\n }\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioType' attribute.`);\n}\n\n/** @beta */\nexport function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\n switch (showSignOption.toLowerCase()) {\n case \"nosign\": return ShowSignOption.NoSign;\n case \"onlynegative\": return ShowSignOption.OnlyNegative;\n case \"signalways\": return ShowSignOption.SignAlways;\n case \"negativeparentheses\": return ShowSignOption.NegativeParentheses;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\n }\n}\n\n/**\n * @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function showSignOptionToString(showSign: ShowSignOption): string {\n switch (showSign) {\n case ShowSignOption.NegativeParentheses: return \"NegativeParentheses\";\n case ShowSignOption.NoSign: return \"NoSign\";\n case ShowSignOption.OnlyNegative: return \"OnlyNegative\";\n case ShowSignOption.SignAlways: return \"SignAlways\";\n }\n}\n\n/** @beta */\nexport function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits {\n switch (formatTraitsString.toLowerCase()) {\n case \"trailzeroes\": return FormatTraits.TrailZeroes;\n case \"keepsinglezero\": return FormatTraits.KeepSingleZero;\n case \"zeroempty\": return FormatTraits.ZeroEmpty;\n case \"keepdecimalpoint\": return FormatTraits.KeepDecimalPoint;\n case \"applyrounding\": return FormatTraits.ApplyRounding;\n case \"fractiondash\": return FormatTraits.FractionDash;\n case \"showunitlabel\": return FormatTraits.ShowUnitLabel;\n case \"prependunitlabel\": return FormatTraits.PrependUnitLabel;\n case \"use1000separator\": return FormatTraits.Use1000Separator;\n case \"exponentonlynegative\": return FormatTraits.ExponentOnlyNegative;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);\n }\n}\n\n/** @beta */\nexport function getTraitString(trait: FormatTraits) {\n switch (trait) {\n case FormatTraits.TrailZeroes:\n return \"trailZeroes\";\n case FormatTraits.KeepSingleZero:\n return \"keepSingleZero\";\n case FormatTraits.ZeroEmpty:\n return \"zeroEmpty\";\n case FormatTraits.KeepDecimalPoint:\n return \"keepDecimalPoint\";\n case FormatTraits.ApplyRounding:\n return \"applyRounding\";\n case FormatTraits.FractionDash:\n return \"fractionDash\";\n case FormatTraits.ShowUnitLabel:\n return \"showUnitLabel\";\n case FormatTraits.PrependUnitLabel:\n return \"prependUnitLabel\";\n case FormatTraits.Use1000Separator:\n return \"use1000Separator\";\n case FormatTraits.ExponentOnlyNegative:\n default:\n return \"exponentOnlyNegative\";\n }\n}\n\n/** @beta */\nexport function formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\n const formatTraitsArr = Array<string>();\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)\n formatTraitsArr.push(\"TrailZeroes\");\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)\n formatTraitsArr.push(\"KeepSingleZero\");\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)\n formatTraitsArr.push(\"ZeroEmpty\");\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)\n formatTraitsArr.push(\"KeepDecimalPoint\");\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)\n formatTraitsArr.push(\"ApplyRounding\");\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)\n formatTraitsArr.push(\"FractionDash\");\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)\n formatTraitsArr.push(\"ShowUnitLabel\");\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)\n formatTraitsArr.push(\"PrependUnitLabel\");\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)\n formatTraitsArr.push(\"Use1000Separator\");\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)\n formatTraitsArr.push(\"ExponentOnlyNegative\");\n return formatTraitsArr;\n}\n\n/** @beta */\nexport function parseFormatType(jsonObjType: string, formatName: string): FormatType {\n switch (jsonObjType.toLowerCase()) {\n case \"decimal\": return FormatType.Decimal;\n case \"scientific\": return FormatType.Scientific;\n case \"station\": return FormatType.Station;\n case \"fractional\": return FormatType.Fractional;\n case \"bearing\": return FormatType.Bearing;\n case \"azimuth\": return FormatType.Azimuth;\n case \"ratio\": return FormatType.Ratio;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\n }\n}\n\n/** @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function formatTypeToString(type: FormatType): string {\n switch (type) {\n case FormatType.Decimal: return \"Decimal\";\n case FormatType.Scientific: return \"Scientific\";\n case FormatType.Station: return \"Station\";\n case FormatType.Fractional: return \"Fractional\";\n case FormatType.Bearing: return \"Bearing\";\n case FormatType.Azimuth: return \"Azimuth\";\n case FormatType.Ratio: return \"Ratio\";\n }\n}\n\n/** @beta */\nexport function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision {\n switch (jsonObjPrecision) {\n case 0: return DecimalPrecision.Zero;\n case 1: return DecimalPrecision.One;\n case 2: return DecimalPrecision.Two;\n case 3: return DecimalPrecision.Three;\n case 4: return DecimalPrecision.Four;\n case 5: return DecimalPrecision.Five;\n case 6: return DecimalPrecision.Six;\n case 7: return DecimalPrecision.Seven;\n case 8: return DecimalPrecision.Eight;\n case 9: return DecimalPrecision.Nine;\n case 10: return DecimalPrecision.Ten;\n case 11: return DecimalPrecision.Eleven;\n case 12: return DecimalPrecision.Twelve;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */\nexport function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\n switch (jsonObjPrecision) {\n case 1: return FractionalPrecision.One;\n case 2: return FractionalPrecision.Two;\n case 4: return FractionalPrecision.Four;\n case 8: return FractionalPrecision.Eight;\n case 16: return FractionalPrecision.Sixteen;\n case 32: return FractionalPrecision.ThirtyTwo;\n case 64: return FractionalPrecision.SixtyFour;\n case 128: return FractionalPrecision.OneHundredTwentyEight;\n case 256: return FractionalPrecision.TwoHundredFiftySix;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */\nexport function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision {\n switch (type) { // type must be decimal, fractional, scientific, or station\n case FormatType.Decimal:\n case FormatType.Scientific:\n case FormatType.Station:\n case FormatType.Ratio:\n case FormatType.Bearing:\n case FormatType.Azimuth:\n return parseDecimalPrecision(precision, formatName);\n case FormatType.Fractional:\n return parseFractionalPrecision(precision, formatName);\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n"]}
1
+ {"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,8JAA8J,CAAC;AAE9L,gBAAgB;AAChB,MAAM,SAAS,CAAC,CAAC,4BAA4B,CAAC,YAAoB;IAChE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,eAAe,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C,KAAK,CAAC,CAAC,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC;QACzC,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,OAAO,CAAC;QAC5C,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC;QAC9C,KAAK,EAAE,CAAC,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC;QAC9C,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,qBAAqB,CAAC;QAC3D,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,kBAAkB,CAAC;QACxD;YACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,CAAC;AAED,iJAAiJ;AACjJ,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,IAAgB,EAAE,UAAkB;IACpF,QAAQ,IAAI,EAAE,CAAC,CAAC,2DAA2D;QACzE,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtD,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,wBAAwB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACzD;YACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\n\r\n/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)\r\n * provided in serialized formats as well as the full name of an [[OverrideFormat]].\r\n *\r\n * `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`\r\n *\r\n * Explanation of the regex:\r\n * - ([\\w.:]+)\r\n * - Grabs the format full name\r\n * - (\\(([^\\)]+)\\))?\r\n * - Grabs the precision part with and without the `()`.\r\n * - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)\r\n * - (\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?\r\n * - 4 of these make up the rest of the regex, none of them are required so each end in `?`\r\n * - Grabs the unit name and label including the `[]`\r\n * - Grabs the unit name, `|` and label separately\r\n * @internal\r\n */\r\nexport const formatStringRgx = /([\\w.:]+)(\\(([^\\)]+)\\))?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?/;\r\n\r\n/** @internal */\r\nexport function* getItemNamesFromFormatString(formatString: string): Iterable<string> {\r\n const match = formatString.split(formatStringRgx);\r\n yield match[1]; // the Format Name\r\n let index = 4;\r\n while (index < match.length - 1) { // index 0 and 21 are empty strings\r\n if (match[index] !== undefined)\r\n yield match[index + 1]; // Unit Name\r\n else\r\n break;\r\n index += 4;\r\n }\r\n}\r\n/** @beta */\r\nexport enum FormatTraits {\r\n Uninitialized = 0,\r\n /** Show trailing zeroes to requested precision. */\r\n TrailZeroes = 1 << 0,\r\n /** Indicates that the fractional part of the number is required when the fraction is zero */\r\n KeepSingleZero = 1 << 1,\r\n /** Zero magnitude returns blank display value */\r\n ZeroEmpty = 1 << 2,\r\n /** Show decimal point when value to right of decimal is empty */\r\n KeepDecimalPoint = 1 << 3,\r\n /** Use the rounding factor. Not yet supported */\r\n ApplyRounding = 1 << 4,\r\n /** Show a dash between whole value and fractional value */\r\n FractionDash = 1 << 5,\r\n /** Append the quantity's unit label */\r\n ShowUnitLabel = 1 << 6,\r\n /** Prepend unit label. Not yet supported */\r\n PrependUnitLabel = 1 << 7,\r\n /** show a grouping in each group of 1000. */\r\n Use1000Separator = 1 << 8,\r\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\r\n ExponentOnlyNegative = 1 << 9,\r\n}\r\n\r\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\r\n * @beta */\r\nexport enum FractionalPrecision {\r\n One = 1,\r\n Two = 2,\r\n Four = 4,\r\n Eight = 8,\r\n Sixteen = 16,\r\n ThirtyTwo = 32,\r\n SixtyFour = 64,\r\n OneHundredTwentyEight = 128,\r\n TwoHundredFiftySix = 256,\r\n}\r\n\r\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\r\n * @beta */\r\nexport enum DecimalPrecision {\r\n Zero = 0,\r\n One = 1,\r\n Two = 2,\r\n Three = 3,\r\n Four = 4,\r\n Five = 5,\r\n Six = 6,\r\n Seven = 7,\r\n Eight = 8,\r\n Nine = 9,\r\n Ten = 10,\r\n Eleven = 11,\r\n Twelve = 12,\r\n}\r\n\r\n/** Supported format types\r\n * @beta */\r\nexport enum FormatType {\r\n /** Decimal display (ie 2.125) */\r\n Decimal = \"Decimal\",\r\n /** Fractional display (ie 2-1/8) */\r\n Fractional = \"Fractional\",\r\n /** Scientific Notation (ie 1.04e3) */\r\n Scientific = \"Scientific\",\r\n /** Civil Engineering Stationing (ie 1+00). */\r\n Station = \"Station\",\r\n /** Bearing angle e.g. N05:00:00E. Requires provided quantities to be of the angle phenomenon */\r\n Bearing = \"Bearing\",\r\n /** Azimuth angle e.g. 45°30'00\". Requires provided quantities to be of the angle phenomenon */\r\n Azimuth = \"Azimuth\",\r\n /** Ratio display e,g. 1:2 or 0.3:1. */\r\n Ratio = \"Ratio\",\r\n}\r\n\r\n/** required if type is scientific\r\n * @beta */\r\nexport enum ScientificType {\r\n /** Non-zero value left of decimal point (ie 1.2345e3) */\r\n Normalized = \"Normalized\",\r\n /** Zero value left of decimal point (ie 0.12345e4) */\r\n ZeroNormalized = \"ZeroNormalized\",\r\n}\r\n\r\n/** required if type is ratio\r\n * @beta */\r\nexport enum RatioType {\r\n /** One to N ratio (ie 1:N) */\r\n OneToN = \"OneToN\",\r\n /** N to One ratio (ie N:1) */\r\n NToOne = \"NToOne\",\r\n /** the lesser value scales to 1. e.g. input 0.5 turns into 2:1 | input 2 turns into 1:2 */\r\n ValueBased = \"ValueBased\",\r\n /** scales the input ratio to its simplest integer form using the greatest common divisor (GCD) of the values. e.g. 0.3 turns into 3:10 */\r\n UseGreatestCommonDivisor = \"UseGreatestCommonDivisor\",\r\n}\r\n\r\n/** Determines how the sign of values are displayed\r\n * @beta */\r\nexport enum ShowSignOption {\r\n /** Never show a sign even if the value is negative. */\r\n NoSign = \"NoSign\",\r\n /** Only show a sign when the value is negative. */\r\n OnlyNegative = \"OnlyNegative\",\r\n /** Always show a sign whether the value is positive or negative. */\r\n SignAlways = \"SignAlways\",\r\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\r\n NegativeParentheses = \"NegativeParentheses\",\r\n}\r\n\r\n// parse and toString methods\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.\r\n*/\r\nexport function scientificTypeToString(scientificType: ScientificType): string {\r\n return (scientificType === ScientificType.Normalized) ? \"Normalized\" : \"ZeroNormalized\";\r\n}\r\n\r\n/**\r\n * @beta\r\n*/\r\nexport function parseScientificType(scientificType: string, formatName: string): ScientificType {\r\n switch (scientificType.toLowerCase()) {\r\n case \"normalized\": return ScientificType.Normalized;\r\n case \"zeronormalized\": return ScientificType.ZeroNormalized;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseRatioType(ratioType: string, formatName: string): RatioType {\r\n const normalizedValue = ratioType.toLowerCase();\r\n for (const key in RatioType) {\r\n if (RatioType.hasOwnProperty(key)) {\r\n const enumValue = RatioType[key as keyof typeof RatioType];\r\n if (enumValue.toLowerCase() === normalizedValue) {\r\n return enumValue as RatioType;\r\n }\r\n }\r\n }\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioType' attribute.`);\r\n}\r\n\r\n/** @beta */\r\nexport function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\r\n switch (showSignOption.toLowerCase()) {\r\n case \"nosign\": return ShowSignOption.NoSign;\r\n case \"onlynegative\": return ShowSignOption.OnlyNegative;\r\n case \"signalways\": return ShowSignOption.SignAlways;\r\n case \"negativeparentheses\": return ShowSignOption.NegativeParentheses;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.\r\n*/\r\nexport function showSignOptionToString(showSign: ShowSignOption): string {\r\n switch (showSign) {\r\n case ShowSignOption.NegativeParentheses: return \"NegativeParentheses\";\r\n case ShowSignOption.NoSign: return \"NoSign\";\r\n case ShowSignOption.OnlyNegative: return \"OnlyNegative\";\r\n case ShowSignOption.SignAlways: return \"SignAlways\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits {\r\n switch (formatTraitsString.toLowerCase()) {\r\n case \"trailzeroes\": return FormatTraits.TrailZeroes;\r\n case \"keepsinglezero\": return FormatTraits.KeepSingleZero;\r\n case \"zeroempty\": return FormatTraits.ZeroEmpty;\r\n case \"keepdecimalpoint\": return FormatTraits.KeepDecimalPoint;\r\n case \"applyrounding\": return FormatTraits.ApplyRounding;\r\n case \"fractiondash\": return FormatTraits.FractionDash;\r\n case \"showunitlabel\": return FormatTraits.ShowUnitLabel;\r\n case \"prependunitlabel\": return FormatTraits.PrependUnitLabel;\r\n case \"use1000separator\": return FormatTraits.Use1000Separator;\r\n case \"exponentonlynegative\": return FormatTraits.ExponentOnlyNegative;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function getTraitString(trait: FormatTraits) {\r\n switch (trait) {\r\n case FormatTraits.TrailZeroes:\r\n return \"trailZeroes\";\r\n case FormatTraits.KeepSingleZero:\r\n return \"keepSingleZero\";\r\n case FormatTraits.ZeroEmpty:\r\n return \"zeroEmpty\";\r\n case FormatTraits.KeepDecimalPoint:\r\n return \"keepDecimalPoint\";\r\n case FormatTraits.ApplyRounding:\r\n return \"applyRounding\";\r\n case FormatTraits.FractionDash:\r\n return \"fractionDash\";\r\n case FormatTraits.ShowUnitLabel:\r\n return \"showUnitLabel\";\r\n case FormatTraits.PrependUnitLabel:\r\n return \"prependUnitLabel\";\r\n case FormatTraits.Use1000Separator:\r\n return \"use1000Separator\";\r\n case FormatTraits.ExponentOnlyNegative:\r\n default:\r\n return \"exponentOnlyNegative\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\r\n const formatTraitsArr = Array<string>();\r\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)\r\n formatTraitsArr.push(\"TrailZeroes\");\r\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)\r\n formatTraitsArr.push(\"KeepSingleZero\");\r\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)\r\n formatTraitsArr.push(\"ZeroEmpty\");\r\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)\r\n formatTraitsArr.push(\"KeepDecimalPoint\");\r\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)\r\n formatTraitsArr.push(\"ApplyRounding\");\r\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)\r\n formatTraitsArr.push(\"FractionDash\");\r\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)\r\n formatTraitsArr.push(\"ShowUnitLabel\");\r\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)\r\n formatTraitsArr.push(\"PrependUnitLabel\");\r\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)\r\n formatTraitsArr.push(\"Use1000Separator\");\r\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)\r\n formatTraitsArr.push(\"ExponentOnlyNegative\");\r\n return formatTraitsArr;\r\n}\r\n\r\n/** @beta */\r\nexport function parseFormatType(jsonObjType: string, formatName: string): FormatType {\r\n switch (jsonObjType.toLowerCase()) {\r\n case \"decimal\": return FormatType.Decimal;\r\n case \"scientific\": return FormatType.Scientific;\r\n case \"station\": return FormatType.Station;\r\n case \"fractional\": return FormatType.Fractional;\r\n case \"bearing\": return FormatType.Bearing;\r\n case \"azimuth\": return FormatType.Azimuth;\r\n case \"ratio\": return FormatType.Ratio;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta\r\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.\r\n*/\r\nexport function formatTypeToString(type: FormatType): string {\r\n switch (type) {\r\n case FormatType.Decimal: return \"Decimal\";\r\n case FormatType.Scientific: return \"Scientific\";\r\n case FormatType.Station: return \"Station\";\r\n case FormatType.Fractional: return \"Fractional\";\r\n case FormatType.Bearing: return \"Bearing\";\r\n case FormatType.Azimuth: return \"Azimuth\";\r\n case FormatType.Ratio: return \"Ratio\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 0: return DecimalPrecision.Zero;\r\n case 1: return DecimalPrecision.One;\r\n case 2: return DecimalPrecision.Two;\r\n case 3: return DecimalPrecision.Three;\r\n case 4: return DecimalPrecision.Four;\r\n case 5: return DecimalPrecision.Five;\r\n case 6: return DecimalPrecision.Six;\r\n case 7: return DecimalPrecision.Seven;\r\n case 8: return DecimalPrecision.Eight;\r\n case 9: return DecimalPrecision.Nine;\r\n case 10: return DecimalPrecision.Ten;\r\n case 11: return DecimalPrecision.Eleven;\r\n case 12: return DecimalPrecision.Twelve;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */\r\nexport function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 1: return FractionalPrecision.One;\r\n case 2: return FractionalPrecision.Two;\r\n case 4: return FractionalPrecision.Four;\r\n case 8: return FractionalPrecision.Eight;\r\n case 16: return FractionalPrecision.Sixteen;\r\n case 32: return FractionalPrecision.ThirtyTwo;\r\n case 64: return FractionalPrecision.SixtyFour;\r\n case 128: return FractionalPrecision.OneHundredTwentyEight;\r\n case 256: return FractionalPrecision.TwoHundredFiftySix;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */\r\nexport function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision {\r\n switch (type) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Decimal:\r\n case FormatType.Scientific:\r\n case FormatType.Station:\r\n case FormatType.Ratio:\r\n case FormatType.Bearing:\r\n case FormatType.Azimuth:\r\n return parseDecimalPrecision(precision, formatName);\r\n case FormatType.Fractional:\r\n return parseFractionalPrecision(precision, formatName);\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n"]}
@@ -37,6 +37,13 @@ export declare class Formatter {
37
37
  */
38
38
  private static formatMagnitude;
39
39
  private static countAndPad;
40
+ /** Helper function to apply sign formatting based on showSignOption
41
+ * @param isNegative whether the value should be treated as negative
42
+ * @param showSignOption the sign display option
43
+ * @param formatType the format type (to handle bearing/azimuth exceptions)
44
+ * @returns object containing prefix and suffix strings
45
+ */
46
+ private static applySignFormatting;
40
47
  /** Format a quantity value into a single text string based on the current format specification of this class.
41
48
  * @param magnitude defines the value to spec.format.
42
49
  * @param spec A FormatterSpec object the defines specification for the magnitude and unit conversions for the formatter.