@63klabs/cache-data 1.3.7 → 1.3.8

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,9 +8,65 @@ To report an issue, or to see proposed and upcoming enhancements, check out [63K
8
8
 
9
9
  Report all vulnerabilities under the [Security menu](https://github.com/63Klabs/cache-data/security/advisories) in the Cache-Data GitHub repository.
10
10
 
11
- ## v1.3.8 (unreleased)
11
+ ## v1.3.8 (2026-03-02)
12
+
13
+ ### Security
14
+ - **Updated the way dependencies are listed reduce npm Security Vulnerabilities** [Spec: 1-3-8-npm-security-vulnerabilities-fix](.kiro/specs/1-3-8-npm-security-vulnerabilities-fix/)
15
+ - Fixed 1 low, 20 high, and 1 critical severity vulnerabilities in development dependencies
16
+ - Updated devDependencies to specific secure versions:
17
+ - `@aws-sdk/client-dynamodb`, `@aws-sdk/client-s3`, `@aws-sdk/client-ssm`, `@aws-sdk/lib-dynamodb`: Updated from `3.x` to `^3.995.0`
18
+ - `mocha`: Updated from `^11.x` to `^11.7.5`
19
+ - `chai`: Updated from `^6.x` to `^6.2.2`
20
+ - `chai-http`: Updated from `^5.x` to `^5.1.2`
21
+ - `sinon`: Updated from `^21.x` to `^21.0.1`
22
+ - `fast-check`: Updated from `^4.x` to `^4.5.3`
23
+ - Added npm overrides for transitive dependencies:
24
+ - `diff`: `>=8.0.3` (fixes low severity DoS vulnerability)
25
+ - `minimatch`: `>=10.2.2` (fixes high severity ReDoS vulnerability)
26
+ - `glob`: `>=13.0.6` (fixes transitive vulnerabilities)
27
+ - No breaking changes to public APIs
28
+ - All existing tests pass
29
+ - Production dependencies remain secure (0 vulnerabilities)
12
30
 
13
- - Nothing yet
31
+ ### Added
32
+ - **APIRequest Pagination, Retry, and X-Ray Enhancements** [Spec: 1-3-8-api-request-pagination-retries-xray](.kiro/specs/1-3-8-api-request-pagination-retries-xray/) addresses [#171](https://github.com/63Klabs/cache-data/issues/171), [#172](https://github.com/63Klabs/cache-data/issues/172), [#173](https://github.com/63Klabs/cache-data/issues/173)
33
+ - **Automatic Pagination**: APIRequest now supports automatic pagination for APIs that return paginated results
34
+ - Configurable pagination labels for different API response structures
35
+ - Batch processing for concurrent page requests
36
+ - Support for both offset-based and token-based pagination
37
+ - Automatic result combination into single response
38
+ - Pagination metadata in response (total pages, total items, incomplete status)
39
+ - **Automatic Retry Logic**: APIRequest now includes built-in retry functionality for transient failures
40
+ - Configurable retry attempts (default: 1 retry after initial attempt)
41
+ - Automatic retry on network errors, empty responses, parse errors, and 5xx status codes
42
+ - Optional retry on 4xx status codes (disabled by default)
43
+ - Retry metadata in response (attempts made, final attempt number)
44
+ - **Enhanced X-Ray Subsegments**: Improved AWS X-Ray tracing for better observability
45
+ - Unique subsegment names for each request using timestamps
46
+ - Retry and pagination metadata included in X-Ray traces
47
+ - Separate subsegments for each paginated request
48
+ - Detailed annotations and metadata for debugging
49
+ - **Response Metadata**: New optional metadata field in responses
50
+ - Retry information (occurred, attempts, final attempt)
51
+ - Pagination information (occurred, total pages, total items, incomplete status)
52
+ - Only present when retries or pagination occur
53
+ - **Backwards Compatibility Maintained**: All new features are opt-in via configuration
54
+ - Existing code continues to work without modification
55
+ - No breaking changes to public API
56
+ - Default behavior unchanged when new features not configured
57
+ - See documentation: [Pagination Guide](docs/features/tools/api-request-pagination.md), [Retry Guide](docs/features/tools/api-request-retry.md), [X-Ray Guide](docs/features/tools/api-request-xray.md)
58
+ - **tools.AppConfig** replaces `tools._ConfigSuperClass` and receives an `.init()` to simplify initialization
59
+ - Updated documentation to reflect how `Config` can be implemented to extend `tools._ConfigSuperClass`
60
+ - Instead of separate `Response.init()`, `ClientRequest.init()` and `Connections.init()` a single `AppConfig.init()` can be used within the `Config.init()`
61
+
62
+ ### Enhancement
63
+
64
+ - **Expanded Generic Responses** - Additional responses for status codes
65
+ - Added responses for 408, 418, and 427
66
+ - Ensured all generic responses have the same statuses
67
+ - **Revised Documentation** - Clarified and revised documentation
68
+ - Reviewed all code examples
69
+ - Reviewed implementation instructions
14
70
 
15
71
  ## v1.3.7 (2026-02-06)
16
72
 
package/CONTRIBUTING.md CHANGED
@@ -28,7 +28,7 @@ Code must be reviewed, understood, and tested by a human before being merged.
28
28
 
29
29
  Kiro is the required AI coding assistant for final integrations, documentation, and testing, as it is in the AWS Ecosystem and this project is deveoped to deploy on the AWS platform. Just like test suites, Kiro ensures the proper tests, documentation, and guardrails are in place. Kiro is as important as commit-hooks and tests as it is a tool that ensures quality checks and should not be bypassed.
30
30
 
31
- Ensure [AI Context](./AI_CONTEXT.md) and [Kiro steering documents](.kiro/steering/ai-context-reference.md) are reviewed, understood, and used by both humans and AI.
31
+ Ensure [AGENTS](./AGENTS.md) and Kiro steering documents are reviewed, understood, and used by both humans and AI.
32
32
 
33
33
  ## Development Setup
34
34
 
@@ -162,6 +162,5 @@ Thank you to the following people who have contributed to this project:
162
162
 
163
163
  Chad Kluck\
164
164
  DevOps & Developer Experience Engineer\
165
- AWS Certified Cloud Practitioner | AWS Certified Developer - Associate | AWS
166
- Certified Solutions Architect - Associate\
165
+ AWS Certified Developer and Solutions Architect\
167
166
  [Website](https://chadkluck.me)
package/README.md CHANGED
@@ -29,7 +29,10 @@ The @63klabs/cache-data package provides three main modules:
29
29
  - **Cache Profiles**: Configure multiple cache profiles with different expiration policies
30
30
 
31
31
  ### Endpoint Module
32
- - **HTTP/HTTPS Requests**: Make requests to external APIs and endpoints with built-in retry logic
32
+ - **HTTP/HTTPS Requests**: Make requests to external APIs and endpoints with automatic pagination, retry logic, and X-Ray tracing
33
+ - **Automatic Pagination**: Fetch all pages from paginated APIs automatically with configurable batch processing
34
+ - **Automatic Retry**: Retry failed requests with configurable conditions (network errors, server errors, empty responses)
35
+ - **Enhanced X-Ray Tracing**: Detailed monitoring and debugging with AWS X-Ray subsegments
33
36
  - **Connection Management**: Define and manage multiple endpoint connections with authentication
34
37
  - **Request Caching**: Automatically cache endpoint responses to reduce API calls and improve performance
35
38
  - **Flexible Configuration**: Support for custom headers, query parameters, request bodies, and timeouts
@@ -136,6 +139,42 @@ console.log("API Response:", response.body);
136
139
  console.log("Status Code:", response.statusCode);
137
140
  ```
138
141
 
142
+ ### Using APIRequest with Pagination and Retry
143
+
144
+ ```javascript
145
+ const { tools } = require("@63klabs/cache-data");
146
+
147
+ // Make a request with automatic pagination and retry
148
+ const request = new tools.APIRequest({
149
+ host: "api.example.com",
150
+ path: "/users",
151
+ parameters: {
152
+ limit: 100 // Items per page
153
+ },
154
+ pagination: {
155
+ enabled: true // Automatically fetch all pages
156
+ },
157
+ retry: {
158
+ enabled: true,
159
+ maxRetries: 2 // Retry failed requests up to 2 times
160
+ }
161
+ });
162
+
163
+ const response = await request.send();
164
+
165
+ // Response contains all users from all pages
166
+ const allUsers = JSON.parse(response.body).items;
167
+ console.log(`Retrieved ${allUsers.length} total users`);
168
+
169
+ // Check metadata
170
+ if (response.metadata?.pagination?.occurred) {
171
+ console.log(`Fetched ${response.metadata.pagination.totalPages} pages`);
172
+ }
173
+ if (response.metadata?.retries?.occurred) {
174
+ console.log(`Succeeded after ${response.metadata.retries.attempts} attempts`);
175
+ }
176
+ ```
177
+
139
178
  ### Using Utility Tools
140
179
 
141
180
  ```javascript
@@ -198,8 +237,8 @@ This will install dependencies, configure the pre-commit hook for documentation
198
237
 
199
238
  ## AI Context
200
239
 
201
- See [AI_CONTEXT.md](AI_CONTEXT.md) for important context and guidelines for AI-generated code in this repository.
240
+ See [AGENTS.md](AGENTS.md) for important context and guidelines for AI-generated code in this repository.
202
241
 
203
242
  The context file is also helpful (and perhaps essential) for HUMANS developing within the application's structured platform as well.
204
243
 
205
- AI Assisted Engineering of this solution was provided by [Kiro](https://kiro.dev/). Steering documents are provided in the repository's [.kiro](.kiro/steering/ai-context-reference.md) directory. Because testing is tightly coupled with the implementation, it is suggested all documents, code, and tests are thoroughly reviewed before, and updated after, any changes.
244
+ AI Assisted Engineering of this solution was provided by [Kiro](https://kiro.dev/). Steering documents are provided in the repository's `.kiro/steering/` directory. Because testing is tightly coupled with the implementation, it is suggested all documents, code, and tests are thoroughly reviewed before, and updated after, any changes.
@@ -0,0 +1,53 @@
1
+ import js from '@eslint/js';
2
+
3
+ export default [
4
+ js.configs.recommended,
5
+ {
6
+ languageOptions: {
7
+ ecmaVersion: 'latest',
8
+ sourceType: 'module',
9
+ globals: {
10
+ // Node.js globals
11
+ console: 'readonly',
12
+ process: 'readonly',
13
+ Buffer: 'readonly',
14
+ __dirname: 'readonly',
15
+ __filename: 'readonly',
16
+ exports: 'writable',
17
+ module: 'writable',
18
+ require: 'readonly',
19
+ global: 'readonly',
20
+ // Mocha globals
21
+ describe: 'readonly',
22
+ it: 'readonly',
23
+ before: 'readonly',
24
+ after: 'readonly',
25
+ beforeEach: 'readonly',
26
+ afterEach: 'readonly',
27
+ // ES2021 globals
28
+ globalThis: 'readonly'
29
+ }
30
+ },
31
+ rules: {
32
+ 'no-template-curly-in-string': 'error',
33
+ 'no-eval': 'error',
34
+ 'no-implied-eval': 'error',
35
+ 'no-new-func': 'error'
36
+ }
37
+ },
38
+ {
39
+ files: ['test/**/*.mjs', 'test/**/*.js', 'scripts/**/*.mjs', 'scripts/**/*.js', 'src/**/*.js'],
40
+ rules: {
41
+ 'no-restricted-imports': ['error', {
42
+ patterns: [{
43
+ group: ['child_process'],
44
+ importNames: ['exec', 'execSync'],
45
+ message: 'Use execFile or execFileSync instead of exec/execSync to prevent shell injection. See .kiro/steering/secure-coding-practices.md'
46
+ }]
47
+ }]
48
+ }
49
+ },
50
+ {
51
+ ignores: ['node_modules/**', 'coverage/**', 'coverage-jest/**', '.git/**']
52
+ }
53
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@63klabs/cache-data",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
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",
@@ -21,32 +21,43 @@
21
21
  "object-hash": "^3.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@aws-sdk/client-dynamodb": "3.x",
25
- "@aws-sdk/client-s3": "3.x",
26
- "@aws-sdk/client-ssm": "3.x",
27
- "@aws-sdk/lib-dynamodb": "3.x",
28
- "chai": "^6.x",
29
- "chai-http": "^5.x",
30
- "fast-check": "^4.x",
24
+ "@aws-sdk/client-dynamodb": "^3.995.0",
25
+ "@aws-sdk/client-s3": "^3.995.0",
26
+ "@aws-sdk/client-ssm": "^3.995.0",
27
+ "@aws-sdk/lib-dynamodb": "^3.995.0",
28
+ "@eslint/js": "^10.0.1",
29
+ "chai": "^6.2.2",
30
+ "chai-http": "^5.1.2",
31
+ "eslint": "^10.0.1",
32
+ "fast-check": "^4.5.3",
31
33
  "jest": "^30.2.0",
32
- "mocha": "^11.x",
33
- "sinon": "^21.x"
34
+ "mocha": "^11.7.5",
35
+ "sinon": "^21.0.1"
34
36
  },
35
37
  "overrides": {
36
- "fast-xml-parser": ">=5.3.4"
38
+ "fast-xml-parser": ">=5.3.4",
39
+ "diff": ">=8.0.3",
40
+ "minimatch": ">=10.2.2",
41
+ "glob": ">=13.0.6"
37
42
  },
38
43
  "scripts": {
39
- "test": "mocha 'test/**/*-tests.mjs'",
44
+ "test": "mocha 'test/**/*-tests.mjs' --exclude 'test/migration/property/test-execution-equivalence-property-tests.mjs'",
40
45
  "test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
41
46
  "test:all": "npm test && npm run test:jest",
47
+ "test:migration:validation": "mocha test/migration/property/test-execution-equivalence-property-tests.mjs",
42
48
  "test:cache": "mocha 'test/cache/**/*-tests.mjs'",
43
49
  "test:cache:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/cache",
44
50
  "test:config": "mocha 'test/config/**/*-tests.mjs'",
45
51
  "test:endpoint": "mocha 'test/endpoint/**/*-tests.mjs'",
52
+ "test:endpoint:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/endpoint",
53
+ "test:tools:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/tools",
46
54
  "test:logging": "mocha 'test/logging/**/*-tests.mjs'",
47
55
  "test:request": "mocha 'test/request/**/*-tests.mjs'",
48
56
  "test:response": "mocha 'test/response/**/*-tests.mjs'",
49
- "test:utils": "mocha 'test/utils/**/*-tests.mjs'"
57
+ "test:utils": "mocha 'test/utils/**/*-tests.mjs'",
58
+ "lint": "eslint .",
59
+ "lint:fix": "eslint . --fix",
60
+ "lint:ci": "eslint . --max-warnings 0"
50
61
  },
51
62
  "keywords": [
52
63
  "api",
@@ -3200,7 +3200,6 @@ class TestHarness {
3200
3200
  * WARNING: This method is for testing only and should never be used in production.
3201
3201
  *
3202
3202
  * @returns {{CacheData: typeof CacheData, S3Cache: typeof S3Cache, DynamoDbCache: typeof DynamoDbCache}} Object containing internal classes
3203
- * @private
3204
3203
  * @example
3205
3204
  * // In tests only - DO NOT use in production
3206
3205
  * const { CacheData, S3Cache, DynamoDbCache } = TestHarness.getInternals();