Socket
Socket
Sign inDemoInstall

@jupiterone/integration-sdk-cli

Package Overview
Dependencies
Maintainers
1
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 3.2.1 to 3.2.2

dist/src/commands/visualize-types.d.ts

75

dist/src/commands/document.js

@@ -24,7 +24,6 @@ "use strict";

const log = __importStar(require("../log"));
const config_1 = require("../config");
const path = __importStar(require("path"));
const integration_sdk_runtime_1 = require("@jupiterone/integration-sdk-runtime");
const commander_1 = require("commander");
const fs_1 = require("fs");
const getSortedJupiterOneTypes_1 = require("../utils/getSortedJupiterOneTypes");
const table = require('markdown-table');

@@ -36,4 +35,4 @@ const J1_DOCUMENTATION_MARKER_START = '<!-- {J1_DOCUMENTATION_MARKER_START} -->';

.description('Generates documentation for all steps')
.option('-p, --project-path <directory>', 'Absolute file path to the integration project directory. Defaults to the current working directory.', process.cwd())
.option('-f, --documentation-file-path <directory>', 'Absolute file path to the Markdown file that should be created/updated. Defaults to {CWD}/docs/jupiterone.md.')
.option('-p, --project-path <directory>', 'Absolute path to the integration project directory. Defaults to the current working directory.', process.cwd())
.option('-o, --output-file <path>', 'Absolute path to the Markdown file that should be created/updated. Defaults to {CWD}/docs/jupiterone.md.')
.action(executeDocumentAction);

@@ -44,8 +43,7 @@ }

const { projectPath } = options;
const documentationFilePath = options.documentationFilePath ||
getDefaultDocumentationFilePath(projectPath);
log.info('\nBeginning documentation from steps...\n');
const config = await config_1.loadConfig(path.join(projectPath, 'src'));
log.info('\nConfiguration successfully loaded!\n');
const metadata = alphabetizeMetadataProperties(collectGraphObjectMetadataFromSteps(config.integrationSteps));
const documentationFilePath = options.outputFile || getDefaultDocumentationFilePath(projectPath);
log.info('\nCollecting metadata types from steps...\n');
const metadata = await getSortedJupiterOneTypes_1.getSortedJupiterOneTypes({
projectPath,
});
if (!metadata.entities.length && !metadata.relationships.length) {

@@ -84,9 +82,2 @@ log.info('No entities or relationships found to generate documentation for. Exiting.');

}
function integrationStepsToMap(integrationSteps) {
const integrationStepMap = new Map();
for (const step of integrationSteps) {
integrationStepMap.set(step.id, step);
}
return integrationStepMap;
}
function buildEntityClassDocumentationValue(_class) {

@@ -120,52 +111,2 @@ if (typeof _class === 'string') {

}
function alphabetizeEntityMetadataPropertyByTypeCompareFn(a, b) {
if (a.resourceName > b.resourceName)
return 1;
if (a.resourceName < b.resourceName)
return -1;
return 0;
}
function alphabetizeRelationshipMetadataPropertyByTypeCompareFn(a, b) {
if (a._type > b._type)
return 1;
if (a._type < b._type)
return -1;
return 0;
}
function alphabetizeMetadataProperties(metadata) {
return {
entities: metadata.entities.sort(alphabetizeEntityMetadataPropertyByTypeCompareFn),
relationships: metadata.relationships.sort(alphabetizeRelationshipMetadataPropertyByTypeCompareFn),
};
}
function collectGraphObjectMetadataFromSteps(steps) {
const orderedStepNames = integration_sdk_runtime_1.buildStepDependencyGraph(steps).overallOrder();
const integrationStepMap = integrationStepsToMap(steps);
const metadata = {
entities: [],
relationships: [],
};
// There could be multiple steps that ingest the same entity/relationship
// `_type`, so we need to deduplicate the data.
const entityTypeSet = new Set();
const relationshipTypeSet = new Set();
for (const stepName of orderedStepNames) {
const step = integrationStepMap.get(stepName);
for (const e of step.entities) {
if (entityTypeSet.has(e._type)) {
continue;
}
entityTypeSet.add(e._type);
metadata.entities.push(e);
}
for (const r of step.relationships) {
if (relationshipTypeSet.has(r._type)) {
continue;
}
relationshipTypeSet.add(r._type);
metadata.relationships.push(r);
}
}
return metadata;
}
function generateGraphObjectDocumentationFromStepsMetadata(metadata) {

@@ -172,0 +113,0 @@ let entitySection = '';

@@ -6,1 +6,2 @@ export * from './collect';

export * from './document';
export * from './visualize-types';

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

__exportStar(require("./document"), exports);
__exportStar(require("./visualize-types"), exports);
//# sourceMappingURL=index.js.map

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

.addCommand(commands_1.run())
.addCommand(commands_1.visualizeTypes())
.addCommand(commands_1.document());

@@ -14,0 +15,0 @@ }

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

const retrieveIntegrationData_1 = require("./retrieveIntegrationData");
const generateVisHTML_1 = require("./generateVisHTML");
const generateVisHTML_1 = require("../utils/generateVisHTML");
const globby_1 = __importDefault(require("globby"));

@@ -32,0 +32,0 @@ const upath_1 = __importDefault(require("upath"));

{
"name": "@jupiterone/integration-sdk-cli",
"version": "3.2.1",
"version": "3.2.2",
"description": "The SDK for developing JupiterOne integrations",

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

"dependencies": {
"@jupiterone/integration-sdk-runtime": "^3.2.1",
"@jupiterone/integration-sdk-runtime": "^3.2.2",
"commander": "^5.0.0",

@@ -35,3 +35,3 @@ "globby": "^11.0.0",

"devDependencies": {
"@jupiterone/integration-sdk-private-test-utils": "^3.2.1",
"@jupiterone/integration-sdk-private-test-utils": "^3.2.2",
"@pollyjs/adapter-node-http": "^4.0.4",

@@ -49,3 +49,3 @@ "@pollyjs/core": "^4.0.4",

},
"gitHead": "880cc901d70a1afa14ccadd52cd371a55ce9810d"
"gitHead": "1b7af1e12957e47d52795791b25cd246aa34af8a"
}

@@ -387,3 +387,3 @@ import path from 'path';

'document',
'-f',
'-o',
customDocumentationFilePath,

@@ -390,0 +390,0 @@ ]);

import * as log from '../log';
import { loadConfig } from '../config';
import * as path from 'path';
import { buildStepDependencyGraph } from '@jupiterone/integration-sdk-runtime';
import { createCommand } from 'commander';
import {
IntegrationStepExecutionContext,
Step,
StepGraphObjectMetadataProperties,

@@ -14,2 +10,6 @@ StepEntityMetadata,

import { promises as fs } from 'fs';
import {
getSortedJupiterOneTypes,
TypesCommandArgs,
} from '../utils/getSortedJupiterOneTypes';

@@ -22,5 +22,4 @@ const table = require('markdown-table');

interface DocumentCommandArgs {
projectPath: string;
documentationFilePath: string;
interface DocumentCommandArgs extends TypesCommandArgs {
outputFile: string;
}

@@ -33,8 +32,8 @@

'-p, --project-path <directory>',
'Absolute file path to the integration project directory. Defaults to the current working directory.',
'Absolute path to the integration project directory. Defaults to the current working directory.',
process.cwd(),
)
.option(
'-f, --documentation-file-path <directory>',
'Absolute file path to the Markdown file that should be created/updated. Defaults to {CWD}/docs/jupiterone.md.',
'-o, --output-file <path>',
'Absolute path to the Markdown file that should be created/updated. Defaults to {CWD}/docs/jupiterone.md.',
)

@@ -49,14 +48,9 @@ .action(executeDocumentAction);

const documentationFilePath =
options.documentationFilePath ||
getDefaultDocumentationFilePath(projectPath);
options.outputFile || getDefaultDocumentationFilePath(projectPath);
log.info('\nBeginning documentation from steps...\n');
const config = await loadConfig(path.join(projectPath, 'src'));
log.info('\nCollecting metadata types from steps...\n');
const metadata = await getSortedJupiterOneTypes({
projectPath,
});
log.info('\nConfiguration successfully loaded!\n');
const metadata = alphabetizeMetadataProperties(
collectGraphObjectMetadataFromSteps(config.integrationSteps),
);
if (!metadata.entities.length && !metadata.relationships.length) {

@@ -121,17 +115,2 @@ log.info(

function integrationStepsToMap(
integrationSteps: Step<IntegrationStepExecutionContext<object>>[],
): Map<string, Step<IntegrationStepExecutionContext<object>>> {
const integrationStepMap = new Map<
string,
Step<IntegrationStepExecutionContext<object>>
>();
for (const step of integrationSteps) {
integrationStepMap.set(step.id, step);
}
return integrationStepMap;
}
function buildEntityClassDocumentationValue(_class: string | string[]): string {

@@ -175,76 +154,2 @@ if (typeof _class === 'string') {

function alphabetizeEntityMetadataPropertyByTypeCompareFn(
a: StepEntityMetadata,
b: StepEntityMetadata,
): number {
if (a.resourceName > b.resourceName) return 1;
if (a.resourceName < b.resourceName) return -1;
return 0;
}
function alphabetizeRelationshipMetadataPropertyByTypeCompareFn(
a: StepRelationshipMetadata,
b: StepRelationshipMetadata,
): number {
if (a._type > b._type) return 1;
if (a._type < b._type) return -1;
return 0;
}
function alphabetizeMetadataProperties(
metadata: StepGraphObjectMetadataProperties,
): StepGraphObjectMetadataProperties {
return {
entities: metadata.entities.sort(
alphabetizeEntityMetadataPropertyByTypeCompareFn,
),
relationships: metadata.relationships.sort(
alphabetizeRelationshipMetadataPropertyByTypeCompareFn,
),
};
}
function collectGraphObjectMetadataFromSteps(
steps: Step<IntegrationStepExecutionContext<object>>[],
): StepGraphObjectMetadataProperties {
const orderedStepNames = buildStepDependencyGraph(steps).overallOrder();
const integrationStepMap = integrationStepsToMap(steps);
const metadata: StepGraphObjectMetadataProperties = {
entities: [],
relationships: [],
};
// There could be multiple steps that ingest the same entity/relationship
// `_type`, so we need to deduplicate the data.
const entityTypeSet = new Set<string>();
const relationshipTypeSet = new Set<string>();
for (const stepName of orderedStepNames) {
const step = integrationStepMap.get(stepName) as Step<
IntegrationStepExecutionContext<object>
>;
for (const e of step.entities) {
if (entityTypeSet.has(e._type)) {
continue;
}
entityTypeSet.add(e._type);
metadata.entities.push(e);
}
for (const r of step.relationships) {
if (relationshipTypeSet.has(r._type)) {
continue;
}
relationshipTypeSet.add(r._type);
metadata.relationships.push(r);
}
}
return metadata;
}
function generateGraphObjectDocumentationFromStepsMetadata(

@@ -251,0 +156,0 @@ metadata: StepGraphObjectMetadataProperties,

@@ -6,1 +6,2 @@ export * from './collect';

export * from './document';
export * from './visualize-types';
import { createCommand } from 'commander';
import { collect, visualize, sync, run, document } from './commands';
import {
collect,
visualize,
sync,
run,
document,
visualizeTypes,
} from './commands';

@@ -11,3 +18,4 @@ export function createCli() {

.addCommand(run())
.addCommand(visualizeTypes())
.addCommand(document());
}

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

import { generateVisHTML, nothingToDisplayMessage } from '../generateVisHTML';
import { generateVisHTML, nothingToDisplayMessage } from '../../utils/generateVisHTML';
import { Node, Edge } from 'vis';

@@ -3,0 +3,0 @@

@@ -15,3 +15,3 @@ import path from 'path';

import { nothingToDisplayMessage } from '../generateVisHTML';
import { nothingToDisplayMessage } from '../../utils/generateVisHTML';
import { generateVisualization } from '../generateVisualization';

@@ -18,0 +18,0 @@

@@ -5,3 +5,3 @@ import path from 'path';

import { retrieveIntegrationData } from './retrieveIntegrationData';
import { generateVisHTML } from './generateVisHTML';
import { generateVisHTML } from '../utils/generateVisHTML';
import { Edge } from 'vis';

@@ -8,0 +8,0 @@ import globby from 'globby';

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