@naturalcycles/nodejs-lib 15.106.2 → 15.107.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/dist/fs/kpy.js +1 -1
- package/dist/infra/process.util.js +2 -2
- package/dist/slack/index.d.ts +1 -1
- package/dist/slack/index.js +0 -1
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.js +0 -2
- package/dist/stream/pipeline.d.ts +2 -1
- package/dist/stream/pipeline.js +3 -1
- package/dist/validation/ajv/jSchema.d.ts +13 -13
- package/dist/zip/zip2.d.ts +10 -2
- package/dist/zip/zip2.js +6 -0
- package/package.json +3 -3
- package/src/infra/process.util.ts +2 -2
- package/src/slack/index.ts +1 -1
- package/src/stream/index.ts +2 -2
- package/src/validation/ajv/jSchema.ts +15 -1
- package/src/zip/zip2.ts +6 -0
package/dist/fs/kpy.js
CHANGED
|
@@ -12,7 +12,7 @@ export async function kpy(opt) {
|
|
|
12
12
|
});
|
|
13
13
|
kpyLogFilenames(opt, filenames);
|
|
14
14
|
const overwrite = !opt.noOverwrite;
|
|
15
|
-
await Promise.all(filenames.map(async filename => {
|
|
15
|
+
await Promise.all(filenames.map(async (filename) => {
|
|
16
16
|
const basename = path.basename(filename);
|
|
17
17
|
const srcFilename = path.resolve(opt.baseDir, filename);
|
|
18
18
|
const destFilename = path.resolve(opt.outputDir, opt.flat ? basename : filename);
|
|
@@ -74,8 +74,8 @@ class ProcessUtil {
|
|
|
74
74
|
getCPUInfo() {
|
|
75
75
|
// oxlint-disable-next-line unicorn/no-array-reduce
|
|
76
76
|
return os.cpus().reduce((r, cpu) => {
|
|
77
|
-
r
|
|
78
|
-
Object.values(cpu.times).forEach(m => (r
|
|
77
|
+
r.idle += cpu.times.idle;
|
|
78
|
+
Object.values(cpu.times).forEach(m => (r.total += m));
|
|
79
79
|
return r;
|
|
80
80
|
}, {
|
|
81
81
|
idle: 0,
|
package/dist/slack/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './slack.service.js';
|
|
2
|
-
export * from './slack.service.model.js';
|
|
2
|
+
export type * from './slack.service.model.js';
|
package/dist/slack/index.js
CHANGED
package/dist/stream/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from './progressLogger.js';
|
|
|
8
8
|
export * from './readable/createReadable.js';
|
|
9
9
|
export * from './readable/readableCombined.js';
|
|
10
10
|
export * from './readable/readableFromArray.js';
|
|
11
|
-
export * from './stream.model.js';
|
|
11
|
+
export type * from './stream.model.js';
|
|
12
12
|
export * from './transform/transformChunk.js';
|
|
13
13
|
export * from './transform/transformFilter.js';
|
|
14
14
|
export * from './transform/transformFlatten.js';
|
|
@@ -27,7 +27,7 @@ export * from './transform/transformThrottleByRSS.js';
|
|
|
27
27
|
export * from './transform/transformWarmup.js';
|
|
28
28
|
export * from './transform/worker/baseWorkerClass.js';
|
|
29
29
|
export * from './transform/worker/transformMultiThreaded.js';
|
|
30
|
-
export * from './transform/worker/transformMultiThreaded.model.js';
|
|
30
|
+
export type * from './transform/worker/transformMultiThreaded.model.js';
|
|
31
31
|
export * from './writable/writableChunk.js';
|
|
32
32
|
export * from './writable/writablePushToArray.js';
|
|
33
33
|
export * from './writable/writableVoid.js';
|
package/dist/stream/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export * from './progressLogger.js';
|
|
|
8
8
|
export * from './readable/createReadable.js';
|
|
9
9
|
export * from './readable/readableCombined.js';
|
|
10
10
|
export * from './readable/readableFromArray.js';
|
|
11
|
-
export * from './stream.model.js';
|
|
12
11
|
export * from './transform/transformChunk.js';
|
|
13
12
|
export * from './transform/transformFilter.js';
|
|
14
13
|
export * from './transform/transformFlatten.js';
|
|
@@ -27,7 +26,6 @@ export * from './transform/transformThrottleByRSS.js';
|
|
|
27
26
|
export * from './transform/transformWarmup.js';
|
|
28
27
|
export * from './transform/worker/baseWorkerClass.js';
|
|
29
28
|
export * from './transform/worker/transformMultiThreaded.js';
|
|
30
|
-
export * from './transform/worker/transformMultiThreaded.model.js';
|
|
31
29
|
export * from './writable/writableChunk.js';
|
|
32
30
|
export * from './writable/writablePushToArray.js';
|
|
33
31
|
export * from './writable/writableVoid.js';
|
|
@@ -99,7 +99,8 @@ export declare class Pipeline<T = unknown> {
|
|
|
99
99
|
parseJson<TO = unknown>(this: Pipeline<Buffer> | Pipeline<Uint8Array> | Pipeline<string>): Pipeline<TO>;
|
|
100
100
|
gzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
|
|
101
101
|
gunzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
|
|
102
|
-
zstdCompress(this: Pipeline<Uint8Array>, level?: Integer,
|
|
102
|
+
zstdCompress(this: Pipeline<Uint8Array>, level?: Integer, // defaults to 3
|
|
103
|
+
opt?: ZstdOptions): Pipeline<Uint8Array>;
|
|
103
104
|
zstdDecompress(this: Pipeline<Uint8Array>, opt?: ZstdOptions): Pipeline<Uint8Array>;
|
|
104
105
|
toArray(opt?: TransformOptions): Promise<T[]>;
|
|
105
106
|
toFile(outputFilePath: string): Promise<void>;
|
package/dist/stream/pipeline.js
CHANGED
|
@@ -304,7 +304,9 @@ export class Pipeline {
|
|
|
304
304
|
else if (outputFilePath.endsWith('.zst')) {
|
|
305
305
|
this.transforms.push(createZstdCompress(zip2.zstdLevelToOptions(level)));
|
|
306
306
|
}
|
|
307
|
-
this.destination = fs2.createWriteStream(outputFilePath, {
|
|
307
|
+
this.destination = fs2.createWriteStream(outputFilePath, {
|
|
308
|
+
// highWaterMark: 64 * 1024, // no observed speedup
|
|
309
|
+
});
|
|
308
310
|
await this.run();
|
|
309
311
|
}
|
|
310
312
|
async to(destination) {
|
|
@@ -17,7 +17,7 @@ export declare const j: {
|
|
|
17
17
|
dbEntity: typeof objectDbEntity;
|
|
18
18
|
infer: typeof objectInfer;
|
|
19
19
|
any(): JObject<AnyObject, false>;
|
|
20
|
-
stringMap<S extends JSchema<any, any>>(schema: S): JObject<StringMap<SchemaOut<S
|
|
20
|
+
stringMap<S extends JSchema<any, any>>(schema: S): JObject<StringMap<SchemaOut<S>>>;
|
|
21
21
|
/**
|
|
22
22
|
* @experimental Look around, maybe you find a rule that is better for your use-case.
|
|
23
23
|
*
|
|
@@ -64,9 +64,9 @@ export declare const j: {
|
|
|
64
64
|
};
|
|
65
65
|
array<OUT, Opt>(itemSchema: JSchema<OUT, Opt>): JArray<OUT, Opt>;
|
|
66
66
|
tuple<const S extends JSchema<any, any>[]>(items: S): JTuple<S>;
|
|
67
|
-
set<
|
|
68
|
-
buffer(): JBuilder<Buffer
|
|
69
|
-
enum<const T extends
|
|
67
|
+
set<OUT_1, Opt_1>(itemSchema: JSchema<OUT_1, Opt_1>): JSet2Builder<OUT_1, Opt_1>;
|
|
68
|
+
buffer(): JBuilder<Buffer, false>;
|
|
69
|
+
enum<const T extends readonly (string | number | boolean | null)[] | StringEnum | NumberEnum>(input: T, opt?: JsonBuilderRuleOpt): JEnum<T extends readonly (infer U)[] ? U : T extends StringEnum ? T[keyof T] : T extends NumberEnum ? T[keyof T] : never>;
|
|
70
70
|
/**
|
|
71
71
|
* Use only with primitive values, otherwise this function will throw to avoid bugs.
|
|
72
72
|
* To validate objects, use `anyOfBy`.
|
|
@@ -90,7 +90,7 @@ export declare const j: {
|
|
|
90
90
|
* Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
|
|
91
91
|
* Use `oneOf` when schemas are mutually exclusive.
|
|
92
92
|
*/
|
|
93
|
-
anyOf<
|
|
93
|
+
anyOf<B_1 extends readonly JSchema<any, boolean>[]>(items: [...B_1]): JBuilder<BuilderOutUnion<B_1>, false>;
|
|
94
94
|
/**
|
|
95
95
|
* Pick validation schema for an object based on the value of a specific property.
|
|
96
96
|
*
|
|
@@ -112,7 +112,7 @@ export declare const j: {
|
|
|
112
112
|
* const schema = j.anyOfThese([successSchema, errorSchema])
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
|
-
anyOfThese<
|
|
115
|
+
anyOfThese<B_2 extends readonly JSchema<any, boolean>[]>(items: [...B_2]): JBuilder<BuilderOutUnion<B_2>, false>;
|
|
116
116
|
and(): {
|
|
117
117
|
silentBob: () => never;
|
|
118
118
|
};
|
|
@@ -123,10 +123,10 @@ export declare const j: {
|
|
|
123
123
|
*
|
|
124
124
|
* Optionally accepts a custom Ajv instance and/or inputName for error messages.
|
|
125
125
|
*/
|
|
126
|
-
fromSchema<
|
|
127
|
-
ajv?: Ajv
|
|
128
|
-
inputName?: string
|
|
129
|
-
}
|
|
126
|
+
fromSchema<OUT_2>(schema: JsonSchema<OUT_2>, cfg?: {
|
|
127
|
+
ajv?: Ajv;
|
|
128
|
+
inputName?: string;
|
|
129
|
+
}): JSchema<OUT_2, false>;
|
|
130
130
|
};
|
|
131
131
|
export declare const HIDDEN_AJV_SCHEMA: unique symbol;
|
|
132
132
|
export type WithCachedAjvSchema<Base, OUT> = Base & {
|
|
@@ -363,8 +363,8 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
|
|
|
363
363
|
*/
|
|
364
364
|
dbEntity(): JObject<Expand<Override<OUT, {
|
|
365
365
|
id: string;
|
|
366
|
-
created: UnixTimestamp
|
|
367
|
-
updated: UnixTimestamp
|
|
366
|
+
created: JNumber<UnixTimestamp, false>;
|
|
367
|
+
updated: JNumber<UnixTimestamp, false>;
|
|
368
368
|
} & {}>>, false>;
|
|
369
369
|
minProperties(minProperties: number): this;
|
|
370
370
|
maxProperties(maxProperties: number): this;
|
|
@@ -634,7 +634,7 @@ type HasAllowExtraKeys<T> = T extends {
|
|
|
634
634
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
635
635
|
type IsAssignableRelaxed<A, B> = IsAny<RelaxIndexSignature<A>> extends true ? true : [RelaxIndexSignature<A>] extends [B] ? true : false;
|
|
636
636
|
type ExactMatchBase<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => (T extends B ? 1 : 2) ? (<T>() => T extends B ? 1 : 2) extends <T>() => (T extends A ? 1 : 2) ? true : false : false;
|
|
637
|
-
type ExactMatch<A, B> = HasAllowExtraKeys<B> extends true ? IsAssignableRelaxed<B, A> : ExactMatchBase<Expand<A>, Expand<B>> extends true ? true : ExactMatchBase<Expand<StripIndexSignatureDeep<A>>, Expand<StripIndexSignatureDeep<B
|
|
637
|
+
type ExactMatch<A, B> = HasAllowExtraKeys<B> extends true ? IsAssignableRelaxed<B, A> : ExactMatchBase<Expand<A>, Expand<B>> extends true ? true : ExactMatchBase<Expand<StripIndexSignatureDeep<A>>, Expand<StripIndexSignatureDeep<B>>> extends true ? true : ExactMatchBase<keyof Expand<A>, keyof Expand<B>> extends true ? [Expand<A>] extends [Expand<B>] ? [Expand<B>] extends [Expand<A>] ? true : false : false : false;
|
|
638
638
|
type BuilderOutUnion<B extends readonly JSchema<any, any>[]> = {
|
|
639
639
|
[K in keyof B]: B[K] extends JSchema<infer O, any> ? O : never;
|
|
640
640
|
}[number];
|
package/dist/zip/zip2.d.ts
CHANGED
|
@@ -37,11 +37,19 @@ declare class Zip2 {
|
|
|
37
37
|
gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer<ArrayBuffer>;
|
|
38
38
|
gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
|
|
39
39
|
gunzipToStringSync(buf: Buffer, options?: ZlibOptions): string;
|
|
40
|
-
zstdCompress(input: Buffer | string, level?: Integer,
|
|
41
|
-
|
|
40
|
+
zstdCompress(input: Buffer | string, level?: Integer, // defaults to 3
|
|
41
|
+
options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
|
|
42
|
+
zstdCompressSync(input: Buffer | string, level?: Integer, // defaults to 3
|
|
43
|
+
options?: ZstdOptions): Buffer<ArrayBuffer>;
|
|
42
44
|
zstdLevelToOptions(level: Integer | undefined, opt?: ZstdOptions): ZstdOptions;
|
|
43
45
|
zstdDecompressToString(input: Buffer, options?: ZstdOptions): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
48
|
+
*/
|
|
44
49
|
zstdDecompress(input: Buffer, options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
|
|
50
|
+
/**
|
|
51
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
52
|
+
*/
|
|
45
53
|
zstdDecompressToStringSync(input: Buffer, options?: ZstdOptions): string;
|
|
46
54
|
zstdDecompressSync(input: Buffer, options?: ZstdOptions): Buffer<ArrayBuffer>;
|
|
47
55
|
isZstdBuffer(input: Buffer): boolean;
|
package/dist/zip/zip2.js
CHANGED
|
@@ -103,9 +103,15 @@ class Zip2 {
|
|
|
103
103
|
async zstdDecompressToString(input, options = {}) {
|
|
104
104
|
return (await zstdDecompressAsync(input, options)).toString();
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
108
|
+
*/
|
|
106
109
|
async zstdDecompress(input, options = {}) {
|
|
107
110
|
return await zstdDecompressAsync(input, options);
|
|
108
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
114
|
+
*/
|
|
109
115
|
zstdDecompressToStringSync(input, options = {}) {
|
|
110
116
|
return zlib.zstdDecompressSync(input, options).toString();
|
|
111
117
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.107.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@standard-schema/spec": "^1",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"yargs": "^18"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
21
|
-
"@naturalcycles/dev-lib": "
|
|
20
|
+
"@typescript/native-preview": "7.0.0-dev.20260401.1",
|
|
21
|
+
"@naturalcycles/dev-lib": "20.42.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": "./dist/index.js",
|
|
@@ -104,8 +104,8 @@ class ProcessUtil {
|
|
|
104
104
|
// oxlint-disable-next-line unicorn/no-array-reduce
|
|
105
105
|
return os.cpus().reduce(
|
|
106
106
|
(r, cpu) => {
|
|
107
|
-
r
|
|
108
|
-
Object.values(cpu.times).forEach(m => (r
|
|
107
|
+
r.idle += cpu.times.idle
|
|
108
|
+
Object.values(cpu.times).forEach(m => (r.total += m))
|
|
109
109
|
return r
|
|
110
110
|
},
|
|
111
111
|
{
|
package/src/slack/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './slack.service.js'
|
|
2
|
-
export * from './slack.service.model.js'
|
|
2
|
+
export type * from './slack.service.model.js'
|
package/src/stream/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from './progressLogger.js'
|
|
|
8
8
|
export * from './readable/createReadable.js'
|
|
9
9
|
export * from './readable/readableCombined.js'
|
|
10
10
|
export * from './readable/readableFromArray.js'
|
|
11
|
-
export * from './stream.model.js'
|
|
11
|
+
export type * from './stream.model.js'
|
|
12
12
|
export * from './transform/transformChunk.js'
|
|
13
13
|
export * from './transform/transformFilter.js'
|
|
14
14
|
export * from './transform/transformFlatten.js'
|
|
@@ -27,7 +27,7 @@ export * from './transform/transformThrottleByRSS.js'
|
|
|
27
27
|
export * from './transform/transformWarmup.js'
|
|
28
28
|
export * from './transform/worker/baseWorkerClass.js'
|
|
29
29
|
export * from './transform/worker/transformMultiThreaded.js'
|
|
30
|
-
export * from './transform/worker/transformMultiThreaded.model.js'
|
|
30
|
+
export type * from './transform/worker/transformMultiThreaded.model.js'
|
|
31
31
|
export * from './writable/writableChunk.js'
|
|
32
32
|
export * from './writable/writablePushToArray.js'
|
|
33
33
|
export * from './writable/writableVoid.js'
|
|
@@ -2141,7 +2141,21 @@ type ExactMatch<A, B> =
|
|
|
2141
2141
|
? IsAssignableRelaxed<B, A>
|
|
2142
2142
|
: ExactMatchBase<Expand<A>, Expand<B>> extends true
|
|
2143
2143
|
? true
|
|
2144
|
-
: ExactMatchBase<
|
|
2144
|
+
: ExactMatchBase<
|
|
2145
|
+
Expand<StripIndexSignatureDeep<A>>,
|
|
2146
|
+
Expand<StripIndexSignatureDeep<B>>
|
|
2147
|
+
> extends true
|
|
2148
|
+
? true
|
|
2149
|
+
: // Fallback for types that are structurally identical but have different internal
|
|
2150
|
+
// representations (e.g. enum values from T[keyof T] vs direct enum references).
|
|
2151
|
+
// Keys must match exactly; then check mutual structural assignability.
|
|
2152
|
+
ExactMatchBase<keyof Expand<A>, keyof Expand<B>> extends true
|
|
2153
|
+
? [Expand<A>] extends [Expand<B>]
|
|
2154
|
+
? [Expand<B>] extends [Expand<A>]
|
|
2155
|
+
? true
|
|
2156
|
+
: false
|
|
2157
|
+
: false
|
|
2158
|
+
: false
|
|
2145
2159
|
|
|
2146
2160
|
type BuilderOutUnion<B extends readonly JSchema<any, any>[]> = {
|
|
2147
2161
|
[K in keyof B]: B[K] extends JSchema<infer O, any> ? O : never
|
package/src/zip/zip2.ts
CHANGED
|
@@ -133,10 +133,16 @@ class Zip2 {
|
|
|
133
133
|
return (await zstdDecompressAsync(input, options)).toString()
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
138
|
+
*/
|
|
136
139
|
async zstdDecompress(input: Buffer, options: ZstdOptions = {}): Promise<Buffer<ArrayBuffer>> {
|
|
137
140
|
return await zstdDecompressAsync(input, options)
|
|
138
141
|
}
|
|
139
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Warning! It leaks memory severely. Prefer sync.
|
|
145
|
+
*/
|
|
140
146
|
zstdDecompressToStringSync(input: Buffer, options: ZstdOptions = {}): string {
|
|
141
147
|
return zlib.zstdDecompressSync(input, options).toString()
|
|
142
148
|
}
|