@63klabs/cache-data 1.2.9 → 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,7 +8,21 @@ 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.2.9 (2025-07-15)
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
+
25
+ ## 1.2.10 (2025-07-15)
12
26
 
13
27
  ### Enhancements
14
28
 
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.9",
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": {
@@ -1,20 +1,32 @@
1
1
  const isTrue = (value) => {
2
- return (value !== null && typeof value !== 'undefined' && (value === true || value.toLowerCase() === "true" || value === 1 || value === "1"));
2
+ return (value !== null && typeof value !== 'undefined' &&
3
+ (value === true || value === 1 || value === "1" ||
4
+ (typeof value === 'string' && value.toLowerCase() === "true")));
3
5
  };
4
6
 
5
- const AWSXRay = (isTrue(process.env?.CacheData_AWSXRayOn) || isTrue(process.env?.CACHE_DATA_AWS_X_RAY_ON) ) ? require("aws-xray-sdk-core") : null;
6
-
7
- if (AWSXRay !== null) {
8
- // Configure capture options
9
- const captureOptions = {
10
- captureRequestInit: true, // Capture request init
11
- captureResponse: true, // Capture response
12
- generateUniqueId: true // Generate unique IDs for each request
13
- };
14
-
15
- AWSXRay.captureHTTPsGlobal(require('http'), captureOptions);
16
- AWSXRay.captureHTTPsGlobal(require("https"), captureOptions);
17
- }
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
+ };
18
30
 
19
31
  /**
20
32
  * AWS Helper Functions - Functions to perform common get and put operations for DynamoDB, S3, and SSM parameter store.
@@ -76,7 +88,9 @@ class AWS {
76
88
  static #nodeVer = [];
77
89
  static #aws_region = null;
78
90
 
79
- static #XRayOn = (AWSXRay !== null);
91
+ static get #XRayOn() {
92
+ return initializeXRay() !== null;
93
+ }
80
94
 
81
95
  constructor() {}
82
96
 
@@ -131,38 +145,15 @@ class AWS {
131
145
  REGION: this.REGION,
132
146
  SDK_V2: this.SDK_V2,
133
147
  SDK_V3: this.SDK_V3,
134
- AWSXRayOn: this.#XRayOn
148
+ AWSXRayOn: USE_XRAY
135
149
  });
136
150
  }
137
151
 
138
152
  static #SDK = (
139
153
  function(){
140
- if (AWS.SDK_V2) {
141
- const { DynamoDB, S3, SSM } = (this.#XRayOn) ? AWSXRay.captureAWS(require("aws-sdk")) : require("aws-sdk");
142
- return {
143
- dynamo: {
144
- client: (new DynamoDB.DocumentClient( {region: AWS.REGION} )),
145
- put: (client, params) => client.put(params).promise(),
146
- get: (client, params) => client.get(params).promise(),
147
- scan: (client, params) => client.scan(params).promise(),
148
- delete: (client, params) => client.delete(params).promise(),
149
- update: (client, params) => client.update(params).promise(),
150
- sdk: { DynamoDB }
151
- },
152
- s3: {
153
- client: (new S3()),
154
- put: (client, params) => client.putObject(params).promise(),
155
- get: (client, params) => client.getObject(params).promise(),
156
- sdk: { S3 }
157
- },
158
- ssm: {
159
- client: (new SSM( {region: AWS.REGION} )),
160
- getByName: (client, params) => client.getParameters(params).promise(),
161
- getByPath: (client, params) => client.getParametersByPath(params).promise(),
162
- sdk: { SSM }
163
- }
164
- }
165
- } else {
154
+
155
+ if (AWS.SDK_V3) {
156
+
166
157
  const { DynamoDBClient} = require("@aws-sdk/client-dynamodb");
167
158
  const { DynamoDBDocumentClient, GetCommand, PutCommand, ScanCommand, DeleteCommand, UpdateCommand } = require("@aws-sdk/lib-dynamodb");
168
159
  const { S3, GetObjectCommand, PutObjectCommand } = require("@aws-sdk/client-s3");
@@ -210,7 +201,10 @@ class AWS {
210
201
  GetParametersCommand
211
202
  }
212
203
  }
213
- }
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.");
214
208
  }
215
209
  }
216
210
  )();