@jupiterone/integration-sdk-cli 11.0.3 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/generate-ingestion-sources-config.js +10 -3
- package/dist/src/commands/generate-ingestion-sources-config.js.map +1 -1
- package/dist/src/commands/generate-integration-graph-schema.js +10 -3
- package/dist/src/commands/generate-integration-graph-schema.js.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +13 -1
- package/dist/src/config.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/__tests__/util/synchronization.ts +17 -4
- package/src/commands/generate-ingestion-sources-config.ts +13 -4
- package/src/commands/generate-integration-graph-schema.ts +13 -4
- package/src/config.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupiterone/integration-sdk-cli",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "The SDK for developing JupiterOne integrations",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@jupiterone/data-model": "^0.54.0",
|
|
28
|
-
"@jupiterone/integration-sdk-core": "^11.0
|
|
29
|
-
"@jupiterone/integration-sdk-runtime": "^11.0
|
|
28
|
+
"@jupiterone/integration-sdk-core": "^11.2.0",
|
|
29
|
+
"@jupiterone/integration-sdk-runtime": "^11.2.0",
|
|
30
30
|
"chalk": "^4",
|
|
31
31
|
"commander": "^9.4.0",
|
|
32
32
|
"fs-extra": "^10.1.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"url-exists": "^1.0.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@jupiterone/integration-sdk-private-test-utils": "^11.0
|
|
46
|
+
"@jupiterone/integration-sdk-private-test-utils": "^11.2.0",
|
|
47
47
|
"@pollyjs/adapter-node-http": "^6.0.5",
|
|
48
48
|
"@pollyjs/core": "^6.0.5",
|
|
49
49
|
"@pollyjs/persister-fs": "^6.0.5",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"neo-forgery": "^2.0.0",
|
|
57
57
|
"vis": "^4.21.0-EOL"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "c671c76b03696bcddb6f0a217b92916c602a6df2"
|
|
60
60
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
SynchronizationJob,
|
|
4
4
|
SynchronizationJobStatus,
|
|
5
5
|
} from '@jupiterone/integration-sdk-core';
|
|
6
|
+
import { gunzipSync } from 'zlib';
|
|
6
7
|
|
|
7
8
|
interface SetupOptions {
|
|
8
9
|
baseUrl: string;
|
|
@@ -37,7 +38,13 @@ export function setupSynchronizerApi({
|
|
|
37
38
|
.post(`${baseUrl}/persister/synchronization/jobs/${job.id}/entities`)
|
|
38
39
|
.intercept((req, res) => {
|
|
39
40
|
allowCrossOrigin(req, res);
|
|
40
|
-
|
|
41
|
+
if (req.hasHeader('Content-Encoding')) {
|
|
42
|
+
const result = gunzipSync(Buffer.from(req.body!));
|
|
43
|
+
const data = JSON.parse(result.toString());
|
|
44
|
+
job.numEntitiesUploaded += data.entities.length;
|
|
45
|
+
} else {
|
|
46
|
+
job.numEntitiesUploaded += JSON.parse(req.body!).entities.length;
|
|
47
|
+
}
|
|
41
48
|
res.status(200).json({ job });
|
|
42
49
|
});
|
|
43
50
|
|
|
@@ -52,9 +59,15 @@ export function setupSynchronizerApi({
|
|
|
52
59
|
.post(`${baseUrl}/persister/synchronization/jobs/${job.id}/relationships`)
|
|
53
60
|
.intercept((req, res) => {
|
|
54
61
|
allowCrossOrigin(req, res);
|
|
55
|
-
|
|
56
|
-
req.body
|
|
57
|
-
|
|
62
|
+
if (req.hasHeader('Content-Encoding')) {
|
|
63
|
+
const result = gunzipSync(Buffer.from(req.body!));
|
|
64
|
+
const data = JSON.parse(result.toString());
|
|
65
|
+
job.numRelationshipsUploaded += data.relationships.length;
|
|
66
|
+
} else {
|
|
67
|
+
job.numRelationshipsUploaded += JSON.parse(
|
|
68
|
+
req.body!,
|
|
69
|
+
).relationships.length;
|
|
70
|
+
}
|
|
58
71
|
res.status(200).json({ job });
|
|
59
72
|
});
|
|
60
73
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
StepMetadata,
|
|
8
8
|
} from '@jupiterone/integration-sdk-core';
|
|
9
9
|
import { createCommand } from 'commander';
|
|
10
|
-
import { loadConfigFromTarget } from '../config';
|
|
10
|
+
import { loadConfigFromModule, loadConfigFromTarget } from '../config';
|
|
11
11
|
import { promises as fs } from 'fs';
|
|
12
12
|
import * as log from '../log';
|
|
13
13
|
|
|
@@ -26,13 +26,22 @@ export function generateIngestionSourcesConfigCommand() {
|
|
|
26
26
|
'path to integration project directory',
|
|
27
27
|
process.cwd(),
|
|
28
28
|
)
|
|
29
|
+
.option(
|
|
30
|
+
'-m, --module-name <module>',
|
|
31
|
+
'name of modules to load (ex "@jupiterone/graph-rumble". Will load using require of package rather than filename)',
|
|
32
|
+
)
|
|
29
33
|
.action(async (options) => {
|
|
30
|
-
const { projectPath, outputFile } = options;
|
|
34
|
+
const { projectPath, outputFile, moduleName } = options;
|
|
31
35
|
|
|
32
36
|
log.info(
|
|
33
|
-
`Generating ingestion sources config (projectPath=${projectPath}, outputFile=${outputFile})`,
|
|
37
|
+
`Generating ingestion sources config (projectPath=${projectPath}, outputFile=${outputFile}, moduleName=${moduleName})`,
|
|
34
38
|
);
|
|
35
|
-
|
|
39
|
+
let config;
|
|
40
|
+
if (moduleName) {
|
|
41
|
+
config = loadConfigFromModule(moduleName);
|
|
42
|
+
} else {
|
|
43
|
+
config = await loadConfigFromTarget(projectPath);
|
|
44
|
+
}
|
|
36
45
|
if (!config.ingestionConfig) {
|
|
37
46
|
log.info(
|
|
38
47
|
'Skipping the generation of ingestion sources config file as there is no ingestionConfig present.',
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
StepRelationshipMetadata,
|
|
8
8
|
} from '@jupiterone/integration-sdk-core';
|
|
9
9
|
import { createCommand } from 'commander';
|
|
10
|
-
import { loadConfigFromTarget } from '../config';
|
|
10
|
+
import { loadConfigFromModule, loadConfigFromTarget } from '../config';
|
|
11
11
|
import { promises as fs } from 'fs';
|
|
12
12
|
import * as log from '../log';
|
|
13
13
|
|
|
@@ -26,13 +26,22 @@ export function generateIntegrationGraphSchemaCommand() {
|
|
|
26
26
|
'path to integration project directory',
|
|
27
27
|
process.cwd(),
|
|
28
28
|
)
|
|
29
|
+
.option(
|
|
30
|
+
'-m, --module-name <module>',
|
|
31
|
+
'name of modules to load (ex "@jupiterone/graph-rumble". Will load using require of package rather than filename)',
|
|
32
|
+
)
|
|
29
33
|
.action(async (options) => {
|
|
30
|
-
const { projectPath, outputFile } = options;
|
|
34
|
+
const { projectPath, outputFile, moduleName } = options;
|
|
31
35
|
|
|
32
36
|
log.info(
|
|
33
|
-
`Generating integration graph schema (projectPath=${projectPath}, outputFile=${outputFile})`,
|
|
37
|
+
`Generating integration graph schema (projectPath=${projectPath}, outputFile=${outputFile}, moduleName=${moduleName})`,
|
|
34
38
|
);
|
|
35
|
-
|
|
39
|
+
let config;
|
|
40
|
+
if (moduleName) {
|
|
41
|
+
config = loadConfigFromModule(moduleName);
|
|
42
|
+
} else {
|
|
43
|
+
config = await loadConfigFromTarget(projectPath);
|
|
44
|
+
}
|
|
36
45
|
|
|
37
46
|
const integrationGraphSchema = generateIntegrationGraphSchema(
|
|
38
47
|
config.integrationSteps,
|
package/src/config.ts
CHANGED
|
@@ -59,6 +59,21 @@ function loadConfigFromDist(projectPath: string) {
|
|
|
59
59
|
return loadConfig(path.join(projectPath, 'dist'));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
export function loadConfigFromModule(mod: string) {
|
|
63
|
+
let integrationModule: any;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
integrationModule = require(mod);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw new IntegrationInvocationConfigLoadError(
|
|
69
|
+
`Error loading integration invocation configuration. Ensure "invocationConfig" is exported from "${mod}". Additional details: ` +
|
|
70
|
+
err,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return integrationModule.invocationConfig as IntegrationInvocationConfig;
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
/**
|
|
63
78
|
* The way that integration npm packages are distributed has changed over time.
|
|
64
79
|
* This function handles different cases where the invocation config has
|