@infrascan/shared-types 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @infrascan/shared-types
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#36](https://github.com/infrascan/infrascan/pull/36) [`f7700f1`](https://github.com/infrascan/infrascan/commit/f7700f11568e413ba2ccefc990fc683bdfdeb01d) Thanks [@lfarrel6](https://github.com/lfarrel6)! - Simplify shared-types package - remove unneeded aws client dependencies. Patch downstream packages.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrascan/shared-types",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shared types for multiple infrascan packages",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
@@ -9,24 +9,6 @@
9
9
  "keywords": [],
10
10
  "author": "Liam Farrelly <liam@l3f7.dev> (https://whoisli.am/)",
11
11
  "license": "MPL-2.0",
12
- "dependencies": {
13
- "@aws-sdk/client-apigatewayv2": "3.428.0",
14
- "@aws-sdk/client-auto-scaling": "3.428.0",
15
- "@aws-sdk/client-cloudfront": "3.428.0",
16
- "@aws-sdk/client-cloudwatch-logs": "3.428.0",
17
- "@aws-sdk/client-dynamodb": "3.428.0",
18
- "@aws-sdk/client-ec2": "3.428.0",
19
- "@aws-sdk/client-ecs": "3.428.0",
20
- "@aws-sdk/client-elastic-load-balancing-v2": "3.428.0",
21
- "@aws-sdk/client-iam": "3.428.0",
22
- "@aws-sdk/client-lambda": "3.428.0",
23
- "@aws-sdk/client-rds": "3.428.0",
24
- "@aws-sdk/client-route-53": "3.428.0",
25
- "@aws-sdk/client-s3": "3.428.0",
26
- "@aws-sdk/client-sns": "3.428.0",
27
- "@aws-sdk/client-sqs": "3.428.0",
28
- "@aws-sdk/client-sts": "3.428.0"
29
- },
30
12
  "devDependencies": {
31
13
  "@aws-sdk/types": "3.428.0",
32
14
  "eslint-config-custom": "*",
package/src/api.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { AwsCredentialIdentityProvider } from "@aws-sdk/types";
2
2
 
3
- import type { Service } from "./services";
4
- import type { BaseEdgeResolver } from "./config";
5
3
  import type { GraphEdge, GraphNode } from "./graph";
6
-
4
+ import type { BaseEdgeResolver } from "./config";
7
5
 
8
6
  /**
9
7
  * Callback to store state from a specific function call
@@ -22,7 +20,7 @@ export type ServiceScanCompleteCallbackFn = (
22
20
  /**
23
21
  * The service being scanned
24
22
  */
25
- service: Service | "IAM",
23
+ service: string,
26
24
  /**
27
25
  * The specific function called during scanning
28
26
  */
@@ -53,7 +51,7 @@ export type ResolveStateForServiceFunction = (
53
51
  /**
54
52
  * The scanned service e.g. Lambda
55
53
  */
56
- service: Service,
54
+ service: string,
57
55
  /**
58
56
  * The specific function called during the scan e.g. GetFunction
59
57
  */
@@ -70,7 +68,7 @@ export interface Connector {
70
68
  onServiceScanCompleteCallback: ServiceScanCompleteCallbackFn;
71
69
  resolveStateForServiceFunction: ResolveStateForServiceFunction;
72
70
  getGlobalStateForServiceFunction: GetGlobalStateForServiceFunction;
73
- };
71
+ }
74
72
 
75
73
  type ClientBuilder<T, P extends Provider> = (
76
74
  credentials: AwsCredentialIdentityProvider,
@@ -80,17 +78,16 @@ type ClientBuilder<T, P extends Provider> = (
80
78
  type GetterFn<T, P extends Provider> = (
81
79
  client: T,
82
80
  stateConnector: Connector,
83
- context: ProviderContextMap[P]
81
+ context: ProviderContextMap[P],
84
82
  ) => Promise<void>;
85
83
 
86
84
  type GetNodeFn<T extends Provider> = (
87
85
  stateConnector: Connector,
88
- context: ProviderContextMap[T]
86
+ context: ProviderContextMap[T],
89
87
  ) => Promise<GraphNode[]>;
90
88
 
91
89
  type GetEdgeFn = (stateConnector: Connector) => Promise<GraphEdge[]>;
92
90
 
93
-
94
91
  export type Provider = "aws";
95
92
 
96
93
  export type AwsContext = {
@@ -100,18 +97,21 @@ export type AwsContext = {
100
97
  };
101
98
 
102
99
  type ProviderContextMap = {
103
- aws: AwsContext
104
- }
100
+ aws: AwsContext;
101
+ };
105
102
 
106
103
  export type ProviderContext<T extends Provider> = {
107
104
  provider: T;
108
105
  context: ProviderContextMap[T];
109
106
  };
110
107
 
111
- type FormatNodeFn<P extends Provider> = (node: GraphNode, context: ProviderContextMap[P]) => GraphNode;
108
+ type FormatNodeFn<P extends Provider> = (
109
+ node: GraphNode,
110
+ context: ProviderContextMap[P],
111
+ ) => GraphNode;
112
112
  type FormatEdgeFn<P extends Provider> = (
113
113
  node: GraphEdge,
114
- context: ProviderContextMap[P]
114
+ context: ProviderContextMap[P],
115
115
  ) => GraphEdge;
116
116
 
117
117
  export type EntityRoleData = {
@@ -135,4 +135,4 @@ export interface ServiceModule<T, P extends Provider> {
135
135
  getEdges?: GetEdgeFn;
136
136
  formatEdge?: FormatEdgeFn<P>;
137
137
  getIamRoles?: GetIamRoleFn;
138
- };
138
+ }
package/src/index.ts CHANGED
@@ -1,18 +1,3 @@
1
- import {
2
- GlobalServiceClients,
3
- RegionalServiceClients,
4
- ServiceClients,
5
- } from "./services";
6
- import type { GlobalService, RegionalService, Service } from "./services";
7
-
8
- export {
9
- ServiceClients,
10
- GlobalServiceClients,
11
- RegionalServiceClients,
12
- GlobalService,
13
- RegionalService,
14
- Service,
15
- };
16
1
  export * from "./api";
17
2
  export * from "./config";
18
3
  export * from "./graph";
package/src/services.ts DELETED
@@ -1,64 +0,0 @@
1
- import * as S3 from "@aws-sdk/client-s3";
2
- import * as CloudFront from "@aws-sdk/client-cloudfront";
3
- import * as Route53 from "@aws-sdk/client-route-53";
4
-
5
- import * as ApiGatewayV2 from "@aws-sdk/client-apigatewayv2";
6
- import * as AutoScaling from "@aws-sdk/client-auto-scaling";
7
- import * as CloudWatchLogs from "@aws-sdk/client-cloudwatch-logs";
8
- import * as DynamoDB from "@aws-sdk/client-dynamodb";
9
- import * as EC2 from "@aws-sdk/client-ec2";
10
- import * as ECS from "@aws-sdk/client-ecs";
11
- import * as ElasticLoadBalancingV2 from "@aws-sdk/client-elastic-load-balancing-v2";
12
- import * as Lambda from "@aws-sdk/client-lambda";
13
- import * as RDS from "@aws-sdk/client-rds";
14
- import * as SNS from "@aws-sdk/client-sns";
15
- import * as SQS from "@aws-sdk/client-sqs";
16
-
17
- /**
18
- * Clients for Global Services
19
- */
20
- export const GlobalServiceClients = {
21
- S3,
22
- CloudFront,
23
- Route53,
24
- };
25
-
26
- /**
27
- * Clients for Regional Services
28
- */
29
- export const RegionalServiceClients = {
30
- ApiGatewayV2,
31
- AutoScaling,
32
- CloudWatchLogs,
33
- DynamoDB,
34
- EC2,
35
- ECS,
36
- ElasticLoadBalancingV2,
37
- Lambda,
38
- RDS,
39
- SNS,
40
- SQS,
41
- };
42
-
43
- /**
44
- * Clients for every service
45
- */
46
- export const ServiceClients = {
47
- ...GlobalServiceClients,
48
- ...RegionalServiceClients,
49
- };
50
-
51
- /**
52
- * Type for Global Services
53
- */
54
- export type GlobalService = keyof typeof GlobalServiceClients;
55
-
56
- /**
57
- * Type for Regional Services
58
- */
59
- export type RegionalService = keyof typeof RegionalServiceClients;
60
-
61
- /**
62
- * Type for any support service
63
- */
64
- export type Service = GlobalService | RegionalService;