@63klabs/cache-data 1.3.7 → 1.3.9
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/AGENTS.md +1107 -0
- package/CHANGELOG.md +121 -2
- package/CONTRIBUTING.md +4 -5
- package/README.md +50 -25
- package/eslint.config.js +53 -0
- package/package.json +26 -14
- package/src/lib/dao-cache.js +30 -14
- package/src/lib/tools/APIRequest.class.js +948 -91
- package/src/lib/tools/AWS.classes.js +58 -5
- package/src/lib/tools/CachedParametersSecrets.classes.js +1 -0
- package/src/lib/tools/ClientRequest.class.js +858 -31
- package/src/lib/tools/Connections.classes.js +40 -3
- package/src/lib/tools/Response.class.js +11 -0
- package/src/lib/tools/generic.response.html.js +33 -0
- package/src/lib/tools/generic.response.json.js +40 -1
- package/src/lib/tools/generic.response.rss.js +33 -0
- package/src/lib/tools/generic.response.text.js +34 -1
- package/src/lib/tools/generic.response.xml.js +39 -0
- package/src/lib/tools/index.js +211 -50
- package/src/lib/utils/ValidationExecutor.class.js +66 -0
- package/src/lib/utils/ValidationMatcher.class.js +405 -0
|
@@ -54,7 +54,6 @@ class Connections {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
|
|
58
57
|
/**
|
|
59
58
|
* Given an object (associative array) or Connection instance, create a Connection object to add to
|
|
60
59
|
* our collection of Connections.
|
|
@@ -88,10 +87,36 @@ class Connections {
|
|
|
88
87
|
return ( ( connectionName in this._connections ) ? this._connections[connectionName] : null );
|
|
89
88
|
};
|
|
90
89
|
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @returns {Array<Connection>} An array of Connection objects
|
|
93
|
+
*/
|
|
91
94
|
toObject() {
|
|
92
|
-
return
|
|
95
|
+
// iterate through connections and return .toObject() for each
|
|
96
|
+
const obj = {};
|
|
97
|
+
for (var key in this._connections) {
|
|
98
|
+
obj[key] = this._connections[key].toObject();
|
|
99
|
+
}
|
|
100
|
+
return obj;
|
|
93
101
|
};
|
|
94
102
|
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @returns {object}
|
|
106
|
+
*/
|
|
107
|
+
info() {
|
|
108
|
+
// iterate through connections and return .toObject for each
|
|
109
|
+
const obj = {};
|
|
110
|
+
for (var key in this._connections) {
|
|
111
|
+
obj[key] = this._connections[key].toObject();
|
|
112
|
+
}
|
|
113
|
+
return obj;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Used by JSON.stringify
|
|
118
|
+
* @returns {string}
|
|
119
|
+
*/
|
|
95
120
|
toJSON() {
|
|
96
121
|
// loop through the Connection objects in Connections by key and use each of their .toInfoObject() methods to generate an object
|
|
97
122
|
var obj = {};
|
|
@@ -300,7 +325,7 @@ class Connection {
|
|
|
300
325
|
|
|
301
326
|
/**
|
|
302
327
|
*
|
|
303
|
-
* @returns object
|
|
328
|
+
* @returns {object} An object representation of the Connection object
|
|
304
329
|
*/
|
|
305
330
|
toObject() {
|
|
306
331
|
const obj = this._toObject();
|
|
@@ -321,6 +346,10 @@ class Connection {
|
|
|
321
346
|
return obj;
|
|
322
347
|
};
|
|
323
348
|
|
|
349
|
+
/**
|
|
350
|
+
*
|
|
351
|
+
* @returns {object} An object representation of the Connection object
|
|
352
|
+
*/
|
|
324
353
|
toInfoObject() {
|
|
325
354
|
const obj = this._toObject();
|
|
326
355
|
|
|
@@ -339,10 +368,18 @@ class Connection {
|
|
|
339
368
|
return obj;
|
|
340
369
|
}
|
|
341
370
|
|
|
371
|
+
/**
|
|
372
|
+
*
|
|
373
|
+
* @returns {string} Name of connection
|
|
374
|
+
*/
|
|
342
375
|
getName() {
|
|
343
376
|
return this._name;
|
|
344
377
|
};
|
|
345
378
|
|
|
379
|
+
/**
|
|
380
|
+
*
|
|
381
|
+
* @returns {string} String of concatenated connection values
|
|
382
|
+
*/
|
|
346
383
|
toString() {
|
|
347
384
|
return `${this._name} ${this._method} ${(this._uri) ? this._uri : this._protocol+"://"+this._host+this._path}${(this._note) ? " "+this._note : ""}`;
|
|
348
385
|
};
|
|
@@ -151,6 +151,17 @@ class Response {
|
|
|
151
151
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Get information about response initialization
|
|
156
|
+
* @returns {{isInitialized: boolean, settings: Object}
|
|
157
|
+
*/
|
|
158
|
+
static info = () => {
|
|
159
|
+
return {
|
|
160
|
+
isInitialized: Response.#isInitialized,
|
|
161
|
+
settings: Response.#settings,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
154
165
|
/**
|
|
155
166
|
* Resets all properties of the response to default values except those specified in the object.
|
|
156
167
|
* ClientRequest cannot be reset. Uses generic response templates based on status code.
|
|
@@ -44,6 +44,24 @@ response405 = {
|
|
|
44
44
|
body: html("405 Method Not Allowed", "<p>Method Not Allowed</p>")
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
response408 = {
|
|
48
|
+
statusCode: 408,
|
|
49
|
+
headers: headers,
|
|
50
|
+
body: html("408 Request Timeout", "<p>Request Timeout</p>")
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
response418 = {
|
|
54
|
+
statusCode: 418,
|
|
55
|
+
headers: headers,
|
|
56
|
+
body: html("418 I'm a teapot", "<p>I'm a teapot</p>")
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
response427 = {
|
|
60
|
+
statusCode: 427,
|
|
61
|
+
headers: headers,
|
|
62
|
+
body: html("427 Too Many Requests", "<p>Too Many Requests</p>")
|
|
63
|
+
};
|
|
64
|
+
|
|
47
65
|
response500 = {
|
|
48
66
|
statusCode: 500,
|
|
49
67
|
headers: headers,
|
|
@@ -70,6 +88,14 @@ response = function (statusCode) {
|
|
|
70
88
|
return this.response403;
|
|
71
89
|
case 404:
|
|
72
90
|
return this.response404;
|
|
91
|
+
case 405:
|
|
92
|
+
return this.response405;
|
|
93
|
+
case 408:
|
|
94
|
+
return this.response408;
|
|
95
|
+
case 418:
|
|
96
|
+
return this.response418;
|
|
97
|
+
case 427:
|
|
98
|
+
return this.response427;
|
|
73
99
|
case 500:
|
|
74
100
|
return this.response500;
|
|
75
101
|
default:
|
|
@@ -82,7 +108,14 @@ module.exports = {
|
|
|
82
108
|
headers,
|
|
83
109
|
html,
|
|
84
110
|
response200,
|
|
111
|
+
response400,
|
|
112
|
+
response401,
|
|
113
|
+
response403,
|
|
85
114
|
response404,
|
|
115
|
+
response405,
|
|
116
|
+
response408,
|
|
117
|
+
response418,
|
|
118
|
+
response427,
|
|
86
119
|
response500,
|
|
87
120
|
response
|
|
88
121
|
}
|
|
@@ -56,6 +56,30 @@ response405 = {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
response408 = {
|
|
60
|
+
statusCode: 408,
|
|
61
|
+
headers: headers,
|
|
62
|
+
body: {
|
|
63
|
+
message: "Request Timeout"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
response418 = {
|
|
68
|
+
statusCode: 418,
|
|
69
|
+
headers: headers,
|
|
70
|
+
body: {
|
|
71
|
+
message: "I'm a teapot"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
response427 = {
|
|
76
|
+
statusCode: 427,
|
|
77
|
+
headers: headers,
|
|
78
|
+
body: {
|
|
79
|
+
message: "Too Many Requests"
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
59
83
|
response500 = {
|
|
60
84
|
statusCode: 500,
|
|
61
85
|
headers: headers,
|
|
@@ -69,7 +93,7 @@ response500 = {
|
|
|
69
93
|
* @param {number|string} statusCode
|
|
70
94
|
* @returns {{statusCode: number, headers: object, body: Array|Object|string}}
|
|
71
95
|
*/
|
|
72
|
-
response = function (statusCode) {
|
|
96
|
+
const response = function (statusCode) {
|
|
73
97
|
// convert to int
|
|
74
98
|
statusCode = parseInt(statusCode, 10);
|
|
75
99
|
|
|
@@ -84,6 +108,14 @@ response = function (statusCode) {
|
|
|
84
108
|
return this.response403;
|
|
85
109
|
case 404:
|
|
86
110
|
return this.response404;
|
|
111
|
+
case 405:
|
|
112
|
+
return this.response405;
|
|
113
|
+
case 408:
|
|
114
|
+
return this.response408;
|
|
115
|
+
case 418:
|
|
116
|
+
return this.response418;
|
|
117
|
+
case 427:
|
|
118
|
+
return this.response427;
|
|
87
119
|
case 500:
|
|
88
120
|
return this.response500;
|
|
89
121
|
default:
|
|
@@ -96,7 +128,14 @@ module.exports = {
|
|
|
96
128
|
headers,
|
|
97
129
|
json,
|
|
98
130
|
response200,
|
|
131
|
+
response400,
|
|
132
|
+
response401,
|
|
133
|
+
response403,
|
|
99
134
|
response404,
|
|
135
|
+
response405,
|
|
136
|
+
response408,
|
|
137
|
+
response418,
|
|
138
|
+
response427,
|
|
100
139
|
response500,
|
|
101
140
|
response
|
|
102
141
|
}
|
|
@@ -44,6 +44,24 @@ response405 = {
|
|
|
44
44
|
body: rss("<error>Method Not Allowed</error>")
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
response408 = {
|
|
48
|
+
statusCode: 408,
|
|
49
|
+
headers: headers,
|
|
50
|
+
body: rss("<error>Request Timeout</error>")
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
response418 = {
|
|
54
|
+
statusCode: 418,
|
|
55
|
+
headers: headers,
|
|
56
|
+
body: rss("<error>418 I'm a teapot</error>")
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
response427 = {
|
|
60
|
+
statusCode: 427,
|
|
61
|
+
headers: headers,
|
|
62
|
+
body: rss("<error>Too Many Requests</error>")
|
|
63
|
+
};
|
|
64
|
+
|
|
47
65
|
response500 = {
|
|
48
66
|
statusCode: 500,
|
|
49
67
|
headers: headers,
|
|
@@ -70,6 +88,14 @@ response = function (statusCode) {
|
|
|
70
88
|
return this.response403;
|
|
71
89
|
case 404:
|
|
72
90
|
return this.response404;
|
|
91
|
+
case 405:
|
|
92
|
+
return this.response405;
|
|
93
|
+
case 408:
|
|
94
|
+
return this.response408;
|
|
95
|
+
case 418:
|
|
96
|
+
return this.response418;
|
|
97
|
+
case 427:
|
|
98
|
+
return this.response427;
|
|
73
99
|
case 500:
|
|
74
100
|
return this.response500;
|
|
75
101
|
default:
|
|
@@ -82,7 +108,14 @@ module.exports = {
|
|
|
82
108
|
headers,
|
|
83
109
|
rss,
|
|
84
110
|
response200,
|
|
111
|
+
response400,
|
|
112
|
+
response401,
|
|
113
|
+
response403,
|
|
85
114
|
response404,
|
|
115
|
+
response405,
|
|
116
|
+
response408,
|
|
117
|
+
response418,
|
|
118
|
+
response427,
|
|
86
119
|
response500,
|
|
87
120
|
response
|
|
88
121
|
}
|
|
@@ -42,6 +42,24 @@ response405 = {
|
|
|
42
42
|
body: text("Method Not Allowed")
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
response408 = {
|
|
46
|
+
statusCode: 408,
|
|
47
|
+
headers: headers,
|
|
48
|
+
body: text("Request Timeout")
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
response418 = {
|
|
52
|
+
statusCode: 418,
|
|
53
|
+
headers: headers,
|
|
54
|
+
body: text("I'm a teapot")
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
response427 = {
|
|
58
|
+
statusCode: 427,
|
|
59
|
+
headers: headers,
|
|
60
|
+
body: text("Too Many Requests")
|
|
61
|
+
};
|
|
62
|
+
|
|
45
63
|
response500 = {
|
|
46
64
|
statusCode: 500,
|
|
47
65
|
headers: headers,
|
|
@@ -53,7 +71,7 @@ response500 = {
|
|
|
53
71
|
* @param {number|string} statusCode
|
|
54
72
|
* @returns {{statusCode: number, headers: object, body: Array|Object|string}}
|
|
55
73
|
*/
|
|
56
|
-
response = function (statusCode) {
|
|
74
|
+
const response = function (statusCode) {
|
|
57
75
|
// convert to int
|
|
58
76
|
statusCode = parseInt(statusCode, 10);
|
|
59
77
|
|
|
@@ -68,6 +86,14 @@ response = function (statusCode) {
|
|
|
68
86
|
return this.response403;
|
|
69
87
|
case 404:
|
|
70
88
|
return this.response404;
|
|
89
|
+
case 405:
|
|
90
|
+
return this.response405;
|
|
91
|
+
case 408:
|
|
92
|
+
return this.response408;
|
|
93
|
+
case 418:
|
|
94
|
+
return this.response418;
|
|
95
|
+
case 427:
|
|
96
|
+
return this.response427;
|
|
71
97
|
case 500:
|
|
72
98
|
return this.response500;
|
|
73
99
|
default:
|
|
@@ -80,7 +106,14 @@ module.exports = {
|
|
|
80
106
|
headers,
|
|
81
107
|
text,
|
|
82
108
|
response200,
|
|
109
|
+
response400,
|
|
110
|
+
response401,
|
|
111
|
+
response403,
|
|
83
112
|
response404,
|
|
113
|
+
response405,
|
|
114
|
+
response408,
|
|
115
|
+
response418,
|
|
116
|
+
response427,
|
|
84
117
|
response500,
|
|
85
118
|
response
|
|
86
119
|
}
|
|
@@ -44,6 +44,24 @@ response405 = {
|
|
|
44
44
|
body: xml("<error>Method Not Allowed</error>")
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
response408 = {
|
|
48
|
+
statusCode: 408,
|
|
49
|
+
headers: headers,
|
|
50
|
+
body: xml("<error>Request Timeout</error>")
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
response418 = {
|
|
54
|
+
statusCode: 418,
|
|
55
|
+
headers: headers,
|
|
56
|
+
body: xml("<error>418 I'm a teapot</error>")
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
response427 = {
|
|
60
|
+
statusCode: 427,
|
|
61
|
+
headers: headers,
|
|
62
|
+
body: xml("<error>Too Many Requests</error>")
|
|
63
|
+
};
|
|
64
|
+
|
|
47
65
|
response500 = {
|
|
48
66
|
statusCode: 500,
|
|
49
67
|
headers: headers,
|
|
@@ -62,8 +80,22 @@ response = function (statusCode) {
|
|
|
62
80
|
switch (statusCode) {
|
|
63
81
|
case 200:
|
|
64
82
|
return this.response200;
|
|
83
|
+
case 400:
|
|
84
|
+
return this.response400;
|
|
85
|
+
case 401:
|
|
86
|
+
return this.response401;
|
|
87
|
+
case 403:
|
|
88
|
+
return this.response403;
|
|
65
89
|
case 404:
|
|
66
90
|
return this.response404;
|
|
91
|
+
case 405:
|
|
92
|
+
return this.response405;
|
|
93
|
+
case 408:
|
|
94
|
+
return this.response408;
|
|
95
|
+
case 418:
|
|
96
|
+
return this.response418;
|
|
97
|
+
case 427:
|
|
98
|
+
return this.response427;
|
|
67
99
|
case 500:
|
|
68
100
|
return this.response500;
|
|
69
101
|
default:
|
|
@@ -76,7 +108,14 @@ module.exports = {
|
|
|
76
108
|
headers,
|
|
77
109
|
xml,
|
|
78
110
|
response200,
|
|
111
|
+
response400,
|
|
112
|
+
response401,
|
|
113
|
+
response403,
|
|
79
114
|
response404,
|
|
115
|
+
response405,
|
|
116
|
+
response408,
|
|
117
|
+
response418,
|
|
118
|
+
response427,
|
|
80
119
|
response500,
|
|
81
120
|
response
|
|
82
121
|
}
|