@naturalcycles/nodejs-lib 12.65.0 → 12.65.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.
- package/dist/got/getGot.js +5 -0
- package/dist/util/lruMemoCache.js +1 -1
- package/dist/validation/ajv/ajv.util.js +1 -1
- package/dist/validation/ajv/ajvSchema.js +1 -1
- package/package.json +3 -3
- package/src/got/getGot.ts +7 -0
- package/src/util/lruMemoCache.ts +1 -1
- package/src/validation/ajv/ajv.util.ts +1 -1
- package/src/validation/ajv/ajvSchema.ts +1 -1
package/dist/got/getGot.js
CHANGED
|
@@ -178,6 +178,11 @@ function gotBeforeRetryHook(opt) {
|
|
|
178
178
|
return (options, err, retryCount) => {
|
|
179
179
|
// opt.logger!.log('beforeRetry', retryCount)
|
|
180
180
|
const statusCode = err?.response?.statusCode || 0;
|
|
181
|
+
if (statusCode && statusCode < 300) {
|
|
182
|
+
// todo: possibly remove the log message completely in the future
|
|
183
|
+
opt.logger.log(`skipping got.beforeRetry hook at statusCode is ${statusCode}`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
181
186
|
const { method, url, prefixUrl } = options;
|
|
182
187
|
const shortUrl = getShortUrl(opt, url, prefixUrl);
|
|
183
188
|
const { started } = options.context;
|
|
@@ -13,7 +13,7 @@ const ajvSchema_1 = require("./ajvSchema");
|
|
|
13
13
|
* @experimental
|
|
14
14
|
*/
|
|
15
15
|
function readJsonSchemas(patterns, opt) {
|
|
16
|
-
return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, '
|
|
16
|
+
return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')));
|
|
17
17
|
}
|
|
18
18
|
exports.readJsonSchemas = readJsonSchemas;
|
|
19
19
|
/**
|
|
@@ -60,7 +60,7 @@ class AjvSchema {
|
|
|
60
60
|
*/
|
|
61
61
|
static readJsonSync(filePath, cfg = {}) {
|
|
62
62
|
(0, index_1.requireFileToExist)(filePath);
|
|
63
|
-
const schema = JSON.parse(fs.readFileSync(filePath, '
|
|
63
|
+
const schema = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
64
64
|
return new AjvSchema(schema, cfg);
|
|
65
65
|
}
|
|
66
66
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "12.65.
|
|
3
|
+
"version": "12.65.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@naturalcycles/js-lib": "^14.0.0",
|
|
18
18
|
"@naturalcycles/time-lib": "^3.0.1",
|
|
19
|
-
"@types/lru-cache": "^
|
|
19
|
+
"@types/lru-cache": "^7.4.0",
|
|
20
20
|
"@types/through2-concurrent": "^2.0.0",
|
|
21
21
|
"ajv": "^8.6.2",
|
|
22
22
|
"ajv-formats": "^2.1.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"globby": "^11.0.0",
|
|
33
33
|
"got": "^11.0.1",
|
|
34
34
|
"joi": "17.4.2",
|
|
35
|
-
"lru-cache": "^
|
|
35
|
+
"lru-cache": "^7.4.0",
|
|
36
36
|
"move-file": "^2.0.0",
|
|
37
37
|
"nanoid": "^3.0.0",
|
|
38
38
|
"through2-concurrent": "^2.0.0",
|
package/src/got/getGot.ts
CHANGED
|
@@ -204,6 +204,13 @@ function gotBeforeRetryHook(opt: GetGotOptions): BeforeRetryHook {
|
|
|
204
204
|
return (options, err, retryCount) => {
|
|
205
205
|
// opt.logger!.log('beforeRetry', retryCount)
|
|
206
206
|
const statusCode = err?.response?.statusCode || 0
|
|
207
|
+
|
|
208
|
+
if (statusCode && statusCode < 300) {
|
|
209
|
+
// todo: possibly remove the log message completely in the future
|
|
210
|
+
opt.logger!.log(`skipping got.beforeRetry hook at statusCode is ${statusCode}`)
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
|
|
207
214
|
const { method, url, prefixUrl } = options
|
|
208
215
|
const shortUrl = getShortUrl(opt, url, prefixUrl)
|
|
209
216
|
const { started } = options.context as GotRequestContext
|
package/src/util/lruMemoCache.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { AjvSchema, AjvSchemaCfg } from './ajvSchema'
|
|
|
13
13
|
* @experimental
|
|
14
14
|
*/
|
|
15
15
|
export function readJsonSchemas(patterns: string | string[], opt?: GlobbyOptions): JsonSchema[] {
|
|
16
|
-
return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, '
|
|
16
|
+
return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')))
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -132,7 +132,7 @@ export class AjvSchema<T = unknown> {
|
|
|
132
132
|
cfg: Partial<AjvSchemaCfg> = {},
|
|
133
133
|
): AjvSchema<T> {
|
|
134
134
|
requireFileToExist(filePath)
|
|
135
|
-
const schema = JSON.parse(fs.readFileSync(filePath, '
|
|
135
|
+
const schema = JSON.parse(fs.readFileSync(filePath, 'utf8'))
|
|
136
136
|
return new AjvSchema<T>(schema, cfg)
|
|
137
137
|
}
|
|
138
138
|
|