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

@integration-app/sdk

Package Overview
Dependencies
Maintainers
3
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.1.23 to 0.1.24

47

data-composer.js

@@ -117,26 +117,33 @@ "use strict";

return sourceLocator;
if (sourceLocator === '$')
return [];
const locators = [];
const parts = sourceLocator.split('.').slice(1);
lodash_1.default.each(parts, (p) => {
if (p === '$current') {
locators.push(new DataLocatorCurrentArrayItem());
return;
let cursorPosition = 1;
while (cursorPosition < sourceLocator.length) {
if (sourceLocator[cursorPosition] === '.') {
const closingIndex = lodash_1.default.min(lodash_1.default.filter([
sourceLocator.indexOf('[', cursorPosition + 1),
sourceLocator.indexOf('<', cursorPosition + 1),
sourceLocator.indexOf('.', cursorPosition + 1),
sourceLocator.length,
], (n) => n > -1));
const part = sourceLocator.slice(cursorPosition + 1, closingIndex);
locators.push(part === '$current'
? new DataLocatorCurrentArrayItem()
: new DataLocatorObjectProperty(part));
cursorPosition = closingIndex;
}
const lowestOpeningIndex = lodash_1.default.min(lodash_1.default.filter([p.indexOf('<'), p.indexOf('[')], (e) => e > 0));
locators.push(new DataLocatorObjectProperty(lowestOpeningIndex ? p.slice(0, lowestOpeningIndex) : p));
if (p.indexOf('<') > -1) {
const openingIndex = p.indexOf('<');
const closingIndex = p.indexOf('>', openingIndex);
const anyOfIndex = +p.slice(openingIndex + 1, closingIndex);
else if (sourceLocator[cursorPosition] === '[') {
const closingIndex = sourceLocator.indexOf(']', cursorPosition);
const arrayIndex = +sourceLocator.slice(cursorPosition + 1, closingIndex);
locators.push(new DataLocatorArrayItem(arrayIndex));
cursorPosition = closingIndex + 1;
}
else if (sourceLocator[cursorPosition] === '<') {
const closingIndex = sourceLocator.indexOf('>', cursorPosition);
const anyOfIndex = +sourceLocator.slice(cursorPosition + 1, closingIndex);
locators.push(new DataLocatorAnyOfOption(anyOfIndex));
cursorPosition = closingIndex + 1;
}
let indexCursor = 0;
while (p.indexOf('[', indexCursor) > -1) {
const openingIndex = p.indexOf('[', indexCursor);
const closingIndex = p.indexOf(']', openingIndex);
indexCursor = closingIndex;
const arrayIndex = +p.slice(openingIndex + 1, closingIndex);
locators.push(new DataLocatorArrayItem(arrayIndex));
}
});
}
return locators;

@@ -143,0 +150,0 @@ }

@@ -128,2 +128,7 @@ "use strict";

});
it('should extract locators if root is array', () => {
expect((0, data_composer_1.transformToDataLocator)('$[5]')).toEqual([
new data_composer_1.DataLocatorArrayItem(5),
]);
});
it('should extract locators from string locator with $current', () => {

@@ -165,4 +170,14 @@ expect((0, data_composer_1.transformToDataLocator)('$.$current.name')).toEqual([

});
it('should extract locators from nested arrays with nested anyOf locator', () => {
expect((0, data_composer_1.transformToDataLocator)('$.field<10>[0]<5>[3].subfield')).toEqual([
new data_composer_1.DataLocatorObjectProperty('field'),
new data_composer_1.DataLocatorAnyOfOption(10),
new data_composer_1.DataLocatorArrayItem(0),
new data_composer_1.DataLocatorAnyOfOption(5),
new data_composer_1.DataLocatorArrayItem(3),
new data_composer_1.DataLocatorObjectProperty('subfield'),
]);
});
});
});
//# sourceMappingURL=data-composer.test.js.map

@@ -75,4 +75,8 @@ export declare enum ErrorType {

}
export declare class ConnectionNotFoundError extends NotFoundError {
connectionId?: string;
constructor(message: any, connectionId?: string);
}
export declare class NotAuthenticatedError extends InputError {
constructor(message: any);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotAuthenticatedError = exports.NotFoundError = exports.ConnectionError = exports.EndpointError = exports.FlowRunError = exports.FlowConfigurationError = exports.InputError = exports.InternalError = exports.EngineError = exports.InputErrorData = exports.FlowRunErrorData = exports.FlowConfigurationErrorData = exports.ConnectionErrorData = exports.EndpointErrorData = exports.InternalErrorData = exports.BaseErrorData = exports.ErrorCode = exports.ErrorType = void 0;
exports.NotAuthenticatedError = exports.ConnectionNotFoundError = exports.NotFoundError = exports.ConnectionError = exports.EndpointError = exports.FlowRunError = exports.FlowConfigurationError = exports.InputError = exports.InternalError = exports.EngineError = exports.InputErrorData = exports.FlowRunErrorData = exports.FlowConfigurationErrorData = exports.ConnectionErrorData = exports.EndpointErrorData = exports.InternalErrorData = exports.BaseErrorData = exports.ErrorCode = exports.ErrorType = void 0;
var ErrorType;

@@ -135,2 +135,9 @@ (function (ErrorType) {

exports.NotFoundError = NotFoundError;
class ConnectionNotFoundError extends NotFoundError {
constructor(message, connectionId) {
super(message);
this.connectionId = connectionId;
}
}
exports.ConnectionNotFoundError = ConnectionNotFoundError;
class NotAuthenticatedError extends InputError {

@@ -137,0 +144,0 @@ constructor(message) {

{
"name": "@integration-app/sdk",
"version": "0.1.23",
"version": "0.1.24",
"description": "JavaScript SDK for Integration.app",

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

@@ -177,2 +177,8 @@ import {

it('should extract locators if root is array', () => {
expect(transformToDataLocator('$[5]')).toEqual([
new DataLocatorArrayItem(5),
])
})
it('should extract locators from string locator with $current', () => {

@@ -218,3 +224,14 @@ expect(transformToDataLocator('$.$current.name')).toEqual([

})
it('should extract locators from nested arrays with nested anyOf locator', () => {
expect(transformToDataLocator('$.field<10>[0]<5>[3].subfield')).toEqual([
new DataLocatorObjectProperty('field'),
new DataLocatorAnyOfOption(10),
new DataLocatorArrayItem(0),
new DataLocatorAnyOfOption(5),
new DataLocatorArrayItem(3),
new DataLocatorObjectProperty('subfield'),
])
})
})
})

@@ -125,41 +125,43 @@ import _ from 'lodash'

if (typeof sourceLocator !== 'string') return sourceLocator
if (sourceLocator === '$') return []
// TODO: add validation for string data locator
const locators = []
// skip $ because it's not used for locator
const parts = sourceLocator.split('.').slice(1)
_.each(parts, (p) => {
if (p === '$current') {
locators.push(new DataLocatorCurrentArrayItem())
return
}
// used to remove <N> and [N] from object property name
const lowestOpeningIndex = _.min(
_.filter([p.indexOf('<'), p.indexOf('[')], (e) => e > 0),
)
locators.push(
new DataLocatorObjectProperty(
lowestOpeningIndex ? p.slice(0, lowestOpeningIndex) : p,
),
)
if (p.indexOf('<') > -1) {
const openingIndex = p.indexOf('<')
const closingIndex = p.indexOf('>', openingIndex)
const anyOfIndex = +p.slice(openingIndex + 1, closingIndex)
let cursorPosition = 1
while (cursorPosition < sourceLocator.length) {
if (sourceLocator[cursorPosition] === '.') {
const closingIndex = _.min(
_.filter(
[
sourceLocator.indexOf('[', cursorPosition + 1),
sourceLocator.indexOf('<', cursorPosition + 1),
sourceLocator.indexOf('.', cursorPosition + 1),
sourceLocator.length,
],
(n) => n > -1,
),
)
const part = sourceLocator.slice(cursorPosition + 1, closingIndex)
locators.push(
part === '$current'
? new DataLocatorCurrentArrayItem()
: new DataLocatorObjectProperty(part),
)
cursorPosition = closingIndex
} else if (sourceLocator[cursorPosition] === '[') {
const closingIndex = sourceLocator.indexOf(']', cursorPosition)
const arrayIndex = +sourceLocator.slice(cursorPosition + 1, closingIndex)
locators.push(new DataLocatorArrayItem(arrayIndex))
cursorPosition = closingIndex + 1
} else if (sourceLocator[cursorPosition] === '<') {
const closingIndex = sourceLocator.indexOf('>', cursorPosition)
const anyOfIndex = +sourceLocator.slice(cursorPosition + 1, closingIndex)
locators.push(new DataLocatorAnyOfOption(anyOfIndex))
cursorPosition = closingIndex + 1
}
}
let indexCursor = 0
while (p.indexOf('[', indexCursor) > -1) {
const openingIndex = p.indexOf('[', indexCursor)
const closingIndex = p.indexOf(']', openingIndex)
indexCursor = closingIndex
const arrayIndex = +p.slice(openingIndex + 1, closingIndex)
locators.push(new DataLocatorArrayItem(arrayIndex))
}
})
return locators

@@ -166,0 +168,0 @@ }

@@ -174,2 +174,8 @@ // TODO: define error types and use them for temp and perm errors

export class ConnectionNotFoundError extends NotFoundError {
constructor(message, public connectionId?: string) {
super(message)
}
}
export class NotAuthenticatedError extends InputError {

@@ -176,0 +182,0 @@ constructor(message) {

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