@infrascan/fs-connector 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -2,19 +2,37 @@
2
2
 
3
3
  Infrascan connectors act as the plumbing between the Infrascan SDK and wherever you persist your scan state.
4
4
 
5
- The FS connector uses the local filesystem. This library exposes a single builder function which takes a base path to use as the directory.
5
+ The Fs connector uses the local filesystem. This library exposes a single builder function which takes a base path to use as the directory.
6
6
 
7
7
  All state files are written into the directory in the format: `<account>-<region>-<service>-<function>.json`.
8
8
 
9
9
  ## Quickstart
10
10
 
11
11
  ```js
12
+ import Infrascan from "@infrascan/sdk";
12
13
  import buildFsConnector from "@infrascan/fs-connector";
13
- import { performScan } from "@infrascan/sdk";
14
+ import { registerAwsScanners } from "@infrascan/aws";
14
15
  import { fromIni } from "@aws-sdk/credential-providers";
15
16
 
17
+ const credentials = fromIni({ profile: "dev" });
18
+ const regions = ["us-east-1","us-west-1"];
19
+ const services = ["SNS","Lambda","S3"];
20
+
16
21
  const connector = buildFsConnector('state');
22
+ const infrascan = registerAwsScanners(new Infrascan());
17
23
 
18
- const credentials = fromIni({ profile: "dev" });
19
- await performScan(credentials, connector);
24
+ infrascan.performScan(
25
+ credentials,
26
+ connector
27
+ ).then(function (scanMetadata) {
28
+ console.log("Scan Complete!", scanMetadata);
29
+ return infrascan.generateGraph(
30
+ scanMetadata,
31
+ connector
32
+ );
33
+ }).then(function (graphData) {
34
+ console.log("Graph generated!", graphData);
35
+ }).catch(function (err) {
36
+ console.error("Failed to scan", err);
37
+ });
20
38
  ```
@@ -0,0 +1,26 @@
1
+ import { Connector } from '@infrascan/shared-types';
2
+
3
+ /**
4
+ * Config for the file system resolver.
5
+ */
6
+ type FsResolverConfig = {
7
+ /**
8
+ * Pretty print state when writing to the fs.
9
+ */
10
+ prettyPrint?: boolean;
11
+ /**
12
+ * Force creation of the target directory. Note: this will enable recursive creation.
13
+ */
14
+ createTargetDirectory?: boolean;
15
+ };
16
+ declare const DEFAULT_CONFIG: Required<FsResolverConfig>;
17
+ /**
18
+ * Connector to store state in the local file system
19
+ * @param {string} basePath Directory to store Infrascan scan and graph state in
20
+ * @param {FsResolverConfig} config Configuration for the FS Connector
21
+ * @returns {Connector} Infrascan Connector
22
+ * @throws {Error} Errors from readDir, and readFile calls.
23
+ */
24
+ declare function buildFsConnector(basePath: string, config?: FsResolverConfig): Connector;
25
+
26
+ export { DEFAULT_CONFIG, FsResolverConfig, buildFsConnector as default };
@@ -0,0 +1,26 @@
1
+ import { Connector } from '@infrascan/shared-types';
2
+
3
+ /**
4
+ * Config for the file system resolver.
5
+ */
6
+ type FsResolverConfig = {
7
+ /**
8
+ * Pretty print state when writing to the fs.
9
+ */
10
+ prettyPrint?: boolean;
11
+ /**
12
+ * Force creation of the target directory. Note: this will enable recursive creation.
13
+ */
14
+ createTargetDirectory?: boolean;
15
+ };
16
+ declare const DEFAULT_CONFIG: Required<FsResolverConfig>;
17
+ /**
18
+ * Connector to store state in the local file system
19
+ * @param {string} basePath Directory to store Infrascan scan and graph state in
20
+ * @param {FsResolverConfig} config Configuration for the FS Connector
21
+ * @returns {Connector} Infrascan Connector
22
+ * @throws {Error} Errors from readDir, and readFile calls.
23
+ */
24
+ declare function buildFsConnector(basePath: string, config?: FsResolverConfig): Connector;
25
+
26
+ export { DEFAULT_CONFIG, FsResolverConfig, buildFsConnector as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrascan/fs-connector",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Connector for the Infrascan SDK to read and write state to the local filesystem",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,6 +25,7 @@
25
25
  "clean": true,
26
26
  "cjsInterop": true,
27
27
  "splitting": false,
28
+ "dts": true,
28
29
  "entry": [
29
30
  "index.ts"
30
31
  ],
@@ -34,11 +35,17 @@
34
35
  ],
35
36
  "target": "node18"
36
37
  },
37
- "keywords": [],
38
+ "keywords": [
39
+ "AWS",
40
+ "Infrastructure Diagram",
41
+ "Infrastructure Graph",
42
+ "Cloud Infrastructure",
43
+ "Connector"
44
+ ],
38
45
  "author": "Liam Farrelly <liam@l3f7.dev> (https://whoisli.am/)",
39
46
  "license": "MPL-2.0",
40
47
  "devDependencies": {
41
- "@infrascan/shared-types": "^0.2.1",
48
+ "@infrascan/shared-types": "^0.2.2",
42
49
  "eslint-config-custom": "*",
43
50
  "tsconfig": "*",
44
51
  "typescript": "^5.1.6"