Socket
Socket
Sign inDemoInstall

@jupiterone/integration-sdk-core

Package Overview
Dependencies
Maintainers
10
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupiterone/integration-sdk-core - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

dist/src/types/metric.d.ts

44

dist/src/data/converters.d.ts

@@ -1,8 +0,30 @@

export declare function convertPropertyValue(value: string | undefined): string | number | boolean | undefined;
export declare function convertProperties(object?: any, options?: {
export declare function parseStringPropertyValue(value: string): string | boolean | number | undefined;
declare type ConvertPropertiesOptions = {
/**
* Convert `Object` properties using `JSON.stringify(value)`. Without this
* option, `Object` properties are not transferred.
*/
stringifyObject?: boolean;
/**
* Convert `Array` properties using `JSON.stringify(value)`. Without this
* option, `Array` properties are not transferred.
*/
stringifyArray?: boolean;
/**
* Parse primitive properties (string, boolean, number). Without this
* option, values are transferred as-is.
*/
parseString?: boolean;
/**
* Parse properties that are named with date/time-like suffixes into number of
* milliseconds since epoch (UNIX timestamp).
*/
parseTime?: boolean;
/**
* Prefix property names as `<prefix>.<property>` when transferring to the
* converted object.
*/
prefix?: string;
}): any;
};
export declare function convertProperties(object?: any, options?: ConvertPropertiesOptions): any;
interface NameValuePair {

@@ -18,6 +40,16 @@ name?: string;

}): any;
export declare function getTime(time: Date | string | number | undefined): number | undefined;
/**
* @description calculates the base64 sha256 hash of the
* stringified object
* @deprecated
* @see parseTimePropertyValue
*/
export declare function getTime(time: Date | string | number | undefined | null): number | undefined;
/**
* Produces a time value in milliseconds since epoch (UNIX timestamp) using `new
* Date(time).getTime()`.
*
* @param time a time value
*/
export declare function parseTimePropertyValue(time: Date | string | number | undefined | null): number | undefined;
/**
* @description calculates the base64 sha256 hash of the stringified object
* @param object object to hash stringified version of

@@ -24,0 +56,0 @@ */

66

dist/src/data/converters.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.sha256 = exports.getTime = exports.convertNameValuePairs = exports.convertProperties = exports.convertPropertyValue = void 0;
exports.sha256 = exports.parseTimePropertyValue = exports.getTime = exports.convertNameValuePairs = exports.convertProperties = exports.parseStringPropertyValue = void 0;
const crypto_1 = require("crypto");

@@ -14,5 +14,5 @@ const camelCase_1 = __importDefault(require("lodash/camelCase"));

const FLOAT_NUMBER_REGEX = /^\d+\.\d+$/;
function convertPropertyValue(value) {
function parseStringPropertyValue(value) {
if (!value) {
return value;
return undefined;
}

@@ -33,7 +33,14 @@ if (TRUE_REGEX.test(value)) {

}
exports.convertPropertyValue = convertPropertyValue;
exports.parseStringPropertyValue = parseStringPropertyValue;
const TIME_PROPERTY_NAMES = /^\w+((T|_t)ime|(O|_o)n|(A|_a)t|(D|_d)ate)$/;
function isTimeProperty(property) {
return TIME_PROPERTY_NAMES.test(property);
}
function convertProperties(object = {}, options = {}) {
const supportedTypes = ['string', 'boolean', 'number'];
const flattenedObject = {};
const converted = {};
for (const [key, value] of Object.entries(object)) {
if (value == null) {
continue;
}
const newKey = options.prefix && options.prefix.length > 0

@@ -43,8 +50,15 @@ ? `${options.prefix}.${camelCase_1.default(key)}`

if (typeof value === 'boolean' || typeof value === 'number') {
flattenedObject[newKey] = value;
converted[newKey] = value;
}
else if (typeof value === 'string') {
flattenedObject[newKey] = options.parseString
? convertPropertyValue(value)
: value;
if (options.parseString) {
converted[newKey] = parseStringPropertyValue(value);
}
else if (options.parseTime && isTimeProperty(key)) {
const time = parseTimePropertyValue(value);
converted[newKey] = time ? time : value;
}
else {
converted[newKey] = value;
}
}

@@ -57,3 +71,3 @@ else if (Array.isArray(value)) {

if (options.stringifyArray) {
flattenedObject[newKey] = JSON.stringify(value);
converted[newKey] = JSON.stringify(value);
}

@@ -71,3 +85,3 @@ else {

if (items.length > 0) {
flattenedObject[newKey] = items;
converted[newKey] = items;
}

@@ -78,6 +92,6 @@ }

else if (options.stringifyObject) {
flattenedObject[newKey] = JSON.stringify(value);
converted[newKey] = JSON.stringify(value);
}
}
return flattenedObject;
return converted;
}

@@ -94,3 +108,3 @@ exports.convertProperties = convertProperties;

: camelCase_1.default(n);
const value = options.parseString ? convertPropertyValue(v) : v;
const value = options.parseString ? parseStringPropertyValue(v) : v;
obj[key] = value;

@@ -102,9 +116,27 @@ }

exports.convertNameValuePairs = convertNameValuePairs;
/**
* @deprecated
* @see parseTimePropertyValue
*/
function getTime(time) {
return time ? new Date(time).getTime() : undefined;
return parseTimePropertyValue(time);
}
exports.getTime = getTime;
/**
* @description calculates the base64 sha256 hash of the
* stringified object
* Produces a time value in milliseconds since epoch (UNIX timestamp) using `new
* Date(time).getTime()`.
*
* @param time a time value
*/
function parseTimePropertyValue(time) {
if (time) {
const parsed = new Date(time).getTime();
if (!isNaN(parsed)) {
return parsed;
}
}
}
exports.parseTimePropertyValue = parseTimePropertyValue;
/**
* @description calculates the base64 sha256 hash of the stringified object
* @param object object to hash stringified version of

@@ -111,0 +143,0 @@ */

@@ -69,3 +69,3 @@ "use strict";

}
entity[`tag.${key}`] = converters_1.convertPropertyValue(value);
entity[`tag.${key}`] = converters_1.parseStringPropertyValue(value);
const lowerKey = key.toLowerCase();

@@ -72,0 +72,0 @@ if (lowerKey === 'name' && value) {

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

export * from './apiClient';
export * from './config';

@@ -11,4 +10,5 @@ export * from './context';

export * from './synchronization';
export * from './metric';
export * from './persistedObject';
export * from './entity';
export * from './relationship';

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

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./apiClient"), exports);
__exportStar(require("./config"), exports);

@@ -24,2 +23,3 @@ __exportStar(require("./context"), exports);

__exportStar(require("./synchronization"), exports);
__exportStar(require("./metric"), exports);
__exportStar(require("./persistedObject"), exports);

@@ -26,0 +26,0 @@ __exportStar(require("./entity"), exports);

import { StepMetadata } from './';
import { SynchronizationJob } from './synchronization';
import { ApiClient } from './apiClient';
import { Metric } from './metric';
export interface IntegrationEvent {
name: string;
description: string;
}
interface LogFunction {

@@ -19,2 +23,3 @@ (...args: any[]): boolean | void;

};
declare type PublishMetricFunction = (metric: Omit<Metric, 'timestamp'>) => void;
declare type PublishEventFunction = (options: PublishEventInput) => void;

@@ -51,8 +56,3 @@ declare type PublishErrorEventInput = {

}
export interface LoggerSynchronizationJobContext {
apiClient: ApiClient;
job: SynchronizationJob;
}
export interface IntegrationLoggerFunctions {
registerSynchronizationJobContext: (context: LoggerSynchronizationJobContext) => IntegrationLogger;
isHandledError: IsHandledErrorFunction;

@@ -65,2 +65,3 @@ stepStart: StepLogFunction;

validationFailure: ValidationLogFunction;
publishMetric: PublishMetricFunction;
/**

@@ -74,5 +75,4 @@ * @deprecated

publishErrorEvent: PublishErrorEventFunction;
flush: () => Promise<void>;
}
export declare type IntegrationLogger = BaseLogger & IntegrationLoggerFunctions;
export {};
{
"name": "@jupiterone/integration-sdk-core",
"version": "1.1.1",
"version": "2.0.0",
"description": "The SDK for developing JupiterOne integrations",

@@ -26,3 +26,2 @@ "main": "dist/src/index.js",

"@jupiterone/data-model": "^0.6.4",
"axios": "^0.19.2",
"lodash": "^4.17.15",

@@ -34,3 +33,3 @@ "uuid": "^7.0.3"

},
"gitHead": "c7bd85ca3ba765888840810ec4e487914ed80da9"
"gitHead": "e23d77f21929829f224d4845e17b796d56df9db0"
}

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