@63klabs/cache-data 1.2.10 → 1.3.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/CHANGELOG.md CHANGED
@@ -8,6 +8,20 @@ Report all vulnerabilities under the [Security menu](https://github.com/63Klabs/
8
8
 
9
9
  > Note: This project is still in beta. Even though changes are tested and breaking changes are avoided, things may break.
10
10
 
11
+ ## 1.3.0 (2025-07-16)
12
+
13
+ ### Enhancements
14
+
15
+ - Removed AWS SDK V2 support which closes [issue-213](https://github.com/63Klabs/cache-data/issues/213). AWS SDK V2 was for versions of Node 16 and under, and since they are no longer supported Lambda runtimes, support has been removed from cache-data.
16
+
17
+ ### Fixes
18
+
19
+ - Addressed deprecation warnings (handled by Amazon Q Developer):
20
+ - Eliminated Warning:
21
+ - querystring@0.2.0 - From aws-sdk v2 (removed aws-sdk v2)
22
+ - Remaining Warning (unavoidable):
23
+ - lodash.get@4.4.2 - From sinon dependency (external package)
24
+
11
25
  ## 1.2.10 (2025-07-15)
12
26
 
13
27
  ### Enhancements
package/README.md CHANGED
@@ -69,7 +69,7 @@ See [Change Log](CHANGELOG.md) for version history and changes.
69
69
 
70
70
  ## Issues, Features, and Enhancements
71
71
 
72
- Visit the [Issues section of the @63Klabs Cache-Data GitHub repository](https://github.com/63klabs/cache-data) for information on reported issues, upcoming fixes and enhancements, and to submit requests.
72
+ Visit the [Issues section of the @63Klabs Cache-Data GitHub repository](https://github.com/63Klabs/cache-data/issues) for information on reported issues, upcoming fixes and enhancements, and to submit requests.
73
73
 
74
74
  ## License
75
75
 
@@ -81,8 +81,8 @@ This project is licensed under the MIT License - see the LICENSE.txt file for de
81
81
 
82
82
  - Software, DevOps, and Developer Experience Engineer
83
83
  - [AWS Certified Developer - Associate](https://www.credly.com/users/chad-kluck/badges)
84
- - [Website](https://chadkluck.me/)
85
- - [GitHub](https://github.com/chadkluck)
86
- - [GitHub (63Klabs)](https://github.com/63klabs)
84
+ - [Website: chadkluck.me](https://chadkluck.me/)
85
+ - [GitHub: chadkluck](https://github.com/chadkluck)
86
+ - [GitHub: 63Klabs](https://github.com/63klabs)
87
87
  - [Mastodon: @chadkluck@universeodon.com](https://universeodon.com/@chadkluck)
88
88
  - [LinkedIn](https://www.linkedin.com/in/chadkluck/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@63klabs/cache-data",
3
- "version": "1.2.10",
3
+ "version": "1.3.0",
4
4
  "description": "Cache data from an API endpoint or application process using AWS S3 and DynamoDb",
5
5
  "author": "Chad Leigh Kluck (https://chadkluck.me)",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "test": "test"
14
14
  },
15
15
  "engines": {
16
- "node": ">=16.0.0"
16
+ "node": ">=18.0.0"
17
17
  },
18
18
  "dependencies": {
19
19
  "aws-xray-sdk-core": "^3.6.0",
@@ -25,10 +25,9 @@
25
25
  "@aws-sdk/client-s3": "3.x",
26
26
  "@aws-sdk/client-ssm": "3.x",
27
27
  "@aws-sdk/lib-dynamodb": "3.x",
28
- "aws-sdk": "2.x",
29
28
  "chai": "^5.2.0",
30
- "chai-http": "^5.1.1",
31
- "mocha": "^11.1.0",
29
+ "chai-http": "^5.1.2",
30
+ "mocha": "^11.7.1",
32
31
  "sinon": "^21.0.0"
33
32
  },
34
33
  "scripts": {
@@ -4,19 +4,29 @@ const isTrue = (value) => {
4
4
  (typeof value === 'string' && value.toLowerCase() === "true")));
5
5
  };
6
6
 
7
- const AWSXRay = (isTrue(process.env?.CacheData_AWSXRayOn) || isTrue(process.env?.CACHE_DATA_AWS_X_RAY_ON) ) ? require("aws-xray-sdk-core") : null;
8
-
9
- if (AWSXRay !== null) {
10
- // Configure capture options
11
- const captureOptions = {
12
- captureRequestInit: true, // Capture request init
13
- captureResponse: true, // Capture response
14
- generateUniqueId: true // Generate unique IDs for each request
15
- };
16
-
17
- AWSXRay.captureHTTPsGlobal(require('http'), captureOptions);
18
- AWSXRay.captureHTTPsGlobal(require("https"), captureOptions);
19
- }
7
+ const USE_XRAY = isTrue(process.env?.CacheData_AWSXRayOn) || isTrue(process.env?.CACHE_DATA_AWS_X_RAY_ON);
8
+
9
+ let AWSXRay = null;
10
+ let xrayInitialized = false;
11
+
12
+ const initializeXRay = () => {
13
+ if (!xrayInitialized && USE_XRAY) {
14
+ try {
15
+ AWSXRay = require("aws-xray-sdk-core");
16
+ const captureOptions = {
17
+ captureRequestInit: true,
18
+ captureResponse: true,
19
+ generateUniqueId: true
20
+ };
21
+ AWSXRay.captureHTTPsGlobal(require('http'), captureOptions);
22
+ AWSXRay.captureHTTPsGlobal(require("https"), captureOptions);
23
+ } catch (error) {
24
+ AWSXRay = null;
25
+ }
26
+ xrayInitialized = true;
27
+ }
28
+ return AWSXRay;
29
+ };
20
30
 
21
31
  /**
22
32
  * AWS Helper Functions - Functions to perform common get and put operations for DynamoDB, S3, and SSM parameter store.
@@ -78,7 +88,9 @@ class AWS {
78
88
  static #nodeVer = [];
79
89
  static #aws_region = null;
80
90
 
81
- static #XRayOn = (AWSXRay !== null);
91
+ static get #XRayOn() {
92
+ return initializeXRay() !== null;
93
+ }
82
94
 
83
95
  constructor() {}
84
96
 
@@ -133,38 +145,15 @@ class AWS {
133
145
  REGION: this.REGION,
134
146
  SDK_V2: this.SDK_V2,
135
147
  SDK_V3: this.SDK_V3,
136
- AWSXRayOn: this.#XRayOn
148
+ AWSXRayOn: USE_XRAY
137
149
  });
138
150
  }
139
151
 
140
152
  static #SDK = (
141
153
  function(){
142
- if (AWS.SDK_V2) {
143
- const { DynamoDB, S3, SSM } = (this.#XRayOn) ? AWSXRay.captureAWS(require("aws-sdk")) : require("aws-sdk");
144
- return {
145
- dynamo: {
146
- client: (new DynamoDB.DocumentClient( {region: AWS.REGION} )),
147
- put: (client, params) => client.put(params).promise(),
148
- get: (client, params) => client.get(params).promise(),
149
- scan: (client, params) => client.scan(params).promise(),
150
- delete: (client, params) => client.delete(params).promise(),
151
- update: (client, params) => client.update(params).promise(),
152
- sdk: { DynamoDB }
153
- },
154
- s3: {
155
- client: (new S3()),
156
- put: (client, params) => client.putObject(params).promise(),
157
- get: (client, params) => client.getObject(params).promise(),
158
- sdk: { S3 }
159
- },
160
- ssm: {
161
- client: (new SSM( {region: AWS.REGION} )),
162
- getByName: (client, params) => client.getParameters(params).promise(),
163
- getByPath: (client, params) => client.getParametersByPath(params).promise(),
164
- sdk: { SSM }
165
- }
166
- }
167
- } else {
154
+
155
+ if (AWS.SDK_V3) {
156
+
168
157
  const { DynamoDBClient} = require("@aws-sdk/client-dynamodb");
169
158
  const { DynamoDBDocumentClient, GetCommand, PutCommand, ScanCommand, DeleteCommand, UpdateCommand } = require("@aws-sdk/lib-dynamodb");
170
159
  const { S3, GetObjectCommand, PutObjectCommand } = require("@aws-sdk/client-s3");
@@ -212,7 +201,10 @@ class AWS {
212
201
  GetParametersCommand
213
202
  }
214
203
  }
215
- }
204
+ }
205
+ }
206
+ else {
207
+ throw new Error("AWS SDK v2 is no longer supported. Please upgrade to Node.js 18 or higher to use AWS SDK v3.");
216
208
  }
217
209
  }
218
210
  )();