@naturalcycles/nodejs-lib 15.90.0 → 15.90.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/exec2/exec2.d.ts +1 -1
- package/dist/security/crypto.util.d.ts +1 -1
- package/dist/slack/slack.service.d.ts +1 -1
- package/dist/slack/slack.service.js +1 -1
- package/dist/stream/pipeline.d.ts +10 -10
- package/dist/stream/pipeline.js +4 -4
- package/dist/stream/readable/createReadable.d.ts +1 -1
- package/dist/stream/transform/transformMap.d.ts +3 -2
- package/dist/stream/transform/transformMap.js +1 -1
- package/dist/validation/ajv/ajvSchema.d.ts +4 -8
- package/dist/validation/ajv/ajvSchema.js +1 -11
- package/dist/validation/ajv/from-data/generateJsonSchemaFromData.d.ts +1 -1
- package/dist/validation/ajv/getAjv.d.ts +2 -1
- package/dist/validation/ajv/jsonSchemaBuilder.d.ts +6 -8
- package/dist/validation/ajv/jsonSchemaBuilder.js +13 -14
- package/package.json +2 -1
- package/src/exec2/exec2.ts +2 -1
- package/src/security/crypto.util.ts +2 -1
- package/src/slack/slack.service.ts +6 -7
- package/src/stream/pipeline.ts +30 -34
- package/src/stream/readable/createReadable.ts +2 -1
- package/src/stream/readable/readableCombined.ts +4 -2
- package/src/stream/transform/transformFork.ts +2 -1
- package/src/stream/transform/transformMap.ts +12 -12
- package/src/stream/transform/worker/workerClassProxy.js +1 -1
- package/src/stream/writable/writableChunk.ts +2 -1
- package/src/validation/ajv/ajvSchema.ts +6 -23
- package/src/validation/ajv/from-data/generateJsonSchemaFromData.ts +2 -1
- package/src/validation/ajv/getAjv.ts +2 -1
- package/src/validation/ajv/jsonSchemaBuilder.ts +32 -42
package/dist/exec2/exec2.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StdioOptions } from 'node:child_process';
|
|
2
2
|
import { AppError } from '@naturalcycles/js-lib/error/error.util.js';
|
|
3
3
|
import type { AnyObject, NumberOfMilliseconds } from '@naturalcycles/js-lib/types';
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib/log';
|
|
2
2
|
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
3
3
|
import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model.js';
|
|
4
4
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { localTime } from '@naturalcycles/js-lib/datetime/localTime.js';
|
|
2
2
|
import { getFetcher } from '@naturalcycles/js-lib/http';
|
|
3
|
-
import { createCommonLoggerAtLevel
|
|
3
|
+
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log';
|
|
4
4
|
import { _omit } from '@naturalcycles/js-lib/object/object.util.js';
|
|
5
5
|
import { PQueue } from '@naturalcycles/js-lib/promise/pQueue.js';
|
|
6
6
|
import { _inspect } from '../index.js';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transform } from 'node:stream';
|
|
2
2
|
import type { ReadableStream as WebReadableStream } from 'node:stream/web';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { ZlibOptions, ZstdOptions } from 'node:zlib';
|
|
4
|
+
import type { AbortableAsyncMapper, AsyncIndexedMapper, AsyncPredicate, END, IndexedMapper, Integer, NonNegativeInteger, PositiveInteger, Predicate, SKIP } from '@naturalcycles/js-lib/types';
|
|
5
5
|
import type { ReadableTyped, TransformOptions, TransformTyped, WritableTyped } from './stream.model.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import type { TransformLogProgressOptions } from './transform/transformLogProgress.js';
|
|
7
|
+
import type { TransformMapOptions } from './transform/transformMap.js';
|
|
8
|
+
import type { TransformMapSimpleOptions } from './transform/transformMapSimple.js';
|
|
9
|
+
import type { TransformMapSyncOptions } from './transform/transformMapSync.js';
|
|
10
|
+
import type { TransformOffsetOptions } from './transform/transformOffset.js';
|
|
11
|
+
import type { TransformThrottleOptions } from './transform/transformThrottle.js';
|
|
12
|
+
import type { TransformWarmupOptions } from './transform/transformWarmup.js';
|
|
13
13
|
export declare class Pipeline<T = unknown> {
|
|
14
14
|
private readonly source;
|
|
15
15
|
private transforms;
|
package/dist/stream/pipeline.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { pipeline } from 'node:stream/promises';
|
|
3
|
-
import { createGzip, createUnzip, createZstdCompress, createZstdDecompress
|
|
3
|
+
import { createGzip, createUnzip, createZstdCompress, createZstdDecompress } from 'node:zlib';
|
|
4
4
|
import { createAbortableSignal } from '@naturalcycles/js-lib';
|
|
5
|
-
import { _passthroughPredicate
|
|
5
|
+
import { _passthroughPredicate } from '@naturalcycles/js-lib/types';
|
|
6
6
|
import { fs2 } from '../fs/fs2.js';
|
|
7
7
|
import { zstdLevelToOptions } from '../zip/zip.util.js';
|
|
8
8
|
import { createReadStreamAsNDJson } from './ndjson/createReadStreamAsNDJson.js';
|
|
@@ -16,9 +16,9 @@ import { transformFlatten, transformFlattenIfNeeded } from './transform/transfor
|
|
|
16
16
|
// oxlint-disable-next-line import/no-cycle -- intentional cycle
|
|
17
17
|
import { transformFork } from './transform/transformFork.js';
|
|
18
18
|
import { transformLimit } from './transform/transformLimit.js';
|
|
19
|
-
import { transformLogProgress
|
|
19
|
+
import { transformLogProgress } from './transform/transformLogProgress.js';
|
|
20
20
|
import { transformMap } from './transform/transformMap.js';
|
|
21
|
-
import { transformMapSimple
|
|
21
|
+
import { transformMapSimple } from './transform/transformMapSimple.js';
|
|
22
22
|
import { transformMapSync } from './transform/transformMapSync.js';
|
|
23
23
|
import { transformOffset } from './transform/transformOffset.js';
|
|
24
24
|
import { transformSplitOnNewline } from './transform/transformSplit.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AbortableSignal } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
3
|
-
import {
|
|
3
|
+
import { END, SKIP } from '@naturalcycles/js-lib/types';
|
|
4
|
+
import type { AbortableAsyncMapper, AsyncPredicate, NumberOfSeconds, PositiveInteger, Predicate, Promisable, StringMap, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
|
|
4
5
|
import type { TransformOptions, TransformTyped } from '../stream.model.js';
|
|
5
6
|
export interface TransformMapOptions<IN = any, OUT = IN> extends TransformOptions {
|
|
6
7
|
/**
|
|
@@ -5,7 +5,7 @@ import { _anyToError, _assert, ErrorMode } from '@naturalcycles/js-lib/error';
|
|
|
5
5
|
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log';
|
|
6
6
|
import { pDefer } from '@naturalcycles/js-lib/promise/pDefer.js';
|
|
7
7
|
import { _stringify } from '@naturalcycles/js-lib/string';
|
|
8
|
-
import { END, SKIP
|
|
8
|
+
import { END, SKIP } from '@naturalcycles/js-lib/types';
|
|
9
9
|
import { yellow } from '../../colors/colors.js';
|
|
10
10
|
import { PIPELINE_GRACEFUL_ABORT } from '../stream.util.js';
|
|
11
11
|
const WARMUP_CHECK_INTERVAL_MS = 1000;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type { ZodType } from '@naturalcycles/js-lib/zod';
|
|
1
|
+
import type { ValidationFunction, ValidationFunctionResult } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
4
3
|
import type { Ajv } from 'ajv';
|
|
5
4
|
import { AjvValidationError } from './ajvValidationError.js';
|
|
6
|
-
import {
|
|
5
|
+
import { JsonSchemaTerminal } from './jsonSchemaBuilder.js';
|
|
6
|
+
import type { JsonSchema } from './jsonSchemaBuilder.js';
|
|
7
7
|
/**
|
|
8
8
|
* On creation - compiles ajv validation function.
|
|
9
9
|
* Provides convenient methods, error reporting, etc.
|
|
@@ -25,10 +25,6 @@ export declare class AjvSchema<IN = unknown, OUT = IN> {
|
|
|
25
25
|
* correctly for some reason.
|
|
26
26
|
*/
|
|
27
27
|
static create<IN, OUT = IN>(schema: SchemaHandledByAjv<IN, OUT>, cfg?: Partial<AjvSchemaCfg>): AjvSchema<IN, OUT>;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use `j` to build schemas, not `z` or `zod`.
|
|
30
|
-
*/
|
|
31
|
-
static createFromZod<T extends ZodType<any, any, any>>(schema: T): AjvSchema<T['_input'], T['_output']>;
|
|
32
28
|
static isJsonSchemaBuilder<IN, OUT>(schema: unknown): schema is JsonSchemaTerminal<IN, OUT, any>;
|
|
33
29
|
readonly cfg: AjvSchemaCfg;
|
|
34
30
|
/**
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { _isObject, _lazyValue
|
|
1
|
+
import { _isObject, _lazyValue } from '@naturalcycles/js-lib';
|
|
2
2
|
import { _assert } from '@naturalcycles/js-lib/error';
|
|
3
3
|
import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object';
|
|
4
4
|
import { _substringBefore } from '@naturalcycles/js-lib/string';
|
|
5
5
|
import { _typeCast } from '@naturalcycles/js-lib/types';
|
|
6
|
-
import { z } from '@naturalcycles/js-lib/zod';
|
|
7
6
|
import { _inspect } from '../../string/inspect.js';
|
|
8
7
|
import { AjvValidationError } from './ajvValidationError.js';
|
|
9
8
|
import { getAjv } from './getAjv.js';
|
|
@@ -70,15 +69,6 @@ export class AjvSchema {
|
|
|
70
69
|
AjvSchema.cacheAjvSchema(schema, ajvSchema);
|
|
71
70
|
return ajvSchema;
|
|
72
71
|
}
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated Use `j` to build schemas, not `z` or `zod`.
|
|
75
|
-
*/
|
|
76
|
-
static createFromZod(schema) {
|
|
77
|
-
const jsonSchema = z.toJSONSchema(schema, {
|
|
78
|
-
target: 'draft-2020-12',
|
|
79
|
-
});
|
|
80
|
-
return AjvSchema.create(jsonSchema);
|
|
81
|
-
}
|
|
82
72
|
static isJsonSchemaBuilder(schema) {
|
|
83
73
|
return schema instanceof JsonSchemaTerminal;
|
|
84
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Set2 } from '@naturalcycles/js-lib/object';
|
|
2
|
-
import {
|
|
2
|
+
import type { AnyObject, BaseDBEntity, IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, NumberEnum, StringEnum, StringMap, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
|
|
3
3
|
export declare const j: {
|
|
4
4
|
/**
|
|
5
5
|
* Matches literally any value - equivalent to TypeScript's `any` type.
|
|
@@ -244,17 +244,15 @@ export interface JsonSchemaStringEmailOptions {
|
|
|
244
244
|
export declare class JsonSchemaIsoDateBuilder<Opt extends boolean = false> extends JsonSchemaAnyBuilder<string | IsoDate, IsoDate, Opt> {
|
|
245
245
|
constructor();
|
|
246
246
|
/**
|
|
247
|
-
* @param
|
|
247
|
+
* @param nullValue Pass `null` to have `null` values be considered/converted as `undefined`.
|
|
248
248
|
*
|
|
249
|
-
* This `
|
|
249
|
+
* This `null` feature only works when the current schema is nested in an object or array schema,
|
|
250
250
|
* due to how mutability works in Ajv.
|
|
251
251
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* When `null` is included in optionalValues, the return type becomes `JsonSchemaTerminal`
|
|
252
|
+
* When `null` is passed, the return type becomes `JsonSchemaTerminal`
|
|
255
253
|
* (no further chaining allowed) because the schema is wrapped in an anyOf structure.
|
|
256
254
|
*/
|
|
257
|
-
optional<
|
|
255
|
+
optional<N extends null | undefined = undefined>(nullValue?: N): N extends null ? JsonSchemaTerminal<string | IsoDate | null | undefined, IsoDate | undefined, true> : JsonSchemaAnyBuilder<string | IsoDate | undefined, IsoDate | undefined, true>;
|
|
258
256
|
before(date: string): this;
|
|
259
257
|
sameOrBefore(date: string): this;
|
|
260
258
|
after(date: string): this;
|
|
@@ -338,7 +336,7 @@ export declare class JsonSchemaObjectBuilder<IN extends AnyObject, OUT extends A
|
|
|
338
336
|
* When `null` is passed, the return type becomes `JsonSchemaTerminal`
|
|
339
337
|
* (no further chaining allowed) because the schema is wrapped in an anyOf structure.
|
|
340
338
|
*/
|
|
341
|
-
optional<N extends null | undefined = undefined>(nullValue?: N): N extends null ? JsonSchemaTerminal<IN | undefined, OUT | undefined, true> : JsonSchemaAnyBuilder<IN | undefined, OUT | undefined, true>;
|
|
339
|
+
optional<N extends null | undefined = undefined>(nullValue?: N): N extends null ? JsonSchemaTerminal<IN | null | undefined, OUT | undefined, true> : JsonSchemaAnyBuilder<IN | undefined, OUT | undefined, true>;
|
|
342
340
|
/**
|
|
343
341
|
* When set, the validation will not strip away properties that are not specified explicitly in the schema.
|
|
344
342
|
*/
|
|
@@ -4,7 +4,7 @@ import { _isUndefined, _numberEnumValues, _stringEnumValues, getEnumType, } from
|
|
|
4
4
|
import { _uniq } from '@naturalcycles/js-lib/array';
|
|
5
5
|
import { _assert } from '@naturalcycles/js-lib/error';
|
|
6
6
|
import { _sortObject } from '@naturalcycles/js-lib/object';
|
|
7
|
-
import { _objectAssign, _typeCast, JWT_REGEX
|
|
7
|
+
import { _objectAssign, _typeCast, JWT_REGEX } from '@naturalcycles/js-lib/types';
|
|
8
8
|
import { BASE64URL_REGEX, COUNTRY_CODE_REGEX, CURRENCY_REGEX, IPV4_REGEX, IPV6_REGEX, LANGUAGE_TAG_REGEX, SEMVER_REGEX, SLUG_REGEX, URL_REGEX, UUID_REGEX, } from '../regexes.js';
|
|
9
9
|
import { TIMEZONES } from '../timezones.js';
|
|
10
10
|
import { isEveryItemNumber, isEveryItemPrimitive, isEveryItemString, JSON_SCHEMA_ORDER, mergeJsonSchemaObjects, } from './jsonSchemaBuilder.util.js';
|
|
@@ -509,27 +509,26 @@ export class JsonSchemaIsoDateBuilder extends JsonSchemaAnyBuilder {
|
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
511
|
/**
|
|
512
|
-
* @param
|
|
512
|
+
* @param nullValue Pass `null` to have `null` values be considered/converted as `undefined`.
|
|
513
513
|
*
|
|
514
|
-
* This `
|
|
514
|
+
* This `null` feature only works when the current schema is nested in an object or array schema,
|
|
515
515
|
* due to how mutability works in Ajv.
|
|
516
516
|
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
* When `null` is included in optionalValues, the return type becomes `JsonSchemaTerminal`
|
|
517
|
+
* When `null` is passed, the return type becomes `JsonSchemaTerminal`
|
|
520
518
|
* (no further chaining allowed) because the schema is wrapped in an anyOf structure.
|
|
521
519
|
*/
|
|
522
|
-
optional(
|
|
523
|
-
if (
|
|
520
|
+
optional(nullValue) {
|
|
521
|
+
if (nullValue === undefined) {
|
|
524
522
|
return super.optional();
|
|
525
523
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
524
|
+
// When `null` is specified, we want `null` to be stripped and the value to become `undefined`,
|
|
525
|
+
// so we must allow `null` values to be parsed by Ajv,
|
|
526
|
+
// but the typing should not reflect that.
|
|
527
|
+
// We also cannot accept more rules attached, since we're not building an ObjectSchema anymore.
|
|
528
|
+
return new JsonSchemaTerminal({
|
|
529
|
+
anyOf: [{ type: 'null', optionalValues: [null] }, this.build()],
|
|
530
530
|
optionalField: true,
|
|
531
531
|
});
|
|
532
|
-
return newBuilder;
|
|
533
532
|
}
|
|
534
533
|
before(date) {
|
|
535
534
|
return this.cloneAndUpdateSchema({ IsoDate: { before: date } });
|
|
@@ -760,7 +759,7 @@ export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
|
760
759
|
* (no further chaining allowed) because the schema is wrapped in an anyOf structure.
|
|
761
760
|
*/
|
|
762
761
|
optional(nullValue) {
|
|
763
|
-
if (
|
|
762
|
+
if (nullValue === undefined) {
|
|
764
763
|
return super.optional();
|
|
765
764
|
}
|
|
766
765
|
// When `null` is specified, we want `null` to be stripped and the value to become `undefined`,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.90.
|
|
4
|
+
"version": "15.90.2",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@types/js-yaml": "^4",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"yargs": "^18"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
+
"@typescript/native-preview": "^7.0.0-0",
|
|
21
22
|
"@naturalcycles/dev-lib": "18.4.2"
|
|
22
23
|
},
|
|
23
24
|
"exports": {
|
package/src/exec2/exec2.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { execSync, spawn, spawnSync
|
|
1
|
+
import { execSync, spawn, spawnSync } from 'node:child_process'
|
|
2
|
+
import type { StdioOptions } from 'node:child_process'
|
|
2
3
|
import { _since } from '@naturalcycles/js-lib/datetime/time.util.js'
|
|
3
4
|
import { AppError } from '@naturalcycles/js-lib/error/error.util.js'
|
|
4
5
|
import { _substringAfterLast } from '@naturalcycles/js-lib/string/string.util.js'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
|
-
import { _stringMapEntries
|
|
2
|
+
import { _stringMapEntries } from '@naturalcycles/js-lib/types'
|
|
3
|
+
import type { Base64String, StringMap } from '@naturalcycles/js-lib/types'
|
|
3
4
|
import { md5AsBuffer, sha256AsBuffer } from './hash.util.js'
|
|
4
5
|
|
|
5
6
|
const algorithm = 'aes-256-cbc'
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { localTime } from '@naturalcycles/js-lib/datetime/localTime.js'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createCommonLoggerAtLevel,
|
|
7
|
-
} from '@naturalcycles/js-lib/log'
|
|
2
|
+
import { getFetcher } from '@naturalcycles/js-lib/http'
|
|
3
|
+
import type { Fetcher } from '@naturalcycles/js-lib/http'
|
|
4
|
+
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
|
|
5
|
+
import type { CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib/log'
|
|
8
6
|
import { _omit } from '@naturalcycles/js-lib/object/object.util.js'
|
|
9
7
|
import { PQueue } from '@naturalcycles/js-lib/promise/pQueue.js'
|
|
10
8
|
import type { AnyObject } from '@naturalcycles/js-lib/types'
|
|
11
|
-
import { _inspect
|
|
9
|
+
import { _inspect } from '../index.js'
|
|
10
|
+
import type { InspectAnyOptions } from '../index.js'
|
|
12
11
|
import type {
|
|
13
12
|
SlackApiBody,
|
|
14
13
|
SlackAttachmentField,
|
package/src/stream/pipeline.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { Readable
|
|
1
|
+
import { Readable } from 'node:stream'
|
|
2
|
+
import type { Transform } from 'node:stream'
|
|
2
3
|
import { pipeline } from 'node:stream/promises'
|
|
3
4
|
import type { ReadableStream as WebReadableStream } from 'node:stream/web'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
createUnzip,
|
|
7
|
-
createZstdCompress,
|
|
8
|
-
createZstdDecompress,
|
|
9
|
-
type ZlibOptions,
|
|
10
|
-
type ZstdOptions,
|
|
11
|
-
} from 'node:zlib'
|
|
5
|
+
import { createGzip, createUnzip, createZstdCompress, createZstdDecompress } from 'node:zlib'
|
|
6
|
+
import type { ZlibOptions, ZstdOptions } from 'node:zlib'
|
|
12
7
|
import { createAbortableSignal } from '@naturalcycles/js-lib'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
import { _passthroughPredicate } from '@naturalcycles/js-lib/types'
|
|
9
|
+
import type {
|
|
10
|
+
AbortableAsyncMapper,
|
|
11
|
+
AsyncIndexedMapper,
|
|
12
|
+
AsyncPredicate,
|
|
13
|
+
END,
|
|
14
|
+
IndexedMapper,
|
|
15
|
+
Integer,
|
|
16
|
+
NonNegativeInteger,
|
|
17
|
+
PositiveInteger,
|
|
18
|
+
Predicate,
|
|
19
|
+
SKIP,
|
|
25
20
|
} from '@naturalcycles/js-lib/types'
|
|
26
21
|
import { fs2 } from '../fs/fs2.js'
|
|
27
22
|
import { zstdLevelToOptions } from '../zip/zip.util.js'
|
|
@@ -42,21 +37,22 @@ import { transformFlatten, transformFlattenIfNeeded } from './transform/transfor
|
|
|
42
37
|
// oxlint-disable-next-line import/no-cycle -- intentional cycle
|
|
43
38
|
import { transformFork } from './transform/transformFork.js'
|
|
44
39
|
import { transformLimit } from './transform/transformLimit.js'
|
|
45
|
-
import {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} from './transform/
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} from './transform/
|
|
54
|
-
import {
|
|
55
|
-
import { transformOffset, type TransformOffsetOptions } from './transform/transformOffset.js'
|
|
40
|
+
import { transformLogProgress } from './transform/transformLogProgress.js'
|
|
41
|
+
import type { TransformLogProgressOptions } from './transform/transformLogProgress.js'
|
|
42
|
+
import { transformMap } from './transform/transformMap.js'
|
|
43
|
+
import type { TransformMapOptions } from './transform/transformMap.js'
|
|
44
|
+
import { transformMapSimple } from './transform/transformMapSimple.js'
|
|
45
|
+
import type { TransformMapSimpleOptions } from './transform/transformMapSimple.js'
|
|
46
|
+
import { transformMapSync } from './transform/transformMapSync.js'
|
|
47
|
+
import type { TransformMapSyncOptions } from './transform/transformMapSync.js'
|
|
48
|
+
import { transformOffset } from './transform/transformOffset.js'
|
|
49
|
+
import type { TransformOffsetOptions } from './transform/transformOffset.js'
|
|
56
50
|
import { transformSplitOnNewline } from './transform/transformSplit.js'
|
|
57
51
|
import { transformTap, transformTapSync } from './transform/transformTap.js'
|
|
58
|
-
import { transformThrottle
|
|
59
|
-
import {
|
|
52
|
+
import { transformThrottle } from './transform/transformThrottle.js'
|
|
53
|
+
import type { TransformThrottleOptions } from './transform/transformThrottle.js'
|
|
54
|
+
import { transformWarmup } from './transform/transformWarmup.js'
|
|
55
|
+
import type { TransformWarmupOptions } from './transform/transformWarmup.js'
|
|
60
56
|
import { writablePushToArray } from './writable/writablePushToArray.js'
|
|
61
57
|
import { writableVoid } from './writable/writableVoid.js'
|
|
62
58
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
|
|
3
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log'
|
|
4
|
+
import { pDefer } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
5
|
+
import type { DeferredPromise } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
4
6
|
import { pMap } from '@naturalcycles/js-lib/promise/pMap.js'
|
|
5
7
|
import type { ReadableTyped } from '@naturalcycles/nodejs-lib/stream'
|
|
6
8
|
import type { TransformOptions } from '../stream.model.js'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Transform } from 'node:stream'
|
|
2
2
|
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
|
|
3
|
-
import {
|
|
3
|
+
import { pDefer } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
4
|
+
import type { DeferredPromise } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
4
5
|
// oxlint-disable-next-line import/no-cycle -- intentional cycle
|
|
5
6
|
import { Pipeline } from '../pipeline.js'
|
|
6
7
|
import { createReadable } from '../readable/createReadable.js'
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Transform } from 'node:stream'
|
|
2
|
-
import { _hc
|
|
2
|
+
import { _hc } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { AbortableSignal } from '@naturalcycles/js-lib'
|
|
3
4
|
import { _since } from '@naturalcycles/js-lib/datetime'
|
|
4
5
|
import { _anyToError, _assert, ErrorMode } from '@naturalcycles/js-lib/error'
|
|
5
6
|
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
|
|
6
7
|
import type { DeferredPromise } from '@naturalcycles/js-lib/promise'
|
|
7
8
|
import { pDefer } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
8
9
|
import { _stringify } from '@naturalcycles/js-lib/string'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type UnixTimestampMillis,
|
|
10
|
+
import { END, SKIP } from '@naturalcycles/js-lib/types'
|
|
11
|
+
import type {
|
|
12
|
+
AbortableAsyncMapper,
|
|
13
|
+
AsyncPredicate,
|
|
14
|
+
NumberOfSeconds,
|
|
15
|
+
PositiveInteger,
|
|
16
|
+
Predicate,
|
|
17
|
+
Promisable,
|
|
18
|
+
StringMap,
|
|
19
|
+
UnixTimestampMillis,
|
|
20
20
|
} from '@naturalcycles/js-lib/types'
|
|
21
21
|
import { yellow } from '../../colors/colors.js'
|
|
22
22
|
import type { TransformOptions, TransformTyped } from '../stream.model.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const started = Date.now()
|
|
2
|
-
import { workerData, parentPort } from 'node:worker_threads'
|
|
3
2
|
import { inspect } from 'node:util'
|
|
3
|
+
import { workerData, parentPort } from 'node:worker_threads'
|
|
4
4
|
const { workerFile, workerIndex, logEvery = 1000, metric = 'worker', silent } = workerData || {}
|
|
5
5
|
|
|
6
6
|
if (!workerFile) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Writable } from 'node:stream'
|
|
2
2
|
import { createCommonLoggerAtLevel } from '@naturalcycles/js-lib/log'
|
|
3
|
-
import {
|
|
3
|
+
import { pDefer } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
4
|
+
import type { DeferredPromise } from '@naturalcycles/js-lib/promise/pDefer.js'
|
|
4
5
|
import type { NonNegativeInteger, Predicate } from '@naturalcycles/js-lib/types'
|
|
5
6
|
import { Pipeline } from '../pipeline.js'
|
|
6
7
|
import { createReadable } from '../readable/createReadable.js'
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
_lazyValue,
|
|
4
|
-
type ValidationFunction,
|
|
5
|
-
type ValidationFunctionResult,
|
|
6
|
-
} from '@naturalcycles/js-lib'
|
|
1
|
+
import { _isObject, _lazyValue } from '@naturalcycles/js-lib'
|
|
2
|
+
import type { ValidationFunction, ValidationFunctionResult } from '@naturalcycles/js-lib'
|
|
7
3
|
import { _assert } from '@naturalcycles/js-lib/error'
|
|
8
4
|
import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object'
|
|
9
5
|
import { _substringBefore } from '@naturalcycles/js-lib/string'
|
|
10
|
-
import { _typeCast
|
|
11
|
-
import type {
|
|
12
|
-
import { z } from '@naturalcycles/js-lib/zod'
|
|
6
|
+
import { _typeCast } from '@naturalcycles/js-lib/types'
|
|
7
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types'
|
|
13
8
|
import type { Ajv, ErrorObject } from 'ajv'
|
|
14
9
|
import { _inspect } from '../../string/inspect.js'
|
|
15
10
|
import { AjvValidationError } from './ajvValidationError.js'
|
|
16
11
|
import { getAjv } from './getAjv.js'
|
|
17
|
-
import {
|
|
12
|
+
import { JsonSchemaTerminal } from './jsonSchemaBuilder.js'
|
|
13
|
+
import type { JsonSchema } from './jsonSchemaBuilder.js'
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
* On creation - compiles ajv validation function.
|
|
@@ -93,19 +89,6 @@ export class AjvSchema<IN = unknown, OUT = IN> {
|
|
|
93
89
|
return ajvSchema
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated Use `j` to build schemas, not `z` or `zod`.
|
|
98
|
-
*/
|
|
99
|
-
static createFromZod<T extends ZodType<any, any, any>>(
|
|
100
|
-
schema: T,
|
|
101
|
-
): AjvSchema<T['_input'], T['_output']> {
|
|
102
|
-
const jsonSchema = z.toJSONSchema(schema, {
|
|
103
|
-
target: 'draft-2020-12',
|
|
104
|
-
}) as unknown as JsonSchema<T['_input'], T['_output']>
|
|
105
|
-
|
|
106
|
-
return AjvSchema.create(jsonSchema)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
92
|
static isJsonSchemaBuilder<IN, OUT>(schema: unknown): schema is JsonSchemaTerminal<IN, OUT, any> {
|
|
110
93
|
return schema instanceof JsonSchemaTerminal
|
|
111
94
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _uniq } from '@naturalcycles/js-lib/array'
|
|
2
|
-
import { _stringMapEntries
|
|
2
|
+
import { _stringMapEntries } from '@naturalcycles/js-lib/types'
|
|
3
|
+
import type { AnyObject, StringMap } from '@naturalcycles/js-lib/types'
|
|
3
4
|
import type { JsonSchema } from '../jsonSchemaBuilder.js'
|
|
4
5
|
|
|
5
6
|
type PrimitiveType = 'undefined' | 'null' | 'boolean' | 'string' | 'number'
|
|
@@ -3,7 +3,8 @@ import { _assert } from '@naturalcycles/js-lib/error'
|
|
|
3
3
|
import { _deepCopy, _mapObject, Set2 } from '@naturalcycles/js-lib/object'
|
|
4
4
|
import { _substringAfterLast } from '@naturalcycles/js-lib/string'
|
|
5
5
|
import type { AnyObject } from '@naturalcycles/js-lib/types'
|
|
6
|
-
import { Ajv2020
|
|
6
|
+
import { Ajv2020 } from 'ajv/dist/2020.js'
|
|
7
|
+
import type { Options, ValidateFunction } from 'ajv/dist/2020.js'
|
|
7
8
|
import { validTLDs } from '../tlds.js'
|
|
8
9
|
import type {
|
|
9
10
|
CustomConverterFn,
|
|
@@ -11,22 +11,20 @@ import { _uniq } from '@naturalcycles/js-lib/array'
|
|
|
11
11
|
import { _assert } from '@naturalcycles/js-lib/error'
|
|
12
12
|
import type { Set2 } from '@naturalcycles/js-lib/object'
|
|
13
13
|
import { _sortObject } from '@naturalcycles/js-lib/object'
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type UnixTimestamp,
|
|
29
|
-
type UnixTimestampMillis,
|
|
14
|
+
import { _objectAssign, _typeCast, JWT_REGEX } from '@naturalcycles/js-lib/types'
|
|
15
|
+
import type {
|
|
16
|
+
AnyObject,
|
|
17
|
+
BaseDBEntity,
|
|
18
|
+
IANATimezone,
|
|
19
|
+
Inclusiveness,
|
|
20
|
+
IsoDate,
|
|
21
|
+
IsoDateTime,
|
|
22
|
+
IsoMonth,
|
|
23
|
+
NumberEnum,
|
|
24
|
+
StringEnum,
|
|
25
|
+
StringMap,
|
|
26
|
+
UnixTimestamp,
|
|
27
|
+
UnixTimestampMillis,
|
|
30
28
|
} from '@naturalcycles/js-lib/types'
|
|
31
29
|
import {
|
|
32
30
|
BASE64URL_REGEX,
|
|
@@ -704,39 +702,31 @@ export class JsonSchemaIsoDateBuilder<Opt extends boolean = false> extends JsonS
|
|
|
704
702
|
}
|
|
705
703
|
|
|
706
704
|
/**
|
|
707
|
-
* @param
|
|
705
|
+
* @param nullValue Pass `null` to have `null` values be considered/converted as `undefined`.
|
|
708
706
|
*
|
|
709
|
-
* This `
|
|
707
|
+
* This `null` feature only works when the current schema is nested in an object or array schema,
|
|
710
708
|
* due to how mutability works in Ajv.
|
|
711
709
|
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
* When `null` is included in optionalValues, the return type becomes `JsonSchemaTerminal`
|
|
710
|
+
* When `null` is passed, the return type becomes `JsonSchemaTerminal`
|
|
715
711
|
* (no further chaining allowed) because the schema is wrapped in an anyOf structure.
|
|
716
712
|
*/
|
|
717
|
-
override optional<
|
|
718
|
-
|
|
719
|
-
):
|
|
720
|
-
? JsonSchemaTerminal<string | IsoDate | undefined, IsoDate | undefined, true>
|
|
713
|
+
override optional<N extends null | undefined = undefined>(
|
|
714
|
+
nullValue?: N,
|
|
715
|
+
): N extends null
|
|
716
|
+
? JsonSchemaTerminal<string | IsoDate | null | undefined, IsoDate | undefined, true>
|
|
721
717
|
: JsonSchemaAnyBuilder<string | IsoDate | undefined, IsoDate | undefined, true> {
|
|
722
|
-
if (
|
|
723
|
-
return super.optional()
|
|
718
|
+
if (nullValue === undefined) {
|
|
719
|
+
return super.optional()
|
|
724
720
|
}
|
|
725
721
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
IsoDate | undefined,
|
|
733
|
-
true
|
|
734
|
-
>({
|
|
735
|
-
anyOf: [{ type: 'null', optionalValues }, optionalBuilder.build()],
|
|
722
|
+
// When `null` is specified, we want `null` to be stripped and the value to become `undefined`,
|
|
723
|
+
// so we must allow `null` values to be parsed by Ajv,
|
|
724
|
+
// but the typing should not reflect that.
|
|
725
|
+
// We also cannot accept more rules attached, since we're not building an ObjectSchema anymore.
|
|
726
|
+
return new JsonSchemaTerminal({
|
|
727
|
+
anyOf: [{ type: 'null', optionalValues: [null] }, this.build()],
|
|
736
728
|
optionalField: true,
|
|
737
|
-
})
|
|
738
|
-
|
|
739
|
-
return newBuilder as any
|
|
729
|
+
}) as any
|
|
740
730
|
}
|
|
741
731
|
|
|
742
732
|
before(date: string): this {
|
|
@@ -1059,9 +1049,9 @@ export class JsonSchemaObjectBuilder<
|
|
|
1059
1049
|
override optional<N extends null | undefined = undefined>(
|
|
1060
1050
|
nullValue?: N,
|
|
1061
1051
|
): N extends null
|
|
1062
|
-
? JsonSchemaTerminal<IN | undefined, OUT | undefined, true>
|
|
1052
|
+
? JsonSchemaTerminal<IN | null | undefined, OUT | undefined, true>
|
|
1063
1053
|
: JsonSchemaAnyBuilder<IN | undefined, OUT | undefined, true> {
|
|
1064
|
-
if (
|
|
1054
|
+
if (nullValue === undefined) {
|
|
1065
1055
|
return super.optional()
|
|
1066
1056
|
}
|
|
1067
1057
|
|