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

@integration-app/sdk

Package Overview
Dependencies
Maintainers
4
Versions
444
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.22 to 0.16.23

flows/nodes/for-each.d.ts

2

accessors.d.ts

@@ -61,4 +61,4 @@ import { PaginationResponse } from './entity-repository';

delete(): Promise<void>;
private getPath;
protected getPath(operation?: string): string;
private getSelector;
}

@@ -30,8 +30,8 @@ "use strict";

function valueToSchema(value, schema, field = '') {
var _a;
function throwError(message) {
throw new Error(`${message}${field ? ` for field ${field}` : ''}`);
}
if (value === null || value === undefined) {
return undefined;
if ((value === null || value === undefined) &&
(schema === null || schema === void 0 ? void 0 : schema.default) !== undefined) {
value = schema.default;
}

@@ -43,29 +43,5 @@ switch (schema === null || schema === void 0 ? void 0 : schema.type) {

case 'number':
const result = Number(value);
if (isNaN(result)) {
throwError(`Cannot convert "${value}" to number`);
}
if (schema.type === 'integer' && !Number.isInteger(result)) {
throwError(`Expected integer but got ${value}`);
}
return result;
return valueToNumber();
case 'boolean':
if (typeof value === 'boolean') {
return value;
}
else if (typeof value === 'string') {
if (value === 'true') {
return true;
}
else if (value === 'false') {
return false;
}
else {
throwError(`Expected true or false but got "${value}"`);
}
}
else if (value) {
throwError(`Expected true or false but got "${value}"`);
}
return undefined;
return valueToBoolean();
case 'list':

@@ -79,19 +55,54 @@ if (Array.isArray(value)) {

case 'object':
if (typeof value === 'object' && value) {
const result = {};
for (const [key, fieldValue] of Object.entries(value)) {
const fieldSchema = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a[key];
if (!fieldSchema && schema && !schema.additionalProperties) {
continue;
}
result[key] = valueToSchema(fieldValue, fieldSchema, field ? `${field}.${key}` : key);
}
return result;
return valueToObject();
default:
return value;
}
function valueToNumber() {
const result = Number(value);
if (isNaN(result)) {
throwError(`Cannot convert "${value}" to number`);
}
if (schema.type === 'integer' && !Number.isInteger(result)) {
throwError(`Expected integer but got ${value}`);
}
return result;
}
function valueToBoolean() {
if (typeof value === 'boolean') {
return value;
}
else if (typeof value === 'string') {
if (value === 'true') {
return true;
}
else if (value === 'false') {
return false;
}
else {
return undefined;
throwError(`Expected true or false but got "${value}"`);
}
default:
return value;
}
else if (value) {
throwError(`Expected true or false but got "${value}"`);
}
return undefined;
}
function valueToObject() {
var _a;
const result = {};
for (const [key, propertySchema] of Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {})) {
const propertyValue = valueToSchema(value === null || value === void 0 ? void 0 : value[key], propertySchema, field ? `${field}.${key}` : key);
if (propertyValue !== undefined) {
result[key] = propertyValue;
}
}
if (schema.additionalProperties) {
for (const [key, fieldValue] of Object.entries(value !== null && value !== void 0 ? value : {})) {
if (!result[key]) {
result[key] = (0, structured_clone_1.default)(fieldValue);
}
}
}
return result;
}
}

@@ -98,0 +109,0 @@ exports.valueToSchema = valueToSchema;

@@ -16,2 +16,3 @@ import { DataSource } from '.';

setup(): Promise<void>;
unifiedFieldsToNative(unifiedFields: any): Promise<any>;
openConfiguration(options?: OpenDataSourceConfiguration): Promise<void>;

@@ -18,0 +19,0 @@ getCollection(): Promise<DataCollectionSpec>;

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

}
async unifiedFieldsToNative(unifiedFields) {
return this.client.post(this.getPath('unified-fields-to-native'), unifiedFields);
}
async openConfiguration(options) {

@@ -27,0 +30,0 @@ (0, iframe_1.showIframeLoader)();

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

testInput?: any;
testConfig?: any;
dependencies?: IntegrationElementInstance[];

@@ -78,0 +77,0 @@ }

@@ -21,4 +21,5 @@ import { FlowNodeSpec } from './base';

FindDataLink = "find-data-link",
ForEach = "for-each",
FindDataRecords = "find-data-records"
}
export declare const FLOW_NODE_SPECS: Record<FlowNodeType, FlowNodeSpec>;

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

FlowNodeType["FindDataLink"] = "find-data-link";
FlowNodeType["ForEach"] = "for-each";
FlowNodeType["FindDataRecords"] = "find-data-records";

@@ -48,3 +49,4 @@ })(FlowNodeType = exports.FlowNodeType || (exports.FlowNodeType = {}));

[FlowNodeType.FindDataLink]: require('./find-data-link').default,
[FlowNodeType.ForEach]: require('./for-each').default,
};
//# sourceMappingURL=index.js.map

@@ -20,2 +20,3 @@ export * from './app-data-schemas';

export * from './workspaces';
export * from './variables';
export { IntegrationAppClient } from './client';

@@ -24,4 +24,5 @@ "use strict";

tslib_1.__exportStar(require("./workspaces"), exports);
tslib_1.__exportStar(require("./variables"), exports);
var client_1 = require("./client");
Object.defineProperty(exports, "IntegrationAppClient", { enumerable: true, get: function () { return client_1.IntegrationAppClient; } });
//# sourceMappingURL=index.js.map
{
"name": "@integration-app/sdk",
"version": "0.16.22",
"version": "0.16.23",
"description": "JavaScript SDK for Integration.app",

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

@@ -146,3 +146,3 @@ import { PaginationResponse } from './entity-repository'

private getPath(operation = '') {
protected getPath(operation = '') {
return (

@@ -149,0 +149,0 @@ this.options.instancePath +

@@ -5,2 +5,3 @@ import {

pickFieldsFromSchema,
valueToSchema,
} from '.'

@@ -153,1 +154,93 @@

})
describe('valueToSchema', () => {
it('should apply default values', () => {
const schema = {
type: 'object',
properties: {
field: {
type: 'string',
default: 'defalutValue',
},
},
}
expect(valueToSchema({}, schema)).toEqual({
field: 'defalutValue',
})
expect(valueToSchema(null, schema)).toEqual({
field: 'defalutValue',
})
expect(valueToSchema({ anotherField: 'anotherValue' }, schema)).toEqual({
field: 'defalutValue',
})
})
it('should apply `false` default value', () => {
const schema = {
type: 'object',
properties: {
field: {
type: 'boolean',
default: false,
},
},
}
expect(valueToSchema({}, schema)).toEqual({
field: false,
})
})
it('should not apply default value if value is provided', () => {
const schema = {
type: 'object',
properties: {
field: {
type: 'string',
default: 'defalutValue',
},
},
}
expect(valueToSchema({ field: 'value' }, schema)).toEqual({
field: 'value',
})
})
it('should exclude properties not in schema', () => {
const schema = {
type: 'object',
properties: {
field: {
type: 'string',
},
},
}
expect(
valueToSchema({ field: 'value', anotherField: 'anotherValue' }, schema),
).toEqual({
field: 'value',
})
})
it('should not exclude properties if additionalProperties is set', () => {
const schema = {
type: 'object',
additionalProperties: true,
properties: {
field: {
type: 'string',
},
},
}
expect(
valueToSchema({ field: 'value', anotherField: 'anotherValue' }, schema),
).toEqual({
field: 'value',
anotherField: 'anotherValue',
})
})
})

@@ -120,4 +120,7 @@ import {

if (value === null || value === undefined) {
return undefined
if (
(value === null || value === undefined) &&
schema?.default !== undefined
) {
value = schema.default
}

@@ -130,25 +133,5 @@

case 'number':
const result = Number(value)
if (isNaN(result)) {
throwError(`Cannot convert "${value}" to number`)
}
if (schema.type === 'integer' && !Number.isInteger(result)) {
throwError(`Expected integer but got ${value}`)
}
return result
return valueToNumber()
case 'boolean':
if (typeof value === 'boolean') {
return value
} else if (typeof value === 'string') {
if (value === 'true') {
return true
} else if (value === 'false') {
return false
} else {
throwError(`Expected true or false but got "${value}"`)
}
} else if (value) {
throwError(`Expected true or false but got "${value}"`)
}
return undefined
return valueToBoolean()
case 'list':

@@ -161,25 +144,58 @@ if (Array.isArray(value)) {

case 'object':
if (typeof value === 'object' && value) {
const result = {}
for (const [key, fieldValue] of Object.entries(value)) {
const fieldSchema = schema?.properties?.[key]
return valueToObject()
default:
return value
}
if (!fieldSchema && schema && !schema.additionalProperties) {
// Property is not in schema - ignore it
continue
}
function valueToNumber() {
const result = Number(value)
if (isNaN(result)) {
throwError(`Cannot convert "${value}" to number`)
}
if (schema.type === 'integer' && !Number.isInteger(result)) {
throwError(`Expected integer but got ${value}`)
}
return result
}
result[key] = valueToSchema(
fieldValue,
fieldSchema,
field ? `${field}.${key}` : key,
)
}
return result
function valueToBoolean() {
if (typeof value === 'boolean') {
return value
} else if (typeof value === 'string') {
if (value === 'true') {
return true
} else if (value === 'false') {
return false
} else {
return undefined
throwError(`Expected true or false but got "${value}"`)
}
default:
return value
} else if (value) {
throwError(`Expected true or false but got "${value}"`)
}
return undefined
}
function valueToObject() {
const result = {}
for (const [key, propertySchema] of Object.entries(
schema.properties ?? {},
)) {
const propertyValue = valueToSchema(
value?.[key],
propertySchema,
field ? `${field}.${key}` : key,
)
if (propertyValue !== undefined) {
result[key] = propertyValue
}
}
if (schema.additionalProperties) {
for (const [key, fieldValue] of Object.entries(value ?? {})) {
if (!result[key]) {
result[key] = structuredClone(fieldValue)
}
}
}
return result
}
}

@@ -186,0 +202,0 @@

@@ -65,2 +65,9 @@ import { DataSource } from '.'

async unifiedFieldsToNative(unifiedFields): Promise<any> {
return this.client.post(
this.getPath('unified-fields-to-native'),
unifiedFields,
)
}
async openConfiguration(

@@ -67,0 +74,0 @@ options?: OpenDataSourceConfiguration,

@@ -240,7 +240,2 @@ import { ErrorData } from '../errors'

/**
* Node's config materialized with the test data. Used for testing the node.
*/
testConfig?: any
/**
* List of dependencies.

@@ -247,0 +242,0 @@ */

@@ -24,2 +24,4 @@ import { FlowNodeSpec } from './base'

FindDataLink = 'find-data-link',
ForEach = 'for-each',
/**

@@ -58,2 +60,4 @@ * @deprecated

[FlowNodeType.FindDataLink]: require('./find-data-link').default,
[FlowNodeType.ForEach]: require('./for-each').default,
}

@@ -20,3 +20,4 @@ export * from './app-data-schemas'

export * from './workspaces'
export * from './variables'
export { IntegrationAppClient } from './client'

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

import { Flow, FlowInstance } from './flows'
import { DataSchema } from './data-schema'
import { FlowInstance, getUpstreamNodeKeys } from './flows'

@@ -22,13 +23,61 @@ export function getNodeInputSchema(flow: FlowInstance, nodeKey: string): any {

export function getUpstreamNodeKeys(
flow: Flow | FlowInstance,
nodeKey: string,
): string[] {
const upLinkedNodeKeys = Object.entries(flow.nodes ?? {})
.filter(([_key, node]) => node.links?.some((l) => l.key == nodeKey))
.map(([key]) => key)
// Recursively find previous nodes for each directly previous node
return upLinkedNodeKeys.concat(
upLinkedNodeKeys.map((k) => getUpstreamNodeKeys(flow, k)).flat(),
)
export function getFlowNodeConfigTimeVariablesSchema({
parametersSchema,
userSchema,
}: {
parametersSchema: DataSchema
userSchema: DataSchema
}): DataSchema {
return {
type: 'object',
properties: {
flowInstance: getFlowInstanceVariableSchema({ parametersSchema }),
user: userSchema,
},
}
}
export function getFlowNodeRunTimeVariablesSchema({
parametersSchema,
inputSchema,
userSchema,
}: {
parametersSchema: DataSchema
inputSchema: DataSchema
userSchema: DataSchema
}): DataSchema {
return {
type: 'object',
properties: {
input: inputSchema,
flowRun: getFlowRunVariableSchema(),
flowInstance: getFlowInstanceVariableSchema({ parametersSchema }),
user: userSchema,
},
}
}
function getFlowInstanceVariableSchema({
parametersSchema,
}: {
parametersSchema: DataSchema
}): DataSchema {
return {
type: 'object',
properties: {
id: { type: 'string ' },
instanceKey: { type: 'string' },
flowId: { type: 'string' },
parameters: parametersSchema,
},
}
}
function getFlowRunVariableSchema(): DataSchema {
return {
type: 'object',
properties: {
id: { type: 'string ' },
},
}
}

@@ -1,3 +0,12 @@

import { Flow, FlowInstance } from './flows';
import { DataSchema } from './data-schema';
import { FlowInstance } from './flows';
export declare function getNodeInputSchema(flow: FlowInstance, nodeKey: string): any;
export declare function getUpstreamNodeKeys(flow: Flow | FlowInstance, nodeKey: string): string[];
export declare function getFlowNodeConfigTimeVariablesSchema({ parametersSchema, userSchema, }: {
parametersSchema: DataSchema;
userSchema: DataSchema;
}): DataSchema;
export declare function getFlowNodeRunTimeVariablesSchema({ parametersSchema, inputSchema, userSchema, }: {
parametersSchema: DataSchema;
inputSchema: DataSchema;
userSchema: DataSchema;
}): DataSchema;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUpstreamNodeKeys = exports.getNodeInputSchema = void 0;
exports.getFlowNodeRunTimeVariablesSchema = exports.getFlowNodeConfigTimeVariablesSchema = exports.getNodeInputSchema = void 0;
const flows_1 = require("./flows");
function getNodeInputSchema(flow, nodeKey) {

@@ -9,3 +10,3 @@ const schema = {

};
getUpstreamNodeKeys(flow, nodeKey).forEach((prevNodeKey) => {
(0, flows_1.getUpstreamNodeKeys)(flow, nodeKey).forEach((prevNodeKey) => {
const prevNode = flow.nodes[prevNodeKey];

@@ -23,10 +24,43 @@ if (prevNode.outputSchema) {

exports.getNodeInputSchema = getNodeInputSchema;
function getUpstreamNodeKeys(flow, nodeKey) {
var _a;
const upLinkedNodeKeys = Object.entries((_a = flow.nodes) !== null && _a !== void 0 ? _a : {})
.filter(([_key, node]) => { var _a; return (_a = node.links) === null || _a === void 0 ? void 0 : _a.some((l) => l.key == nodeKey); })
.map(([key]) => key);
return upLinkedNodeKeys.concat(upLinkedNodeKeys.map((k) => getUpstreamNodeKeys(flow, k)).flat());
function getFlowNodeConfigTimeVariablesSchema({ parametersSchema, userSchema, }) {
return {
type: 'object',
properties: {
flowInstance: getFlowInstanceVariableSchema({ parametersSchema }),
user: userSchema,
},
};
}
exports.getUpstreamNodeKeys = getUpstreamNodeKeys;
exports.getFlowNodeConfigTimeVariablesSchema = getFlowNodeConfigTimeVariablesSchema;
function getFlowNodeRunTimeVariablesSchema({ parametersSchema, inputSchema, userSchema, }) {
return {
type: 'object',
properties: {
input: inputSchema,
flowRun: getFlowRunVariableSchema(),
flowInstance: getFlowInstanceVariableSchema({ parametersSchema }),
user: userSchema,
},
};
}
exports.getFlowNodeRunTimeVariablesSchema = getFlowNodeRunTimeVariablesSchema;
function getFlowInstanceVariableSchema({ parametersSchema, }) {
return {
type: 'object',
properties: {
id: { type: 'string ' },
instanceKey: { type: 'string' },
flowId: { type: 'string' },
parameters: parametersSchema,
},
};
}
function getFlowRunVariableSchema() {
return {
type: 'object',
properties: {
id: { type: 'string ' },
},
};
}
//# sourceMappingURL=variables.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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