@jupiterone/cli 17.6.1 → 18.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupiterone/cli",
3
- "version": "17.6.1",
3
+ "version": "18.0.0",
4
4
  "description": "The JupiterOne cli",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "test": "jest"
25
25
  },
26
26
  "dependencies": {
27
- "@jupiterone/integration-sdk-core": "^17.6.1",
28
- "@jupiterone/integration-sdk-runtime": "^17.6.1",
27
+ "@jupiterone/integration-sdk-core": "^18.0.0",
28
+ "@jupiterone/integration-sdk-runtime": "^18.0.0",
29
29
  "@lifeomic/attempt": "^3.0.3",
30
30
  "commander": "^5.0.0",
31
31
  "globby": "^11.0.1",
@@ -42,5 +42,5 @@
42
42
  "csvtojson": "^2.0.10",
43
43
  "memfs": "^3.2.0"
44
44
  },
45
- "gitHead": "adf843732aa9016847bc9041a23b9c8f97846267"
45
+ "gitHead": "4613afc276f1cbbe2a164c61959e3cb15bc1582c"
46
46
  }
@@ -1,4 +1,3 @@
1
- import axios from 'axios';
2
1
  import * as runtime from '@jupiterone/integration-sdk-runtime';
3
2
  import { createCli } from '..';
4
3
  import { TEST_API_KEY, TEST_ACCOUNT } from './utils';
@@ -7,7 +6,6 @@ import { vol } from 'memfs';
7
6
  import { createEntity, createRelationship } from '../export/__tests__/utils';
8
7
 
9
8
  jest.mock('@jupiterone/integration-sdk-runtime');
10
- jest.mock('axios');
11
9
  jest.mock('fs');
12
10
  jest.mock('../log');
13
11
 
@@ -22,11 +20,13 @@ jest.mock('ora', () => {
22
20
  };
23
21
  });
24
22
 
25
- const mockedAxios = jest.mocked(axios);
23
+ const mockedAxios = { get: jest.fn(), post: jest.fn() };
26
24
  const mockedCreateApiClient = jest.mocked(runtime.createApiClient);
27
25
 
28
26
  beforeEach(() => {
29
- mockedCreateApiClient.mockReturnValue(axios);
27
+ mockedCreateApiClient.mockReturnValue(
28
+ mockedAxios as unknown as runtime.ApiClient,
29
+ );
30
30
  mockedAxios.get.mockReset();
31
31
  delete process.env.JUPITERONE_API_KEY;
32
32
  jest.clearAllMocks();
@@ -1,5 +1,4 @@
1
1
  import * as runtime from '@jupiterone/integration-sdk-runtime';
2
- import axios from 'axios';
3
2
  import { vol } from 'memfs';
4
3
  import { randomUUID as uuid } from 'crypto';
5
4
  import globby from 'globby';
@@ -18,7 +17,6 @@ import * as log from '../log';
18
17
  import { createCli } from '..';
19
18
 
20
19
  jest.mock('@jupiterone/integration-sdk-runtime');
21
- jest.mock('axios');
22
20
  jest.mock('fs');
23
21
  jest.mock('globby');
24
22
  jest.mock('../pause');
@@ -36,7 +34,7 @@ jest.mock('ora', () => {
36
34
  });
37
35
 
38
36
  const mockedCreateApiClient = jest.mocked(runtime.createApiClient);
39
- const mockedAxios = jest.mocked(axios);
37
+ const mockedAxios = { get: jest.fn(), post: jest.fn() };
40
38
  const mockedGlobby = jest.mocked(globby);
41
39
 
42
40
  const type1Entities = [
@@ -67,7 +65,9 @@ const type1Relationships = [
67
65
  ];
68
66
 
69
67
  beforeEach(async () => {
70
- mockedCreateApiClient.mockReturnValue(axios);
68
+ mockedCreateApiClient.mockReturnValue(
69
+ mockedAxios as unknown as runtime.ApiClient,
70
+ );
71
71
  vol.reset();
72
72
  vol.fromJSON({
73
73
  [`${TEST_STORAGE_LOCATION}/csv/entities/entity_type_1/${uuid()}.csv`]:
@@ -1,5 +1,4 @@
1
1
  import * as runtime from '@jupiterone/integration-sdk-runtime';
2
- import axios, { AxiosInstance } from 'axios';
3
2
  import { randomUUID as uuid } from 'crypto';
4
3
 
5
4
  import * as fileSystem from '../../fileSystem';
@@ -12,12 +11,11 @@ import { DEFAULT_EXPORT_DIRECTORY } from '../../commands';
12
11
  import { Entity } from '@jupiterone/integration-sdk-core';
13
12
  import { TEST_API_KEY, TEST_ACCOUNT } from '../../__tests__/utils';
14
13
 
15
- jest.mock('axios');
16
14
  jest.mock('@jupiterone/integration-sdk-runtime');
17
15
  jest.mock('../../fileSystem');
18
16
 
19
17
  const mockedRuntime = jest.mocked(runtime);
20
- const mockedAxios = jest.mocked<AxiosInstance>(axios);
18
+ const mockedAxios = { get: jest.fn(), post: jest.fn() };
21
19
  const mockedFileSystem = jest.mocked(fileSystem);
22
20
 
23
21
  const options: BulkDownloadParams = {
@@ -42,7 +40,11 @@ function createEntity(id: string, type: string): Entity {
42
40
  }
43
41
 
44
42
  beforeEach(() => {
45
- mockedRuntime.createApiClient.mockReturnValue(axios);
43
+ mockedRuntime.createApiClient.mockReturnValue(
44
+ mockedAxios as unknown as runtime.ApiClient,
45
+ );
46
+ mockedAxios.get.mockReset();
47
+ mockedAxios.post.mockReset();
46
48
  });
47
49
 
48
50
  test('should write assets to json file', async () => {
@@ -5,7 +5,6 @@ import { groupJsonAssetsByType } from '../groupJsonAssetsByType';
5
5
  import { TEST_STORAGE_LOCATION } from '../../__tests__/utils';
6
6
  import { writeAssetsToCsv } from '../writeAssetsToCsv';
7
7
  import { createEntity } from './utils/createEntity';
8
- import { sanitizeContent } from '../util';
9
8
 
10
9
  jest.mock('fs');
11
10
 
@@ -1,15 +1,14 @@
1
1
  import globby from 'globby';
2
2
  import upath from 'upath';
3
3
  import createSpinner from 'ora';
4
- import type { Alpha } from '@lifeomic/alpha';
5
4
  import path from 'path';
6
5
  import pMap from 'p-map';
7
- import { retry } from '@lifeomic/attempt';
8
6
 
9
7
  import * as log from '../log';
10
8
  import { ImportAssetsParams } from './importAssets';
11
9
  import { readFileFromPath, getCsvAssetsDirectory } from '../fileSystem';
12
10
  import {
11
+ ApiClient,
13
12
  createApiClient,
14
13
  getApiBaseUrl,
15
14
  } from '@jupiterone/integration-sdk-runtime';
@@ -33,7 +32,7 @@ async function waitForSyncCompletion({ jobId, apiClient, progress }) {
33
32
 
34
33
  interface ImportAssetsTypeParams {
35
34
  storageDirectory: string;
36
- apiClient: Alpha;
35
+ apiClient: ApiClient;
37
36
  jobId: string;
38
37
  assetType: 'entities' | 'relationships';
39
38
  progress: (currentFile: string) => void;
@@ -56,18 +55,15 @@ async function importAssetTypeFromCsv({
56
55
  async (assetFile) => {
57
56
  const assets = sanitizeContent(await readFileFromPath(assetFile));
58
57
  try {
59
- await retry(
60
- () =>
61
- apiClient.post(
62
- `/persister/synchronization/jobs/${jobId}/${assetType}?ignoreDuplicates=true&ignoreIllegalProperties=true`,
63
- assets,
64
- {
65
- headers: {
66
- 'Content-Type': 'text/csv',
67
- },
68
- },
69
- ),
70
- { delay: 500 },
58
+ // Retry/backoff is handled by the api client's built-in retry.
59
+ await apiClient.post(
60
+ `/persister/synchronization/jobs/${jobId}/${assetType}?ignoreDuplicates=true&ignoreIllegalProperties=true`,
61
+ assets,
62
+ {
63
+ headers: {
64
+ 'Content-Type': 'text/csv',
65
+ },
66
+ },
71
67
  );
72
68
  } catch (e) {
73
69
  if (e?.response?.data.error) {