New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@integration-app/sdk

Package Overview
Dependencies
Maintainers
4
Versions
445
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@integration-app/sdk - npm Package Compare versions

Comparing version 0.16.21 to 0.16.22

1

data-builder/formulas/index.d.ts

@@ -68,3 +68,4 @@ import { DataBuilderFormulaBase } from './base';

export declare function processCopy(data: any): any;
export declare function transformVars(value: any, transformations: Record<string, any>): any;
export declare function isEmpty(value: any): boolean;
export declare function getSchemaFromValue(value: any, variablesSchema: any, ignoreFormulas?: boolean): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaFromValue = exports.isEmpty = exports.processCopy = exports.processValue = exports.getFormula = exports.isFormula = exports.Formula = exports.DataBuilderFormulaType = void 0;
exports.getSchemaFromValue = exports.isEmpty = exports.transformVars = exports.processCopy = exports.processValue = exports.getFormula = exports.isFormula = exports.Formula = exports.DataBuilderFormulaType = void 0;
const tslib_1 = require("tslib");
const errors_1 = require("../../errors");

@@ -27,2 +28,3 @@ const data_schema_1 = require("../../data-schema");

const or_1 = require("./or");
const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
var DataBuilderFormulaType;

@@ -167,2 +169,14 @@ (function (DataBuilderFormulaType) {

exports.processCopy = processCopy;
function transformVars(value, transformations) {
let transformedValue = (0, structured_clone_1.default)(value);
const varFormulaLocators = (0, locators_1.getFormulaLocators)(DataBuilderFormulaType.VAR, value);
for (const varLocator of varFormulaLocators) {
const formula = getFormula((0, locators_1.getValueAtLocator)(value, varLocator));
const variableLocator = formula.locator;
const transformedFormula = (0, locators_1.getValueAtLocator)(transformations, variableLocator);
transformedValue = (0, locators_1.setValueAtLocator)(transformedValue, varLocator, transformedFormula);
}
return transformedValue;
}
exports.transformVars = transformVars;
function isEmpty(value) {

@@ -169,0 +183,0 @@ return typeof value == 'undefined';

@@ -81,2 +81,3 @@ import { ErrorData } from '../errors';

filter?: DataFilter;
name?: string;
}

@@ -83,0 +84,0 @@ export interface OpenFlowInstanceConfigurationOptions {

2

package.json
{
"name": "@integration-app/sdk",
"version": "0.16.21",
"version": "0.16.22",
"description": "JavaScript SDK for Integration.app",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

import { getFormula } from '.'
import { getFormula, transformVars } from '.'
import { DataBuilderFormulaRecord } from './record'

@@ -22,1 +22,49 @@

})
describe('transformVars', () => {
it('should transform $var formulas', () => {
expect(
transformVars(
{
$var: 'field',
},
{
field: {
$var: 'field2',
},
},
),
).toEqual({
$var: 'field2',
})
})
it('should transform nested $var formulas', () => {
expect(
transformVars(
[
{
field1: {
$var: 'var',
},
},
],
{
var: {
$firstName: {
$var: 'var2',
},
},
},
),
).toEqual([
{
field1: {
$firstName: {
$var: 'var2',
},
},
},
])
})
})

@@ -29,2 +29,3 @@ import { FlowConfigurationError } from '../../errors'

import { Or } from './or'
import structuredClone from '@ungap/structured-clone'

@@ -174,2 +175,42 @@ export enum DataBuilderFormulaType {

/**
* Transforms $var formulas into a different formula using transformation rules.
* Transformation rules look like:
* {
* "field": <formula>
* }
*
* This function will transform anything that has { $var: "field" } into <formula>
*/
export function transformVars(
value: any,
transformations: Record<string, any>,
) {
let transformedValue = structuredClone(value)
const varFormulaLocators = getFormulaLocators(
DataBuilderFormulaType.VAR,
value,
)
for (const varLocator of varFormulaLocators) {
const formula = getFormula(
getValueAtLocator(value, varLocator),
) as DataBuilderFormulaVar
const variableLocator = formula.locator
const transformedFormula = getValueAtLocator(
transformations,
variableLocator,
)
transformedValue = setValueAtLocator(
transformedValue,
varLocator,
transformedFormula,
)
}
return transformedValue
}
export function isEmpty(value: any): boolean {

@@ -176,0 +217,0 @@ return typeof value == 'undefined'

@@ -257,2 +257,3 @@ import { ErrorData } from '../errors'

filter?: DataFilter
name?: string
}

@@ -259,0 +260,0 @@

@@ -50,2 +50,47 @@ import { Static, Type } from '@sinclair/typebox'

export const FallbackFieldsMap = {
fromTaskToActivities: {
subject: {
$var: 'title',
},
content: {
$var: 'description',
},
},
fromActivitiesToTask: {
title: {
$var: 'subject',
},
description: {
$var: 'content',
},
},
fromNoteToActivities: {
content: {
$var: 'description',
},
},
fromActivitiesToNote: {
description: {
$var: 'content',
},
},
fromEmailToActivities: {
subject: {
$var: 'title',
},
body: {
$var: 'description',
},
},
fromActivitiesToEmail: {
title: {
$var: 'subject',
},
description: {
$var: 'body',
},
},
}
const udm: UnifiedDataModel = {

@@ -62,2 +107,22 @@ singularName: 'activity',

populateFields,
udmFallbacks: [
{
udm: 'tasks',
importFields: FallbackFieldsMap.fromActivitiesToTask,
exportFields: FallbackFieldsMap.fromTaskToActivities,
},
{
udm: 'meetings',
},
{
udm: 'notes',
importFields: FallbackFieldsMap.fromActivitiesToNote,
exportFields: FallbackFieldsMap.fromNoteToActivities,
},
{
udm: 'emails',
importFields: FallbackFieldsMap.fromActivitiesToEmail,
exportFields: FallbackFieldsMap.fromEmailToActivities,
},
],
}

@@ -64,0 +129,0 @@

@@ -78,2 +78,26 @@ import { Static, Type } from '@sinclair/typebox'

populateFields: populateContactInfo,
fieldFallbacks: {
fullName: [
{
$concat: {
values: [{ $var: 'firstName' }, { $var: 'lastName' }],
delimiter: ' ',
},
},
],
firstName: [
{
$firstName: {
$var: 'fullName',
},
},
],
lastName: [
{
$lastName: {
$var: 'fullName',
},
},
],
},
}

@@ -80,0 +104,0 @@

import { Type } from '@sinclair/typebox'
import { FallbackFieldsMap } from './activities'
import { UnifiedDataModel } from './base'

@@ -39,5 +40,11 @@

},
udmFallbacks: [{ udm: 'activities' }],
udmFallbacks: [
{
udm: 'activities',
importFields: FallbackFieldsMap.fromEmailToActivities,
exportFields: FallbackFieldsMap.fromActivitiesToEmail,
},
],
}
export default udm

@@ -17,2 +17,14 @@ import { ConnectionDataSpec } from '../connections'

import users from './users'
import structuredClone from '@ungap/structured-clone'
import {
getFormulaLocators,
getValueAtLocator,
setValueAtLocator,
} from '../data-builder/locators'
import {
DataBuilderFormulaType,
getFormula,
transformVars,
} from '../data-builder/formulas'
import { DataBuilderFormulaVar } from '../data-builder/formulas/var'

@@ -79,1 +91,54 @@ export enum UDM {

}
/**
* Applies fallbackFields for the given UDM.
*/
export function addUdmFallbackFields(fields: any, udm: string): any {
if (!udm) {
return fields
}
const udmSpec = UNIFIED_DATA_MODELS[udm]
if (!udmSpec) {
throw new BadRequestError(`Unknown UDM: ${udm}`)
}
let result = structuredClone(fields)
if (udmSpec.fieldFallbacks) {
for (const field of Object.keys(udmSpec.fieldFallbacks)) {
const currentValue = getValueAtLocator(fields, field)
if (currentValue === undefined) {
for (const fallbackValue of udmSpec.fieldFallbacks[field]) {
const varFormulaLocators = getFormulaLocators(
DataBuilderFormulaType.VAR,
fallbackValue,
)
const varLocators = []
for (const varFormulaLocator of varFormulaLocators) {
const formula = getFormula(
getValueAtLocator(fallbackValue, varFormulaLocator),
) as DataBuilderFormulaVar
varLocators.push(formula.locator)
}
const fallbackValueHasDependencies = varLocators.some(
(locator) => getValueAtLocator(fields, locator) !== undefined,
)
if (fallbackValueHasDependencies) {
result = setValueAtLocator(
result,
field,
transformVars(fallbackValue, fields),
)
break
}
}
}
}
return result
}
return fields
}
import { Type } from '@sinclair/typebox'
import { FallbackFieldsMap } from './activities'
import { UnifiedDataModel } from './base'

@@ -48,2 +49,4 @@

udm: 'activities',
importFields: FallbackFieldsMap.fromNoteToActivities,
exportFields: FallbackFieldsMap.fromActivitiesToNote,
},

@@ -50,0 +53,0 @@ ],

import { Type } from '@sinclair/typebox'
import { FallbackFieldsMap } from './activities'
import { UnifiedDataModel } from './base'

@@ -52,2 +53,4 @@

udm: 'activities',
importFields: FallbackFieldsMap.fromTaskToActivities,
exportFields: FallbackFieldsMap.fromActivitiesToTask,
},

@@ -54,0 +57,0 @@ ],

@@ -29,3 +29,47 @@ import { Static } from '@sinclair/typebox';

export declare type UnifiedActivityFields = Static<typeof FIELDS_SCHEMA>;
export declare const FallbackFieldsMap: {
fromTaskToActivities: {
subject: {
$var: string;
};
content: {
$var: string;
};
};
fromActivitiesToTask: {
title: {
$var: string;
};
description: {
$var: string;
};
};
fromNoteToActivities: {
content: {
$var: string;
};
};
fromActivitiesToNote: {
description: {
$var: string;
};
};
fromEmailToActivities: {
subject: {
$var: string;
};
body: {
$var: string;
};
};
fromActivitiesToEmail: {
title: {
$var: string;
};
description: {
$var: string;
};
};
};
declare const udm: UnifiedDataModel;
export default udm;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIELDS_SCHEMA = void 0;
exports.FallbackFieldsMap = exports.FIELDS_SCHEMA = void 0;
const typebox_1 = require("@sinclair/typebox");

@@ -44,2 +44,46 @@ exports.FIELDS_SCHEMA = typebox_1.Type.Partial(typebox_1.Type.Object({

}));
exports.FallbackFieldsMap = {
fromTaskToActivities: {
subject: {
$var: 'title',
},
content: {
$var: 'description',
},
},
fromActivitiesToTask: {
title: {
$var: 'subject',
},
description: {
$var: 'content',
},
},
fromNoteToActivities: {
content: {
$var: 'description',
},
},
fromActivitiesToNote: {
description: {
$var: 'content',
},
},
fromEmailToActivities: {
subject: {
$var: 'title',
},
body: {
$var: 'description',
},
},
fromActivitiesToEmail: {
title: {
$var: 'subject',
},
description: {
$var: 'body',
},
},
};
const udm = {

@@ -56,2 +100,22 @@ singularName: 'activity',

populateFields,
udmFallbacks: [
{
udm: 'tasks',
importFields: exports.FallbackFieldsMap.fromActivitiesToTask,
exportFields: exports.FallbackFieldsMap.fromTaskToActivities,
},
{
udm: 'meetings',
},
{
udm: 'notes',
importFields: exports.FallbackFieldsMap.fromActivitiesToNote,
exportFields: exports.FallbackFieldsMap.fromNoteToActivities,
},
{
udm: 'emails',
importFields: exports.FallbackFieldsMap.fromActivitiesToEmail,
exportFields: exports.FallbackFieldsMap.fromEmailToActivities,
},
],
};

@@ -58,0 +122,0 @@ exports.default = udm;

@@ -67,2 +67,26 @@ "use strict";

populateFields: base_1.populateContactInfo,
fieldFallbacks: {
fullName: [
{
$concat: {
values: [{ $var: 'firstName' }, { $var: 'lastName' }],
delimiter: ' ',
},
},
],
firstName: [
{
$firstName: {
$var: 'fullName',
},
},
],
lastName: [
{
$lastName: {
$var: 'fullName',
},
},
],
},
};

@@ -69,0 +93,0 @@ exports.default = udm;

@@ -5,2 +5,3 @@ "use strict";

const typebox_1 = require("@sinclair/typebox");
const activities_1 = require("./activities");
exports.FIELDS_SCHEMA = typebox_1.Type.Partial(typebox_1.Type.Object({

@@ -38,5 +39,11 @@ subject: typebox_1.Type.String(),

},
udmFallbacks: [{ udm: 'activities' }],
udmFallbacks: [
{
udm: 'activities',
importFields: activities_1.FallbackFieldsMap.fromEmailToActivities,
exportFields: activities_1.FallbackFieldsMap.fromActivitiesToEmail,
},
],
};
exports.default = udm;
//# sourceMappingURL=emails.js.map

@@ -20,1 +20,2 @@ import { ConnectionDataSpec } from '../connections';

export declare function findUdmRootLocation(spec: ConnectionDataSpec, udm: string): DataLocation | undefined;
export declare function addUdmFallbackFields(fields: any, udm: string): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findUdmRootLocation = exports.UNIFIED_DATA_MODELS = exports.UDM = void 0;
exports.addUdmFallbackFields = exports.findUdmRootLocation = exports.UNIFIED_DATA_MODELS = exports.UDM = void 0;
const tslib_1 = require("tslib");

@@ -18,2 +18,5 @@ const errors_1 = require("../errors");

const users_1 = tslib_1.__importDefault(require("./users"));
const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
const locators_1 = require("../data-builder/locators");
const formulas_1 = require("../data-builder/formulas");
var UDM;

@@ -71,2 +74,35 @@ (function (UDM) {

exports.findUdmRootLocation = findUdmRootLocation;
function addUdmFallbackFields(fields, udm) {
if (!udm) {
return fields;
}
const udmSpec = exports.UNIFIED_DATA_MODELS[udm];
if (!udmSpec) {
throw new errors_1.BadRequestError(`Unknown UDM: ${udm}`);
}
let result = (0, structured_clone_1.default)(fields);
if (udmSpec.fieldFallbacks) {
for (const field of Object.keys(udmSpec.fieldFallbacks)) {
const currentValue = (0, locators_1.getValueAtLocator)(fields, field);
if (currentValue === undefined) {
for (const fallbackValue of udmSpec.fieldFallbacks[field]) {
const varFormulaLocators = (0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, fallbackValue);
const varLocators = [];
for (const varFormulaLocator of varFormulaLocators) {
const formula = (0, formulas_1.getFormula)((0, locators_1.getValueAtLocator)(fallbackValue, varFormulaLocator));
varLocators.push(formula.locator);
}
const fallbackValueHasDependencies = varLocators.some((locator) => (0, locators_1.getValueAtLocator)(fields, locator) !== undefined);
if (fallbackValueHasDependencies) {
result = (0, locators_1.setValueAtLocator)(result, field, (0, formulas_1.transformVars)(fallbackValue, fields));
break;
}
}
}
}
return result;
}
return fields;
}
exports.addUdmFallbackFields = addUdmFallbackFields;
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ "use strict";

const typebox_1 = require("@sinclair/typebox");
const activities_1 = require("./activities");
exports.FIELDS_SCHEMA = typebox_1.Type.Partial(typebox_1.Type.Object({

@@ -47,2 +48,4 @@ title: typebox_1.Type.String(),

udm: 'activities',
importFields: activities_1.FallbackFieldsMap.fromNoteToActivities,
exportFields: activities_1.FallbackFieldsMap.fromActivitiesToNote,
},

@@ -49,0 +52,0 @@ ],

@@ -5,2 +5,3 @@ "use strict";

const typebox_1 = require("@sinclair/typebox");
const activities_1 = require("./activities");
exports.FIELDS_SCHEMA = typebox_1.Type.Partial(typebox_1.Type.Object({

@@ -51,2 +52,4 @@ subject: typebox_1.Type.String(),

udm: 'activities',
importFields: activities_1.FallbackFieldsMap.fromTaskToActivities,
exportFields: activities_1.FallbackFieldsMap.fromActivitiesToTask,
},

@@ -53,0 +56,0 @@ ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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