@contrail/types
Advanced tools
Comparing version 3.0.70 to 3.0.71
@@ -1,2 +0,2 @@ | ||
import { Type } from "../types"; | ||
import { Type } from '../types'; | ||
export declare enum CopyMethodTypes { | ||
@@ -3,0 +3,0 @@ QUICK_COPY = "Quick Copy", |
@@ -13,4 +13,4 @@ "use strict"; | ||
static buildCopiesOfEntities(entitiesToCopy, typeMap, propertySlugsToIgnore = []) { | ||
const entityCopies = entitiesToCopy.map(entity => this.buildCopyOfEntity(entity, typeMap, propertySlugsToIgnore)); | ||
return entityCopies.filter(entity => !!entity); | ||
const entityCopies = entitiesToCopy.map((entity) => this.buildCopyOfEntity(entity, typeMap, propertySlugsToIgnore)); | ||
return entityCopies.filter((entity) => !!entity); | ||
} | ||
@@ -51,19 +51,15 @@ static buildCopyOfEntity(entityToCopy, typeMap, propertySlugsToIgnore = []) { | ||
]; | ||
const propertiesToCopy = entityType.typeProperties.filter(property => { | ||
const propertiesToCopy = entityType.typeProperties.filter((property) => { | ||
const isConfiguredToCopy = property.copyBehavior === type_properties_1.CopyBehavior.Copy || !property.copyBehavior; | ||
const doesPropertyLevelMatch = !isLeveledEntity || (property.propertyLevel && [typeLevel, 'overridable', 'all'].includes(property.propertyLevel)); | ||
const doesPropertyLevelMatch = !isLeveledEntity || | ||
(property.propertyLevel && [typeLevel, 'overridable', 'all'].includes(property.propertyLevel)); | ||
const isPropertyTypeCopyable = property.propertyType && validCopyPropertyTypes.includes(property.propertyType); | ||
return Boolean(isConfiguredToCopy && | ||
doesPropertyLevelMatch && | ||
isPropertyTypeCopyable && | ||
!property.isUniqueProperty); | ||
return Boolean(isConfiguredToCopy && doesPropertyLevelMatch && isPropertyTypeCopyable && !property.isUniqueProperty); | ||
}); | ||
const propertiesToDefault = entityType.typeProperties.filter(property => { | ||
const propertiesToDefault = entityType.typeProperties.filter((property) => { | ||
const isConfiguredToDefault = property.copyBehavior === type_properties_1.CopyBehavior.Default; | ||
const doesPropertyLevelMatch = !isLeveledEntity || (property.propertyLevel && [typeLevel, 'overridable', 'all'].includes(property.propertyLevel)); | ||
const doesPropertyLevelMatch = !isLeveledEntity || | ||
(property.propertyLevel && [typeLevel, 'overridable', 'all'].includes(property.propertyLevel)); | ||
const isPropertyTypeCopyable = property.propertyType && validCopyPropertyTypes.includes(property.propertyType); | ||
return Boolean(isConfiguredToDefault && | ||
doesPropertyLevelMatch && | ||
isPropertyTypeCopyable && | ||
!property.isUniqueProperty); | ||
return Boolean(isConfiguredToDefault && doesPropertyLevelMatch && isPropertyTypeCopyable && !property.isUniqueProperty); | ||
}); | ||
@@ -73,3 +69,3 @@ const defaultPropertiesToIgnore = isLeveledEntity ? ['id', 'roles', 'specifiedId'] : ['id', 'specifiedId']; | ||
const copy = {}; | ||
propertiesToCopy.forEach(property => { | ||
propertiesToCopy.forEach((property) => { | ||
if (!propertiesToIgnore.includes(property.slug)) { | ||
@@ -79,3 +75,3 @@ copy[this.getTypePropertySlug(property)] = entityToCopy[this.getTypePropertySlug(property)]; | ||
}); | ||
propertiesToDefault.forEach(property => { | ||
propertiesToDefault.forEach((property) => { | ||
if (!propertiesToIgnore.includes(property.slug)) { | ||
@@ -82,0 +78,0 @@ copy[this.getTypePropertySlug(property)] = this.getCastDefaultValue(property); |
@@ -1,3 +0,3 @@ | ||
import { NumberFormatingOptions } from "../type-properties"; | ||
import { LocalizationConfig } from "./property-value-formatter"; | ||
import { NumberFormatingOptions } from '../type-properties'; | ||
import { LocalizationConfig } from './property-value-formatter'; | ||
export declare const formatNumber: (value: any, numberFormat?: NumberFormatingOptions, localizationConfig?: LocalizationConfig) => string; |
@@ -27,5 +27,3 @@ "use strict"; | ||
options.currency = | ||
numberFormat.currency | ||
|| localizationConfig.currency | ||
|| localizationConfig.currencyCode || 'USD'; | ||
numberFormat.currency || localizationConfig.currency || localizationConfig.currencyCode || 'USD'; | ||
val = value[options.currency] || value[options.currency.toLowerCase()] || val; | ||
@@ -32,0 +30,0 @@ } |
@@ -17,5 +17,5 @@ "use strict"; | ||
} | ||
keys.forEach(size2 => { | ||
object.sizes[size2]?.forEach(size1 => { | ||
display += ((display !== '' ? ' | ' : '') + size2 + ' x ' + size1); | ||
keys.forEach((size2) => { | ||
object.sizes[size2]?.forEach((size1) => { | ||
display += (display !== '' ? ' | ' : '') + size2 + ' x ' + size1; | ||
}); | ||
@@ -22,0 +22,0 @@ }); |
@@ -51,3 +51,3 @@ "use strict"; | ||
let displayValue = ''; | ||
value.forEach(optionVal => { | ||
value.forEach((optionVal) => { | ||
displayValue = displayValue + this.formatOptionValue(optionVal, property) + ', '; | ||
@@ -65,3 +65,3 @@ }); | ||
let display = ''; | ||
property.options.map(opt => { | ||
property.options.map((opt) => { | ||
if (opt.value === value) { | ||
@@ -228,3 +228,6 @@ display = opt.display; | ||
parseBooleanValue(value) { | ||
if (value.toUpperCase() === 'FALSE' || value.toUpperCase() === 'NO' || value.trim() === '' || value.trim() === 'undefined') { | ||
if (value.toUpperCase() === 'FALSE' || | ||
value.toUpperCase() === 'NO' || | ||
value.trim() === '' || | ||
value.trim() === 'undefined') { | ||
return false; | ||
@@ -245,3 +248,3 @@ } | ||
let optionValue = display; | ||
typeProperty.options.map(opt => { | ||
typeProperty.options.map((opt) => { | ||
if (opt.display === display) { | ||
@@ -261,3 +264,3 @@ optionValue = opt.value; | ||
const values = display.split(','); | ||
return values.map(value => { | ||
return values.map((value) => { | ||
return this.parseOptionValue(value.trim(), typeProperty); | ||
@@ -286,5 +289,5 @@ }); | ||
isValidDateObject(value) { | ||
return (value && value instanceof Date && !isNaN(value.getTime())); | ||
return value && value instanceof Date && !isNaN(value.getTime()); | ||
} | ||
} | ||
exports.PropertyValueFormatter = PropertyValueFormatter; |
@@ -1,2 +0,2 @@ | ||
import { TypeProperty } from "../type-properties"; | ||
import { TypeProperty } from '../type-properties'; | ||
export declare class FormulaFunctionProcessor { | ||
@@ -3,0 +3,0 @@ static processFormulaFunctionsForEntity(entity: any, properties: Array<TypeProperty>, context?: {}): Promise<void>; |
@@ -11,5 +11,3 @@ "use strict"; | ||
let value = await this.processFormulaFunction(property.formulaFunction, entity, context); | ||
if (value === undefined || | ||
value === null || | ||
(typeof value === "number" && Number.isNaN(value))) { | ||
if (value === undefined || value === null || (typeof value === 'number' && Number.isNaN(value))) { | ||
value = null; | ||
@@ -20,3 +18,3 @@ } | ||
} | ||
static async processFormulaFunction(formulaFunctionString = "", data, context = {}) { | ||
static async processFormulaFunction(formulaFunctionString = '', data, context = {}) { | ||
let value; | ||
@@ -29,3 +27,3 @@ try { | ||
console.error(e); | ||
console.error("FormulaFunctionProcessor: error processing function: ", formulaFunctionString); | ||
console.error('FormulaFunctionProcessor: error processing function: ', formulaFunctionString); | ||
} | ||
@@ -42,3 +40,3 @@ return value; | ||
const AsyncFunction = Object.getPrototypeOf(async () => { }).constructor; | ||
const executionFunction = new AsyncFunction("obj", "context", functionString); | ||
const executionFunction = new AsyncFunction('obj', 'context', functionString); | ||
return executionFunction; | ||
@@ -48,3 +46,3 @@ } | ||
console.error(e); | ||
throw new Error("FormulaFunctionProcessor: Failed to parse the execution string."); | ||
throw new Error('FormulaFunctionProcessor: Failed to parse the execution string.'); | ||
} | ||
@@ -51,0 +49,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { TypeProperty } from "../type-properties"; | ||
import { TypeProperty } from '../type-properties'; | ||
export declare class FormulaProcessor { | ||
@@ -3,0 +3,0 @@ static processFormula(formula: string | undefined, data: any): number | null; |
@@ -8,3 +8,3 @@ "use strict"; | ||
class FormulaProcessor { | ||
static processFormula(formula = "", data) { | ||
static processFormula(formula = '', data) { | ||
const converted = util_1.StringUtil.parseVariables(formula, data); | ||
@@ -11,0 +11,0 @@ const value = parseFloat(eval(converted)); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const formula_processor_1 = require("./formula-processor"); | ||
console.log("Start test"); | ||
console.log('Start test'); | ||
const formula = '{retailPrice}*{volume}-{retailPrice}'; | ||
@@ -11,2 +11,2 @@ const data = { | ||
const value = formula_processor_1.FormulaProcessor.processFormula(formula, data); | ||
console.log("value: ", value); | ||
console.log('value: ', value); |
@@ -1,3 +0,3 @@ | ||
import { TypePropertyOptionSet } from "../type-properties"; | ||
import { OptionSetHierarchy } from "./option-set-hierarchy"; | ||
import { TypePropertyOptionSet } from '../type-properties'; | ||
import { OptionSetHierarchy } from './option-set-hierarchy'; | ||
export interface OptionSetHierarchyOptionDefinition { | ||
@@ -4,0 +4,0 @@ value: any; |
@@ -12,3 +12,3 @@ "use strict"; | ||
hierarchy.maxDepth = optionSets.length; | ||
hierarchy.hierarchy = optionSets.map(o => o.id); | ||
hierarchy.hierarchy = optionSets.map((o) => o.id); | ||
hierarchy.options = this.generateAllOptionDefinitions(optionSets, widthLimit); | ||
@@ -15,0 +15,0 @@ return hierarchy; |
@@ -1,2 +0,2 @@ | ||
import { Type } from "../types"; | ||
import { Type } from '../types'; | ||
export interface OptionSetHierarchy { | ||
@@ -3,0 +3,0 @@ id?: string; |
@@ -35,1 +35,2 @@ export declare enum PropertyType { | ||
export declare const PropertyTypeMeta: Map<PropertyType, PropertyTypeMetaData>; | ||
export declare function isReferencePropertyType(propertyType: PropertyType): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PropertyTypeMeta = exports.AllPropertyTypes = exports.PropertyType = void 0; | ||
exports.isReferencePropertyType = exports.PropertyTypeMeta = exports.AllPropertyTypes = exports.PropertyType = void 0; | ||
var PropertyType; | ||
@@ -60,4 +60,8 @@ (function (PropertyType) { | ||
exports.PropertyTypeMeta = new Map(); | ||
exports.AllPropertyTypes.forEach(propDef => { | ||
exports.AllPropertyTypes.forEach((propDef) => { | ||
exports.PropertyTypeMeta.set(propDef.propertyType, propDef); | ||
}); | ||
function isReferencePropertyType(propertyType) { | ||
return [PropertyType.ObjectReference, PropertyType.UserList, PropertyType.TypeReference].includes(propertyType); | ||
} | ||
exports.isReferencePropertyType = isReferencePropertyType; |
@@ -25,2 +25,1 @@ "use strict"; | ||
})(PropertyLevel = exports.PropertyLevel || (exports.PropertyLevel = {})); | ||
; |
@@ -1,2 +0,2 @@ | ||
import { PropertyType } from "../type-properties"; | ||
import { PropertyType } from '../type-properties'; | ||
export interface ReducedType { | ||
@@ -3,0 +3,0 @@ slug: string; |
@@ -96,4 +96,4 @@ "use strict"; | ||
return { | ||
'TypePropertiesByEntity': reducedTypePropertiesByEntity, | ||
'OptionSets': reducedOptionSets | ||
TypePropertiesByEntity: reducedTypePropertiesByEntity, | ||
OptionSets: reducedOptionSets, | ||
}; | ||
@@ -193,4 +193,4 @@ } | ||
return { | ||
'TypePropertiesByEntity': reducedTypePropertiesByEntity, | ||
'OptionSets': reducedOptionSets | ||
TypePropertiesByEntity: reducedTypePropertiesByEntity, | ||
OptionSets: reducedOptionSets, | ||
}; | ||
@@ -298,6 +298,6 @@ } | ||
return { | ||
'TypeProperties': reducedTypeProperties, | ||
'OptionSets': reducedOptionSets | ||
TypeProperties: reducedTypeProperties, | ||
OptionSets: reducedOptionSets, | ||
}; | ||
} | ||
exports.GetSuggestedTypes = GetSuggestedTypes; |
@@ -33,3 +33,3 @@ "use strict"; | ||
inherited: false, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -52,3 +52,3 @@ return reducedTypeProperty; | ||
}, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -71,3 +71,3 @@ return reducedTypeProperty; | ||
}, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -90,3 +90,3 @@ return reducedTypeProperty; | ||
}, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -105,3 +105,3 @@ return reducedTypeProperty; | ||
inherited: false, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -120,3 +120,3 @@ return reducedTypeProperty; | ||
inherited: false, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -135,3 +135,3 @@ return reducedTypeProperty; | ||
inherited: false, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -150,3 +150,3 @@ return reducedTypeProperty; | ||
inherited: false, | ||
propertyLevel: GetLevel(level) | ||
propertyLevel: GetLevel(level), | ||
}; | ||
@@ -153,0 +153,0 @@ return reducedTypeProperty; |
@@ -1,8 +0,8 @@ | ||
import { Relation } from "../relations/relation"; | ||
import { TypeInterface } from "../type-interfaces"; | ||
import { TypeOptionSetHierarchyLink } from "../type-option-set-hierarchies/option-set-hierarchy"; | ||
import { TypeProperty } from "../type-properties"; | ||
import { TypePropertyPolicy } from "../type-property-policies"; | ||
import { TypeRuleSet } from "../type-rule-sets/type-rules"; | ||
import { TypePolicy } from "../type-policies"; | ||
import { Relation } from '../relations/relation'; | ||
import { TypeInterface } from '../type-interfaces'; | ||
import { TypeOptionSetHierarchyLink } from '../type-option-set-hierarchies/option-set-hierarchy'; | ||
import { TypeProperty } from '../type-properties'; | ||
import { TypePropertyPolicy } from '../type-property-policies'; | ||
import { TypeRuleSet } from '../type-rule-sets/type-rules'; | ||
import { TypePolicy } from '../type-policies'; | ||
export interface Type { | ||
@@ -9,0 +9,0 @@ id?: string; |
{ | ||
"name": "@contrail/types", | ||
"version": "3.0.70", | ||
"version": "3.0.71", | ||
"description": "Types Utility module", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,1 +0,1 @@ | ||
Module used for different utilities like property formatter | ||
Module used for different utilities like property formatter |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79888
2
1878