Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contrail/types

Package Overview
Dependencies
Maintainers
9
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/types - npm Package Compare versions

Comparing version 2.0.67 to 2.0.69

0

lib/formatter/index.d.ts
export * from './property-value-formatter';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { DateFormatingOptions, NumberFormatingOptions, TypeProperty } from '../type-properties';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { TypeProperty } from "../type-properties";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { TypeProperty } from '../type-properties';

@@ -0,0 +0,0 @@ "use strict";

export * from './formula-processor';
export * from './formula-function-processor';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export * from './formatter';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface Relation {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export * from './type-interface';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface TypeInterface {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export * from './property-types';
export * from './type-property';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare enum PropertyType {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { PropertyType } from '.';

@@ -0,0 +0,0 @@ "use strict";

export * from './type-property-policy';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Policy } from '@contrail/policies';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export * from './type-root';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface TypeRoot {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export * from './interfaces';
export * from './parse-optionSet';
export * from './process-orchestrator';

@@ -0,0 +0,0 @@ "use strict";

1

lib/types-processor/interfaces.d.ts

@@ -25,2 +25,3 @@ import { PropertyType } from "../type-properties";

validationFunction?: string;
numberFormat?: any;
}

@@ -27,0 +28,0 @@ export interface ReducedOptionSet {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
import { ReducedOptionSet } from './interfaces';
export declare function parseOptionSets(csvData: any[]): ReducedOptionSet[];
export declare function parseOptionSet(columnName: any, values: Set<string>): ReducedOptionSet;

12

lib/types-processor/parse-optionSet.js

@@ -39,7 +39,9 @@ "use strict";

const optionSet = [];
for (const entry of values.values()) {
optionSet.push({
value: util_1.StringUtil.convertToCamelCase(entry),
display: entry,
});
if (values) {
for (const entry of values.values()) {
optionSet.push({
value: util_1.StringUtil.convertToCamelCase(entry),
display: entry,
});
}
}

@@ -46,0 +48,0 @@ const reducedOptionSet = {

import { ReducedTypeProperty, ReducedOptionSet } from './interfaces';
export declare function GetTypesFromTemplate(typeRows: any[], dataForOptionSets: any[]): {
TypePropertiesByEntity: {};
OptionSets: ReducedOptionSet[];
};
export declare function GetSuggestedTypes(data: any[]): {

@@ -3,0 +7,0 @@ TypeProperties: ReducedTypeProperty[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetSuggestedTypes = void 0;
exports.GetSuggestedTypes = exports.GetTypesFromTemplate = void 0;
const parse_optionSet_1 = require("./parse-optionSet");

@@ -9,2 +9,91 @@ const util_1 = require("@contrail/util");

}
function GetTypesFromTemplate(typeRows, dataForOptionSets) {
const valuesByFieldName = {};
for (const row of dataForOptionSets) {
for (const [key, value] of Object.entries(row)) {
if (!value) {
continue;
}
if (!valuesByFieldName[key]) {
valuesByFieldName[key] = { count: 0, values: new Set() };
}
valuesByFieldName[key].values.add(value);
valuesByFieldName[key].count += 1;
}
}
console.log('Data recieved for: ', Object.keys(valuesByFieldName));
console.log('Sorted data by column completed.');
const reducedTypePropertiesByEntity = {};
reducedTypePropertiesByEntity['Plan-Placeholder'] = [];
const reducedOptionSets = [];
console.log('Creating TypeProperties and OptionSets');
for (const typeRow of typeRows) {
const propertyLabel = typeRow['Property Label*'];
const propertyType = typeRow['Property Type*'];
const entity = typeRow['Entity*'];
const level = typeRow['Level*'];
const isCore = typeRow['Vibe oob Property?'];
const editable = !!typeRow['Editable?'];
let precision = typeRow['Decimals(for #, %, $ types)'];
if (precision && precision.length > 1) {
precision = precision.charAt(0);
}
if (isCore || !propertyType || !propertyLabel) {
console.log('Skipping: ' + propertyLabel);
continue;
}
console.log('Creating TypeProperty for: ', propertyLabel);
let reducedTypeProperty;
if (propertyType === 'Number') {
console.log('Creating Number TypeProperty');
reducedTypeProperty = getNumberProperty(propertyLabel, precision, editable, level);
}
else if (propertyType === 'Percent') {
console.log('Creating Percent TypeProperty');
reducedTypeProperty = getPercentProperty(propertyLabel, precision, editable, level);
}
else if (propertyType === 'Currency') {
console.log('Creating Currency TypeProperty');
reducedTypeProperty = getCurrencyProperty(propertyLabel, precision, editable, level);
}
else if (propertyType === 'Date') {
console.log('Creating Date TypeProperty');
reducedTypeProperty = getDateProperty(propertyLabel, editable, level);
}
else if (propertyType === 'Boolean') {
console.log('Creating Boolean TypeProperty');
reducedTypeProperty = getBooleanProperty(propertyLabel, editable, level);
}
else if (propertyType === 'Single Select') {
console.log('Creating SingleSelect TypeProperty and OptionSet');
reducedTypeProperty = getOptionSetProperty(true, propertyLabel, editable, level);
const optionSet = (0, parse_optionSet_1.parseOptionSet)(propertyLabel, valuesByFieldName[propertyLabel]?.values);
reducedOptionSets.push(optionSet);
}
else if (propertyType === 'Multi Select') {
console.log('Creating MultiSelect TypeProperty and OptionSet');
reducedTypeProperty = getOptionSetProperty(false, propertyLabel, editable, level);
const optionSet = (0, parse_optionSet_1.parseOptionSet)(propertyLabel, valuesByFieldName[propertyLabel]?.values);
reducedOptionSets.push(optionSet);
}
else if (propertyType === 'String') {
console.log('Creating String TypeProperty');
reducedTypeProperty = getStringProperty(propertyLabel, editable, level);
}
else {
console.log(`Skipping: ${propertyLabel}. There is no matching type for ${propertyType}`);
continue;
}
if (!reducedTypePropertiesByEntity[entity]) {
reducedTypePropertiesByEntity[entity] = [];
}
reducedTypePropertiesByEntity[entity].push(JSON.parse(JSON.stringify(reducedTypeProperty)));
reducedTypePropertiesByEntity['Plan-Placeholder'].push(JSON.parse(JSON.stringify(reducedTypeProperty)));
}
return {
'TypePropertiesByEntity': reducedTypePropertiesByEntity,
'OptionSets': reducedOptionSets
};
}
exports.GetTypesFromTemplate = GetTypesFromTemplate;
function GetSuggestedTypes(data) {

@@ -85,3 +174,3 @@ const valuesByFieldName = {};

console.log('Creating SingleSelect TypeProperty and OptionSet');
reducedTypeProperty = getOptionSetProperty(key);
reducedTypeProperty = getOptionSetProperty(true, key);
const optionSet = (0, parse_optionSet_1.parseOptionSet)(key, typeValueSummary.values);

@@ -98,3 +187,3 @@ reducedOptionSets.push(optionSet);

console.log('Mixed Values - Creating SingleSelect TypeProperty and OptionSet');
reducedTypeProperty = getOptionSetProperty(key);
reducedTypeProperty = getOptionSetProperty(true, key);
const optionSet = (0, parse_optionSet_1.parseOptionSet)(key, typeValueSummary.values);

@@ -116,16 +205,32 @@ reducedOptionSets.push(optionSet);

exports.GetSuggestedTypes = GetSuggestedTypes;
function getOptionSetProperty(key) {
function getLevel(level) {
if (level === 'Family') {
return 'family';
}
else if (level === 'Option') {
return 'option';
}
else if (level === 'Overridable') {
return 'overridable';
}
else if (level === 'All') {
return 'all';
}
return undefined;
}
function getOptionSetProperty(isSingleSelect, key, editable = false, level = null) {
const reducedTypeProperty = {
slug: util_1.StringUtil.convertToCamelCase(key),
label: key,
propertyType: type_properties_1.PropertyType.SingleSelect,
propertyType: isSingleSelect ? type_properties_1.PropertyType.SingleSelect : type_properties_1.PropertyType.MultiSelect,
typePropertyOptionSetName: key,
isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getNumberProperty(key) {
function getNumberProperty(key, precision = 0, editable = false, level = null) {
const reducedTypeProperty = {

@@ -136,21 +241,48 @@ slug: util_1.StringUtil.convertToCamelCase(key),

isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
numberFormat: {
format: precision === 0 ? 'integer' : 'decimal',
precision: precision,
},
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getCurrencyProperty(key) {
function getPercentProperty(key, precision = 0, editable = false, level = null) {
const reducedTypeProperty = {
slug: util_1.StringUtil.convertToCamelCase(key),
label: key,
propertyType: type_properties_1.PropertyType.Percent,
isArchived: false,
editable: editable,
core: false,
inherited: false,
numberFormat: {
format: 'percent',
precision: precision,
},
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getCurrencyProperty(key, precision = 0, editable = false, level = null) {
const reducedTypeProperty = {
slug: util_1.StringUtil.convertToCamelCase(key),
label: key,
propertyType: type_properties_1.PropertyType.Currency,
isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
numberFormat: {
format: 'currency',
precision: precision,
},
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getDateProperty(key) {
function getDateProperty(key, editable = false, level = null) {
const reducedTypeProperty = {

@@ -161,9 +293,10 @@ slug: util_1.StringUtil.convertToCamelCase(key),

isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getStringProperty(key) {
function getStringProperty(key, editable = false, level = null) {
const reducedTypeProperty = {

@@ -174,9 +307,10 @@ slug: util_1.StringUtil.convertToCamelCase(key),

isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
function getBooleanProperty(key) {
function getBooleanProperty(key, editable = false, level = null) {
const reducedTypeProperty = {

@@ -187,7 +321,8 @@ slug: util_1.StringUtil.convertToCamelCase(key),

isArchived: false,
editable: false,
editable: editable,
core: false,
inherited: false,
propertyLevel: getLevel(level)
};
return reducedTypeProperty;
}
export * from './type';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Relation } from "../relations/relation";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export * from './type-managed-validator';
export * from './validation-summary';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ValidationError, ValidationSummary } from './validation-summary';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface ValidationError {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
{
"name": "@contrail/types",
"version": "2.0.67",
"version": "2.0.69",
"description": "Types Utility module",

@@ -18,5 +18,5 @@ "main": "lib/index.js",

"@types/node": "^14.18.12",
"jest": "^23.6.0",
"jest": "^29.3.1",
"prettier": "^1.19.1",
"ts-jest": "^23.10.5",
"ts-jest": "^29.0.3",
"tslint": "^5.11.0",

@@ -23,0 +23,0 @@ "tslint-config-prettier": "^1.18.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc