@naturalcycles/nodejs-lib 15.99.0 → 15.101.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/yaml2.d.ts +3 -2
- package/dist/fs/yaml2.js +4 -4
- package/dist/validation/ajv/jSchema.d.ts +4 -4
- package/package.json +1 -1
- package/src/fs/yaml2.ts +6 -4
- package/src/validation/ajv/jSchema.ts +19 -17
package/dist/fs/yaml2.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from 'yaml';
|
|
2
|
+
export type YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions;
|
|
2
3
|
export type YamlStringifyOptions = DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions;
|
|
3
4
|
declare class Yaml2 {
|
|
4
|
-
readYaml<T = unknown>(filePath: string): T;
|
|
5
|
-
readYamlAsync<T = unknown>(filePath: string): Promise<T>;
|
|
5
|
+
readYaml<T = unknown>(filePath: string, opt?: YamlParseOptions): T;
|
|
6
|
+
readYamlAsync<T = unknown>(filePath: string, opt?: YamlParseOptions): Promise<T>;
|
|
6
7
|
writeYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void;
|
|
7
8
|
writeYamlAsync(filePath: string, data: any, opt?: YamlStringifyOptions): Promise<void>;
|
|
8
9
|
outputYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void;
|
package/dist/fs/yaml2.js
CHANGED
|
@@ -3,11 +3,11 @@ import fsp from 'node:fs/promises';
|
|
|
3
3
|
import { parse, stringify } from 'yaml';
|
|
4
4
|
import { fs2 } from './fs2.js';
|
|
5
5
|
class Yaml2 {
|
|
6
|
-
readYaml(filePath) {
|
|
7
|
-
return parse(fs.readFileSync(filePath, 'utf8'));
|
|
6
|
+
readYaml(filePath, opt) {
|
|
7
|
+
return parse(fs.readFileSync(filePath, 'utf8'), opt);
|
|
8
8
|
}
|
|
9
|
-
async readYamlAsync(filePath) {
|
|
10
|
-
return parse(await fsp.readFile(filePath, 'utf8'));
|
|
9
|
+
async readYamlAsync(filePath, opt) {
|
|
10
|
+
return parse(await fsp.readFile(filePath, 'utf8'), opt);
|
|
11
11
|
}
|
|
12
12
|
writeYaml(filePath, data, opt) {
|
|
13
13
|
const str = stringify(data, opt);
|
|
@@ -336,11 +336,11 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
|
|
|
336
336
|
* When set, the validation will not strip away properties that are not specified explicitly in the schema.
|
|
337
337
|
*/
|
|
338
338
|
allowAdditionalProperties(): this;
|
|
339
|
-
extend<P extends Record<string, JSchema<any, any>>>(props: P): JObject<Override<OUT, {
|
|
339
|
+
extend<P extends Record<string, JSchema<any, any>>>(props: P): JObject<Expand<Override<OUT, {
|
|
340
340
|
[K in keyof P as P[K] extends JSchema<any, infer IsOpt> ? IsOpt extends true ? never : K : never]: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never;
|
|
341
341
|
} & {
|
|
342
342
|
[K in keyof P as P[K] extends JSchema<any, infer IsOpt> ? IsOpt extends true ? K : never : never]?: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never;
|
|
343
|
-
}
|
|
343
|
+
}>>, false>;
|
|
344
344
|
/**
|
|
345
345
|
* Concatenates another schema to the current schema.
|
|
346
346
|
*
|
|
@@ -352,11 +352,11 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
|
|
|
352
352
|
/**
|
|
353
353
|
* Extends the current schema with `id`, `created` and `updated` according to NC DB conventions.
|
|
354
354
|
*/
|
|
355
|
-
dbEntity(): JObject<Override<OUT, {
|
|
355
|
+
dbEntity(): JObject<Expand<Override<OUT, {
|
|
356
356
|
id: string;
|
|
357
357
|
created: UnixTimestamp;
|
|
358
358
|
updated: UnixTimestamp;
|
|
359
|
-
} & {}
|
|
359
|
+
} & {}>>, false>;
|
|
360
360
|
minProperties(minProperties: number): this;
|
|
361
361
|
maxProperties(maxProperties: number): this;
|
|
362
362
|
exclusiveProperties(propNames: readonly (keyof OUT & string)[]): this;
|
package/package.json
CHANGED
package/src/fs/yaml2.ts
CHANGED
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
import { parse, stringify } from 'yaml'
|
|
11
11
|
import { fs2 } from './fs2.js'
|
|
12
12
|
|
|
13
|
+
export type YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions
|
|
14
|
+
|
|
13
15
|
export type YamlStringifyOptions = DocumentOptions &
|
|
14
16
|
SchemaOptions &
|
|
15
17
|
ParseOptions &
|
|
@@ -17,12 +19,12 @@ export type YamlStringifyOptions = DocumentOptions &
|
|
|
17
19
|
ToStringOptions
|
|
18
20
|
|
|
19
21
|
class Yaml2 {
|
|
20
|
-
readYaml<T = unknown>(filePath: string): T {
|
|
21
|
-
return parse(fs.readFileSync(filePath, 'utf8')) as T
|
|
22
|
+
readYaml<T = unknown>(filePath: string, opt?: YamlParseOptions): T {
|
|
23
|
+
return parse(fs.readFileSync(filePath, 'utf8'), opt) as T
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
async readYamlAsync<T = unknown>(filePath: string): Promise<T> {
|
|
25
|
-
return parse(await fsp.readFile(filePath, 'utf8')) as T
|
|
26
|
+
async readYamlAsync<T = unknown>(filePath: string, opt?: YamlParseOptions): Promise<T> {
|
|
27
|
+
return parse(await fsp.readFile(filePath, 'utf8'), opt) as T
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
writeYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void {
|
|
@@ -1071,23 +1071,25 @@ export class JObject<OUT extends AnyObject, Opt extends boolean = false> extends
|
|
|
1071
1071
|
extend<P extends Record<string, JSchema<any, any>>>(
|
|
1072
1072
|
props: P,
|
|
1073
1073
|
): JObject<
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
?
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
?
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1074
|
+
Expand<
|
|
1075
|
+
Override<
|
|
1076
|
+
OUT,
|
|
1077
|
+
{
|
|
1078
|
+
// required keys
|
|
1079
|
+
[K in keyof P as P[K] extends JSchema<any, infer IsOpt>
|
|
1080
|
+
? IsOpt extends true
|
|
1081
|
+
? never
|
|
1082
|
+
: K
|
|
1083
|
+
: never]: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
|
|
1084
|
+
} & {
|
|
1085
|
+
// optional keys
|
|
1086
|
+
[K in keyof P as P[K] extends JSchema<any, infer IsOpt>
|
|
1087
|
+
? IsOpt extends true
|
|
1088
|
+
? K
|
|
1089
|
+
: never
|
|
1090
|
+
: never]?: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
|
|
1091
|
+
}
|
|
1092
|
+
>
|
|
1091
1093
|
>,
|
|
1092
1094
|
false
|
|
1093
1095
|
> {
|