@infrascan/s3-connector 0.1.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.
@@ -0,0 +1,12 @@
1
+ declare class Cache<T> {
2
+ sizeLimit: number;
3
+ size: number;
4
+ state: Record<string, T>;
5
+ keyOrders: Array<string>;
6
+ constructor(maxSize: number);
7
+ set(key: string, val: T): void;
8
+ get(key: string): T | undefined;
9
+ has(key: string): boolean;
10
+ }
11
+
12
+ export { Cache as default };
@@ -0,0 +1,12 @@
1
+ declare class Cache<T> {
2
+ sizeLimit: number;
3
+ size: number;
4
+ state: Record<string, T>;
5
+ keyOrders: Array<string>;
6
+ constructor(maxSize: number);
7
+ set(key: string, val: T): void;
8
+ get(key: string): T | undefined;
9
+ has(key: string): boolean;
10
+ }
11
+
12
+ export = Cache;
package/dist/cache.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cache.ts
21
+ var cache_exports = {};
22
+ __export(cache_exports, {
23
+ default: () => Cache
24
+ });
25
+ module.exports = __toCommonJS(cache_exports);
26
+ var Cache = class {
27
+ constructor(maxSize) {
28
+ if (maxSize < 1) {
29
+ throw new Error("Cannot create a cache with a size less than 1");
30
+ }
31
+ this.sizeLimit = maxSize;
32
+ this.size = 0;
33
+ this.state = {};
34
+ this.keyOrders = [];
35
+ }
36
+ set(key, val) {
37
+ if (this.size === this.sizeLimit) {
38
+ const keyToRemove = this.keyOrders.shift();
39
+ delete this.state[keyToRemove];
40
+ this.size -= 1;
41
+ }
42
+ this.keyOrders.push(key);
43
+ this.state[key] = val;
44
+ this.size += 1;
45
+ }
46
+ get(key) {
47
+ return this.state[key];
48
+ }
49
+ has(key) {
50
+ return this.state[key] != null;
51
+ }
52
+ };
package/dist/cache.mjs ADDED
@@ -0,0 +1,31 @@
1
+ // src/cache.ts
2
+ var Cache = class {
3
+ constructor(maxSize) {
4
+ if (maxSize < 1) {
5
+ throw new Error("Cannot create a cache with a size less than 1");
6
+ }
7
+ this.sizeLimit = maxSize;
8
+ this.size = 0;
9
+ this.state = {};
10
+ this.keyOrders = [];
11
+ }
12
+ set(key, val) {
13
+ if (this.size === this.sizeLimit) {
14
+ const keyToRemove = this.keyOrders.shift();
15
+ delete this.state[keyToRemove];
16
+ this.size -= 1;
17
+ }
18
+ this.keyOrders.push(key);
19
+ this.state[key] = val;
20
+ this.size += 1;
21
+ }
22
+ get(key) {
23
+ return this.state[key];
24
+ }
25
+ has(key) {
26
+ return this.state[key] != null;
27
+ }
28
+ };
29
+ export {
30
+ Cache as default
31
+ };
package/dist/index.d.mts CHANGED
@@ -1,15 +1,5 @@
1
1
  import { S3Client, PutObjectCommandOutput } from '@aws-sdk/client-s3';
2
-
3
- declare class Cache<T> {
4
- sizeLimit: number;
5
- size: number;
6
- state: Record<string, T>;
7
- keyOrders: Array<string>;
8
- constructor(maxSize: number);
9
- set(key: string, val: T): void;
10
- get(key: string): T | undefined;
11
- has(key: string): boolean;
12
- }
2
+ import Cache from './cache.mjs';
13
3
 
14
4
  interface ConstructorArgs {
15
5
  S3: S3Client;
@@ -44,4 +34,4 @@ declare class S3Connector {
44
34
  writeGraphData(graphBlob: any): Promise<PutObjectCommandOutput>;
45
35
  }
46
36
 
47
- export { ConstructorArgs, S3Connector as default };
37
+ export { type ConstructorArgs, S3Connector as default };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,5 @@
1
1
  import { S3Client, PutObjectCommandOutput } from '@aws-sdk/client-s3';
2
-
3
- declare class Cache<T> {
4
- sizeLimit: number;
5
- size: number;
6
- state: Record<string, T>;
7
- keyOrders: Array<string>;
8
- constructor(maxSize: number);
9
- set(key: string, val: T): void;
10
- get(key: string): T | undefined;
11
- has(key: string): boolean;
12
- }
2
+ import Cache from './cache.js';
13
3
 
14
4
  interface ConstructorArgs {
15
5
  S3: S3Client;
@@ -44,4 +34,4 @@ declare class S3Connector {
44
34
  writeGraphData(graphBlob: any): Promise<PutObjectCommandOutput>;
45
35
  }
46
36
 
47
- export { ConstructorArgs, S3Connector as default };
37
+ export { type ConstructorArgs, S3Connector as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrascan/s3-connector",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Connector for the Infrascan SDK to read and write state to an S3 bucket",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -16,25 +16,11 @@
16
16
  "dist"
17
17
  ],
18
18
  "scripts": {
19
- "build": "rm -rf dist ; tsup",
20
- "prepublish": "rm -rf dist ; tsup",
19
+ "build": "rm -rf dist ; tsup --config internal/tsconfig/tsup.json",
20
+ "prepublish": "rm -rf dist ; tsup --config internal/tsconfig/tsup.json",
21
21
  "lint": "tsc --noEmit ; eslint .",
22
22
  "clean": "rm -rf dist node_modules",
23
- "test": "tap test/*.test.ts --allow-incomplete-coverage -- --typescript"
24
- },
25
- "tsup": {
26
- "clean": true,
27
- "cjsInterop": true,
28
- "splitting": false,
29
- "dts": true,
30
- "entry": [
31
- "src/index.ts"
32
- ],
33
- "format": [
34
- "esm",
35
- "cjs"
36
- ],
37
- "target": "node18"
23
+ "test": "tap src/*.test.ts --allow-incomplete-coverage -- --typescript"
38
24
  },
39
25
  "keywords": [
40
26
  "AWS",
@@ -47,15 +33,15 @@
47
33
  "license": "MPL-2.0",
48
34
  "devDependencies": {
49
35
  "@aws-sdk/util-stream-node": "^3.374.0",
50
- "@infrascan/shared-types": "^0.2.2",
36
+ "@infrascan/shared-types": "^0.5.1",
51
37
  "aws-sdk-client-mock": "^3.0.0",
52
38
  "eslint-config-custom": "*",
53
- "tap": "^18.5.7",
39
+ "tap": "^18.7.0",
54
40
  "tsconfig": "*",
55
41
  "typescript": "^5.1.6"
56
42
  },
57
43
  "dependencies": {
58
- "@aws-sdk/client-s3": "3.428.0",
44
+ "@aws-sdk/client-s3": "3.624.0",
59
45
  "minimatch": "^9.0.3"
60
46
  }
61
47
  }