@naturalcycles/nodejs-lib 15.146.0 → 15.147.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/fs2.js +2 -4
- package/dist/validation/ajv/jSchema.d.ts +12 -5
- package/package.json +2 -2
- package/src/fs/fs2.ts +3 -5
- package/src/validation/ajv/jSchema.ts +16 -20
package/dist/fs/fs2.js
CHANGED
|
@@ -271,11 +271,9 @@ class FS2 {
|
|
|
271
271
|
* Doesn't throw, returns false instead.
|
|
272
272
|
*/
|
|
273
273
|
isDirectory(filePath) {
|
|
274
|
-
return (
|
|
275
|
-
.stat(filePath, {
|
|
274
|
+
return (this.stat(filePath, {
|
|
276
275
|
throwIfNoEntry: false,
|
|
277
|
-
})
|
|
278
|
-
?.isDirectory() || false);
|
|
276
|
+
})?.isDirectory() || false);
|
|
279
277
|
}
|
|
280
278
|
// Re-export the whole fs/fsp, for the edge cases where they are needed
|
|
281
279
|
fs = fs;
|
|
@@ -430,17 +430,15 @@ export declare class JObjectInfer<PROPS extends Record<string, JSchema<any, any>
|
|
|
430
430
|
* When set, the validation will not strip away properties that are not specified explicitly in the schema.
|
|
431
431
|
*/
|
|
432
432
|
allowAdditionalProperties(): this;
|
|
433
|
-
extend<NEW_PROPS extends Record<string, JSchema<any, any>>>(props: NEW_PROPS): JObjectInfer<
|
|
434
|
-
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS ? NEW_PROPS[K] : K extends keyof PROPS ? PROPS[K] : never;
|
|
435
|
-
}, Opt>;
|
|
433
|
+
extend<NEW_PROPS extends Record<string, JSchema<any, any>>>(props: NEW_PROPS): JObjectInfer<ExtendedProps<PROPS, NEW_PROPS>, Opt>;
|
|
436
434
|
/**
|
|
437
435
|
* Extends the current schema with `id`, `created` and `updated` according to NC DB conventions.
|
|
438
436
|
*/
|
|
439
|
-
dbEntity(): JObjectInfer<
|
|
437
|
+
dbEntity(): JObjectInfer<ExtendedProps<PROPS, {
|
|
440
438
|
id: JString<string, false>;
|
|
441
439
|
created: JNumber<UnixTimestamp, false>;
|
|
442
440
|
updated: JNumber<UnixTimestamp, false>;
|
|
443
|
-
}
|
|
441
|
+
}>, Opt>;
|
|
444
442
|
}
|
|
445
443
|
export declare class JArray<OUT, Opt, ARR extends OUT[] = OUT[]> extends JBuilder<ARR, Opt> {
|
|
446
444
|
constructor(itemsSchema: JSchema<OUT, Opt>);
|
|
@@ -709,6 +707,15 @@ type RelaxIndexSignature<T> = T extends readonly unknown[] ? T : T extends AnyOb
|
|
|
709
707
|
[K in keyof T]: RelaxIndexSignature<T[K]>;
|
|
710
708
|
} : T;
|
|
711
709
|
type Override<T, U> = Omit<T, keyof U> & U;
|
|
710
|
+
/**
|
|
711
|
+
* Props of `JObjectInfer.extend()`: NEW_PROPS override PROPS with the same key.
|
|
712
|
+
*
|
|
713
|
+
* A named alias keeps the return type annotation and the cast in `extend()` identical.
|
|
714
|
+
* TypeScript 7.1 reports two separately written copies of this mapped type as unrelated (TS2719).
|
|
715
|
+
*/
|
|
716
|
+
type ExtendedProps<PROPS, NEW_PROPS> = {
|
|
717
|
+
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS ? NEW_PROPS[K] : K extends keyof PROPS ? PROPS[K] : never;
|
|
718
|
+
};
|
|
712
719
|
declare const allowExtraKeysSymbol: unique symbol;
|
|
713
720
|
type HasAllowExtraKeys<T> = T extends {
|
|
714
721
|
readonly [allowExtraKeysSymbol]?: true;
|
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.147.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@standard-schema/spec": "^1",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"yaml": "^2"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@naturalcycles/dev-lib": "20.
|
|
17
|
+
"@naturalcycles/dev-lib": "20.76.0",
|
|
18
18
|
"typescript": "^7"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
package/src/fs/fs2.ts
CHANGED
|
@@ -312,11 +312,9 @@ class FS2 {
|
|
|
312
312
|
*/
|
|
313
313
|
isDirectory(filePath: string): boolean {
|
|
314
314
|
return (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
})
|
|
319
|
-
?.isDirectory() || false
|
|
315
|
+
this.stat(filePath, {
|
|
316
|
+
throwIfNoEntry: false,
|
|
317
|
+
})?.isDirectory() || false
|
|
320
318
|
)
|
|
321
319
|
}
|
|
322
320
|
|
|
@@ -1306,16 +1306,7 @@ export class JObjectInfer<
|
|
|
1306
1306
|
|
|
1307
1307
|
extend<NEW_PROPS extends Record<string, JSchema<any, any>>>(
|
|
1308
1308
|
props: NEW_PROPS,
|
|
1309
|
-
): JObjectInfer<
|
|
1310
|
-
{
|
|
1311
|
-
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS
|
|
1312
|
-
? NEW_PROPS[K]
|
|
1313
|
-
: K extends keyof PROPS
|
|
1314
|
-
? PROPS[K]
|
|
1315
|
-
: never
|
|
1316
|
-
},
|
|
1317
|
-
Opt
|
|
1318
|
-
> {
|
|
1309
|
+
): JObjectInfer<ExtendedProps<PROPS, NEW_PROPS>, Opt> {
|
|
1319
1310
|
const newBuilder = new JObjectInfer<PROPS, Opt>()
|
|
1320
1311
|
_objectAssign(newBuilder.schema, deepCopyPreservingFunctions(this.schema))
|
|
1321
1312
|
|
|
@@ -1327,16 +1318,7 @@ export class JObjectInfer<
|
|
|
1327
1318
|
// the new schema loses that quality.
|
|
1328
1319
|
_objectAssign(newBuilder.schema, { hasIsOfTypeCheck: false })
|
|
1329
1320
|
|
|
1330
|
-
return newBuilder as any as JObjectInfer<
|
|
1331
|
-
{
|
|
1332
|
-
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS
|
|
1333
|
-
? NEW_PROPS[K]
|
|
1334
|
-
: K extends keyof PROPS
|
|
1335
|
-
? PROPS[K]
|
|
1336
|
-
: never
|
|
1337
|
-
},
|
|
1338
|
-
Opt
|
|
1339
|
-
>
|
|
1321
|
+
return newBuilder as any as JObjectInfer<ExtendedProps<PROPS, NEW_PROPS>, Opt>
|
|
1340
1322
|
}
|
|
1341
1323
|
|
|
1342
1324
|
/**
|
|
@@ -2283,6 +2265,20 @@ type RelaxIndexSignature<T> = T extends readonly unknown[]
|
|
|
2283
2265
|
|
|
2284
2266
|
type Override<T, U> = Omit<T, keyof U> & U
|
|
2285
2267
|
|
|
2268
|
+
/**
|
|
2269
|
+
* Props of `JObjectInfer.extend()`: NEW_PROPS override PROPS with the same key.
|
|
2270
|
+
*
|
|
2271
|
+
* A named alias keeps the return type annotation and the cast in `extend()` identical.
|
|
2272
|
+
* TypeScript 7.1 reports two separately written copies of this mapped type as unrelated (TS2719).
|
|
2273
|
+
*/
|
|
2274
|
+
type ExtendedProps<PROPS, NEW_PROPS> = {
|
|
2275
|
+
[K in keyof PROPS | keyof NEW_PROPS]: K extends keyof NEW_PROPS
|
|
2276
|
+
? NEW_PROPS[K]
|
|
2277
|
+
: K extends keyof PROPS
|
|
2278
|
+
? PROPS[K]
|
|
2279
|
+
: never
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2286
2282
|
declare const allowExtraKeysSymbol: unique symbol
|
|
2287
2283
|
|
|
2288
2284
|
type HasAllowExtraKeys<T> = T extends { readonly [allowExtraKeysSymbol]?: true } ? true : false
|