@naturalcycles/nodejs-lib 13.2.0 → 13.2.2
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/stream/ndjson/ndjsonMap.js +1 -1
- package/dist/stream/ndjson/pipelineFromNDJsonFile.js +1 -1
- package/dist/stream/ndjson/pipelineToNDJsonFile.js +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.js +1 -1
- package/dist/string/inspect.js +1 -1
- package/dist/validation/ajv/getAjv.js +4 -3
- package/dist/validation/joi/joi.shared.schemas.js +4 -4
- package/package.json +1 -2
- package/src/validation/ajv/getAjv.ts +2 -1
- package/src/validation/joi/joi.shared.schemas.ts +4 -4
|
@@ -22,7 +22,7 @@ async function ndjsonMap(mapper, opt) {
|
|
|
22
22
|
await (0, __1._pipeline)([
|
|
23
23
|
readable,
|
|
24
24
|
...transformUnzip,
|
|
25
|
-
(0, __1.transformSplit)(),
|
|
25
|
+
(0, __1.transformSplit)(), // splits by \n
|
|
26
26
|
(0, __1.transformJsonParse)(),
|
|
27
27
|
(0, __1.transformLimit)({ limit: limitInput, sourceReadable: readable }),
|
|
28
28
|
(0, __1.transformLogProgress)({ metric: 'read', ...opt }),
|
|
@@ -21,7 +21,7 @@ async function pipelineFromNDJsonFile(streams, opt) {
|
|
|
21
21
|
await (0, __1._pipeline)([
|
|
22
22
|
node_fs_1.default.createReadStream(filePath),
|
|
23
23
|
...(gzip ? [(0, node_zlib_1.createUnzip)(opt.zlibOptions)] : []),
|
|
24
|
-
(0, __1.transformSplit)(separator),
|
|
24
|
+
(0, __1.transformSplit)(separator), // splits by separator
|
|
25
25
|
(0, transformJsonParse_1.transformJsonParse)(opt),
|
|
26
26
|
(0, __1.transformTap)(() => rows++),
|
|
27
27
|
...streams,
|
|
@@ -27,7 +27,7 @@ async function pipelineToNDJsonFile(streams, opt) {
|
|
|
27
27
|
...streams,
|
|
28
28
|
(0, __1.transformTap)(() => rows++),
|
|
29
29
|
(0, transformToNDJson_1.transformToNDJson)(opt),
|
|
30
|
-
...(gzip ? [(0, node_zlib_1.createGzip)(opt.zlibOptions)] : []),
|
|
30
|
+
...(gzip ? [(0, node_zlib_1.createGzip)(opt.zlibOptions)] : []), // optional gzip
|
|
31
31
|
node_fs_1.default.createWriteStream(filePath),
|
|
32
32
|
]);
|
|
33
33
|
const { size: sizeBytes } = node_fs_1.default.statSync(filePath);
|
package/dist/string/inspect.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.inspectAny = exports._inspect = exports.inspectStringifyFn = void 0;
|
|
|
4
4
|
const node_util_1 = require("node:util");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const INSPECT_OPT = {
|
|
7
|
-
breakLength: 80,
|
|
7
|
+
breakLength: 80, // default: ??
|
|
8
8
|
depth: 10, // default: 2
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
@@ -7,7 +7,7 @@ const AJV_OPTIONS = {
|
|
|
7
7
|
removeAdditional: true,
|
|
8
8
|
allErrors: true,
|
|
9
9
|
// https://ajv.js.org/options.html#usedefaults
|
|
10
|
-
useDefaults: 'empty',
|
|
10
|
+
useDefaults: 'empty', // this will mutate your input!
|
|
11
11
|
// these are important and kept same as default:
|
|
12
12
|
// https://ajv.js.org/options.html#coercetypes
|
|
13
13
|
coerceTypes: false, // while `false` - it won't mutate your input
|
|
@@ -29,13 +29,14 @@ function getAjv(opt) {
|
|
|
29
29
|
require('ajv-formats')(ajv);
|
|
30
30
|
// https://ajv.js.org/packages/ajv-keywords.html
|
|
31
31
|
require('ajv-keywords')(ajv, [
|
|
32
|
-
'transform',
|
|
32
|
+
'transform', // trim, toLowerCase, etc.
|
|
33
33
|
'uniqueItemProperties',
|
|
34
34
|
'instanceof',
|
|
35
35
|
]);
|
|
36
36
|
// Adds $merge, $patch keywords
|
|
37
37
|
// https://github.com/ajv-validator/ajv-merge-patch
|
|
38
|
-
|
|
38
|
+
// Kirill: temporarily disabled, as it creates a noise of CVE warnings
|
|
39
|
+
// require('ajv-merge-patch')(ajv)
|
|
39
40
|
return ajv;
|
|
40
41
|
}
|
|
41
42
|
exports.getAjv = getAjv;
|
|
@@ -19,22 +19,22 @@ exports.dateObjectSchema = joi_extensions_1.Joi.object().instance(Date);
|
|
|
19
19
|
/**
|
|
20
20
|
* Allows all values of a String Enum.
|
|
21
21
|
*/
|
|
22
|
-
const stringEnumValueSchema = (en) => joi_extensions_1.Joi.string().
|
|
22
|
+
const stringEnumValueSchema = (en) => joi_extensions_1.Joi.string().valid(...(0, js_lib_1._stringEnumValues)(en));
|
|
23
23
|
exports.stringEnumValueSchema = stringEnumValueSchema;
|
|
24
24
|
/**
|
|
25
25
|
* Allows all keys of a String Enum.
|
|
26
26
|
*/
|
|
27
|
-
const stringEnumKeySchema = (en) => joi_extensions_1.Joi.string().
|
|
27
|
+
const stringEnumKeySchema = (en) => joi_extensions_1.Joi.string().valid(...(0, js_lib_1._stringEnumKeys)(en));
|
|
28
28
|
exports.stringEnumKeySchema = stringEnumKeySchema;
|
|
29
29
|
/**
|
|
30
30
|
* Allows all values of a String Enum.
|
|
31
31
|
*/
|
|
32
|
-
const numberEnumValueSchema = (en) => joi_extensions_1.Joi.number().
|
|
32
|
+
const numberEnumValueSchema = (en) => joi_extensions_1.Joi.number().valid(...(0, js_lib_1._numberEnumValues)(en));
|
|
33
33
|
exports.numberEnumValueSchema = numberEnumValueSchema;
|
|
34
34
|
/**
|
|
35
35
|
* Allows all keys of a Number Enum.
|
|
36
36
|
*/
|
|
37
|
-
const numberEnumKeySchema = (en) => joi_extensions_1.Joi.string().
|
|
37
|
+
const numberEnumKeySchema = (en) => joi_extensions_1.Joi.string().valid(...(0, js_lib_1._numberEnumKeys)(en));
|
|
38
38
|
exports.numberEnumKeySchema = numberEnumKeySchema;
|
|
39
39
|
const urlSchema = (scheme = 'https') => joi_extensions_1.Joi.string().uri({ scheme });
|
|
40
40
|
exports.urlSchema = urlSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"ajv": "^8.6.2",
|
|
21
21
|
"ajv-formats": "^2.1.0",
|
|
22
22
|
"ajv-keywords": "^5.0.0",
|
|
23
|
-
"ajv-merge-patch": "^5.0.1",
|
|
24
23
|
"binary-split": "^1.0.5",
|
|
25
24
|
"chalk": "^4.0.0",
|
|
26
25
|
"debug": "^4.1.1",
|
|
@@ -38,7 +38,8 @@ export function getAjv(opt?: Options): Ajv {
|
|
|
38
38
|
|
|
39
39
|
// Adds $merge, $patch keywords
|
|
40
40
|
// https://github.com/ajv-validator/ajv-merge-patch
|
|
41
|
-
|
|
41
|
+
// Kirill: temporarily disabled, as it creates a noise of CVE warnings
|
|
42
|
+
// require('ajv-merge-patch')(ajv)
|
|
42
43
|
|
|
43
44
|
return ajv
|
|
44
45
|
}
|
|
@@ -30,26 +30,26 @@ export const dateObjectSchema = Joi.object().instance(Date)
|
|
|
30
30
|
*/
|
|
31
31
|
export const stringEnumValueSchema = <ENUM extends StringEnum>(
|
|
32
32
|
en: ENUM,
|
|
33
|
-
): StringSchema<ENUM[keyof ENUM]> => Joi.string<ENUM[keyof ENUM]>().
|
|
33
|
+
): StringSchema<ENUM[keyof ENUM]> => Joi.string<ENUM[keyof ENUM]>().valid(..._stringEnumValues(en))
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Allows all keys of a String Enum.
|
|
37
37
|
*/
|
|
38
38
|
export const stringEnumKeySchema = <ENUM extends StringEnum>(en: ENUM): StringSchema =>
|
|
39
|
-
Joi.string().
|
|
39
|
+
Joi.string().valid(..._stringEnumKeys(en))
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Allows all values of a String Enum.
|
|
43
43
|
*/
|
|
44
44
|
export const numberEnumValueSchema = <ENUM extends NumberEnum>(
|
|
45
45
|
en: ENUM,
|
|
46
|
-
): NumberSchema<ENUM[keyof ENUM]> => Joi.number<ENUM[keyof ENUM]>().
|
|
46
|
+
): NumberSchema<ENUM[keyof ENUM]> => Joi.number<ENUM[keyof ENUM]>().valid(..._numberEnumValues(en))
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Allows all keys of a Number Enum.
|
|
50
50
|
*/
|
|
51
51
|
export const numberEnumKeySchema = <ENUM extends NumberEnum>(en: ENUM): StringSchema =>
|
|
52
|
-
Joi.string().
|
|
52
|
+
Joi.string().valid(..._numberEnumKeys(en))
|
|
53
53
|
|
|
54
54
|
export const urlSchema = (scheme: string | string[] = 'https'): StringSchema =>
|
|
55
55
|
Joi.string().uri({ scheme })
|