Skip to content

Commit 3b3ff27

Browse files
author
Marco Franceschi
committed
chore: Updated SDK to latest version
1 parent 96915f3 commit 3b3ff27

7 files changed

Lines changed: 18 additions & 80 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"terraform:cleanup": "rimraf ./tests/terraform/{.terraform,.terraform.lock.hcl,tfplan} ./tests/terraform/*.{tfstate,tfplan,backup}"
3333
},
3434
"dependencies": {
35-
"@cloudgraph/sdk": "0.10.7",
35+
"@cloudgraph/sdk": "0.14.2",
3636
"@fast-csv/parse": "^4.3.6",
3737
"@graphql-tools/load-files": "6.3.2",
3838
"@graphql-tools/merge": "8.0.1",

src/services/account/schema.graphql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ type awsAccount @key(fields: "id") {
88
appSync: [awsAppSync]
99
asgs: [awsAsg]
1010
athenaDataCatalogs: [awsAthenaDataCatalog]
11-
1211
billing: [awsBilling]
1312
clientVpnEndpoint: [awsClientVpnEndpoint]
1413
cloud9Environments: [awsCloud9Environment]

src/services/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import CloudGraph, { Service, Opts, ProviderData } from '@cloudgraph/sdk'
1+
import CloudGraph, {
2+
Service,
3+
Opts,
4+
ProviderData,
5+
sortResourcesDependencies,
6+
} from '@cloudgraph/sdk'
27
import { loadFilesSync } from '@graphql-tools/load-files'
38
import { mergeTypeDefs } from '@graphql-tools/merge'
49
import AWS, { Config } from 'aws-sdk'
@@ -13,9 +18,10 @@ import resources from '../enums/resources'
1318
import services from '../enums/services'
1419
import serviceMap from '../enums/serviceMap'
1520
import schemasMap from '../enums/schemasMap'
21+
import relations from '../enums/relations'
1622
import { Credentials } from '../types'
1723
import { obfuscateSensitiveString } from '../utils/format'
18-
import { checkAndMergeConnections, sortResourcesDependencies } from '../utils'
24+
import { checkAndMergeConnections } from '../utils'
1925
import { Account, rawDataInterface } from './base'
2026
import enhancers, { EnhancerConfig } from './base/enhancers'
2127

@@ -557,7 +563,7 @@ export default class Provider extends CloudGraph.Client {
557563
if (!configuredResources) {
558564
configuredResources = Object.values(this.properties.services).join(',')
559565
}
560-
const resourceNames: string[] = sortResourcesDependencies([
566+
const resourceNames: string[] = sortResourcesDependencies(relations, [
561567
...new Set<string>(configuredResources.split(',')),
562568
])
563569

src/services/securityGroup/format.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { toCamel } from '@cloudgraph/sdk'
12
import cuid from 'cuid'
3+
24
import t from '../../properties/translations'
35
import { AwsSecurityGroup } from './data'
46
import { AwsSecurityGroup as AwsSgType } from '../../types/generated'
5-
import { toCamel } from '../../utils'
67
import { formatTagsFromMap } from '../../utils/format'
78
import { securityGroupArn } from '../../utils/generateArns'
89

src/services/vpc/connections.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ServiceConnection } from '@cloudgraph/sdk'
1+
import { intersectStringArrays, ServiceConnection } from '@cloudgraph/sdk'
22

33
import {
44
Address,
@@ -18,7 +18,6 @@ import { FunctionConfiguration } from 'aws-sdk/clients/lambda'
1818
// import { LoadBalancerDescription } from 'aws-sdk/clients/elb' // TODO: Uncomment when adding ELB
1919

2020
import services from '../../enums/services'
21-
import { intersectStringArrays } from '../../utils/index'
2221
import { RawAwsSubnet } from '../subnet/data'
2322
import { RawFlowLog } from '../flowLogs/data'
2423
import { RawAwsEcsService } from '../ecsService/data'

src/utils/index.ts

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,19 @@ import AWS, { ConfigurationOptions } from 'aws-sdk'
22
import { APIVersions } from 'aws-sdk/lib/config'
33
import CloudGraph, { Opts } from '@cloudgraph/sdk'
44
import STS from 'aws-sdk/clients/sts'
5-
import camelCase from 'lodash/camelCase'
65
import isEmpty from 'lodash/isEmpty'
76
import isEqual from 'lodash/isEqual'
87
import unionWith from 'lodash/unionWith'
8+
99
import environment from '../config/environment'
1010
import { Credentials } from '../types'
1111
import {
1212
BASE_CUSTOM_RETRY_DELAY,
1313
MAX_FAILED_AWS_REQUEST_RETRIES,
1414
} from '../config/constants'
15-
import relations from '../enums/relations'
16-
17-
1815

1916
const { logger } = CloudGraph
2017

21-
export const toCamel = (o: any): any => {
22-
let origKey
23-
let newKey
24-
let value
25-
26-
if (o instanceof Array) {
27-
return o.map(value => {
28-
if (typeof value === 'object') {
29-
value = toCamel(value)
30-
}
31-
return value
32-
})
33-
}
34-
35-
const newObject = {}
36-
for (origKey in o) {
37-
if (o.hasOwnProperty(origKey)) {
38-
newKey = camelCase(origKey)
39-
value = o[origKey]
40-
if (
41-
value instanceof Array ||
42-
(value !== null && value !== undefined && value.constructor === Object)
43-
) {
44-
value = toCamel(value)
45-
}
46-
newObject[newKey] = value
47-
}
48-
}
49-
50-
return newObject
51-
}
52-
53-
export const getKeyByValue = (
54-
object: Record<string, unknown>,
55-
value: any
56-
): string | undefined => {
57-
return Object.keys(object).find(key => object[key] === value)
58-
}
59-
60-
export const intersectStringArrays = (
61-
a: Array<string>,
62-
b: Array<string>
63-
): Array<string> => {
64-
const setA = new Set(a)
65-
const setB = new Set(b)
66-
const intersection = new Set([...setA].filter(x => setB.has(x)))
67-
return Array.from(intersection)
68-
}
69-
7018
export async function getAccountId({
7119
credentials,
7220
}: // opts,
@@ -160,21 +108,6 @@ export const settleAllPromises = async (
160108
i => (i as PromiseFulfilledResult<any>).value
161109
)
162110

163-
/**
164-
* Sorts a services list depending on his dependencies
165-
* @param resourceNames services to sort
166-
* @returns sorted list of services
167-
*/
168-
export const sortResourcesDependencies = (resourceNames: string[]): string[] =>
169-
resourceNames.sort((prevResource, nextResource) => {
170-
const dependecies = relations[prevResource]
171-
172-
if (dependecies && dependecies.includes(nextResource)) {
173-
return -1
174-
}
175-
return 0
176-
})
177-
178111
export const checkAndMergeConnections = (
179112
serviceConnections: any,
180113
connectionsToMerge: any

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,10 @@
564564
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
565565
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
566566

567-
"@cloudgraph/sdk@0.10.7":
568-
version "0.10.7"
569-
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.10.7.tgz#f5454a0124c55e7684d536d51b9accc3b3446fa2"
570-
integrity sha512-gOkDj9CWFsbt5LZnsuq4zTBRBRztjkj40azOknNBvwu90jF93R91Sy8USyKTw6/rAbMhc+uA92H5JBKqOxDEVg==
567+
"@cloudgraph/sdk@0.14.2":
568+
version "0.14.2"
569+
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.14.2.tgz#0594cd7c9c1a893a259ad137400a9b29d48079b5"
570+
integrity sha512-cpPqg/vbwbhUNxWWAXXUz8ZtNyrNwXCHxU4nBiEEgHtewQV7lmVjx5OgThspPZcZjb+bsYIR+Q19euY7oGFQkQ==
571571
dependencies:
572572
"@graphql-tools/load-files" "^6.5.3"
573573
"@graphql-tools/merge" "^8.2.1"

0 commit comments

Comments
 (0)