@regle/schemas 1.7.1 → 1.8.0-beta.1
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/regle-schemas.d.ts +17 -424
- package/package.json +3 -3
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -1246,24 +1246,6 @@ type Not<T extends boolean> = T extends true ? false : true;
|
|
|
1246
1246
|
* {@linkcode Types} array is `true`, otherwise returns `false`.
|
|
1247
1247
|
*/
|
|
1248
1248
|
|
|
1249
|
-
/**
|
|
1250
|
-
* Checks if all the boolean types in the {@linkcode Types} array are `true`.
|
|
1251
|
-
*/
|
|
1252
|
-
type And<Types extends boolean[]> = Types[number] extends true ? true : false;
|
|
1253
|
-
/**
|
|
1254
|
-
* Represents an equality type that returns {@linkcode Right} if
|
|
1255
|
-
* {@linkcode Left} is `true`,
|
|
1256
|
-
* otherwise returns the negation of {@linkcode Right}.
|
|
1257
|
-
*/
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* @internal
|
|
1261
|
-
*/
|
|
1262
|
-
declare const secret: unique symbol;
|
|
1263
|
-
/**
|
|
1264
|
-
* @internal
|
|
1265
|
-
*/
|
|
1266
|
-
type Secret = typeof secret;
|
|
1267
1249
|
/**
|
|
1268
1250
|
* Checks if the given type is `never`.
|
|
1269
1251
|
*/
|
|
@@ -1271,47 +1253,7 @@ type IsNever$2<T> = [T] extends [never] ? true : false;
|
|
|
1271
1253
|
/**
|
|
1272
1254
|
* Checks if the given type is `any`.
|
|
1273
1255
|
*/
|
|
1274
|
-
type IsAny$2<T> = [T] extends [Secret] ? Not<IsNever$2<T>> : false;
|
|
1275
|
-
/**
|
|
1276
|
-
* Determines if the given type is `unknown`.
|
|
1277
|
-
*/
|
|
1278
|
-
type IsUnknown$1<T> = [unknown] extends [T] ? Not<IsAny$2<T>> : false;
|
|
1279
|
-
/**
|
|
1280
|
-
* Determines if a type is either `never` or `any`.
|
|
1281
|
-
*/
|
|
1282
1256
|
|
|
1283
|
-
/**
|
|
1284
|
-
* Subjective "useful" keys from a type. For objects it's just `keyof` but for
|
|
1285
|
-
* tuples/arrays it's the number keys.
|
|
1286
|
-
*
|
|
1287
|
-
* @example
|
|
1288
|
-
* ```ts
|
|
1289
|
-
* UsefulKeys<{ a: 1; b: 2 }> // 'a' | 'b'
|
|
1290
|
-
*
|
|
1291
|
-
* UsefulKeys<['a', 'b']> // '0' | '1'
|
|
1292
|
-
*
|
|
1293
|
-
* UsefulKeys<string[]> // number
|
|
1294
|
-
* ```
|
|
1295
|
-
*/
|
|
1296
|
-
type UsefulKeys<T> = T extends any[] ? { [K in keyof T]: K }[number] : keyof T;
|
|
1297
|
-
/**
|
|
1298
|
-
* Extracts the keys from a type that are required (not optional).
|
|
1299
|
-
*/
|
|
1300
|
-
type RequiredKeys<T> = Extract<{ [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T], keyof T>;
|
|
1301
|
-
/**
|
|
1302
|
-
* Gets the keys of an object type that are optional.
|
|
1303
|
-
*/
|
|
1304
|
-
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
|
1305
|
-
/**
|
|
1306
|
-
* Extracts the keys from a type that are not `readonly`.
|
|
1307
|
-
*/
|
|
1308
|
-
type ReadonlyKeys<T> = Extract<{ [K in keyof T]-?: ReadonlyEquivalent<{ [_K in K]: T[K] }, { -readonly [_K in K]: T[K] }> extends true ? never : K }[keyof T], keyof T>;
|
|
1309
|
-
/**
|
|
1310
|
-
* Determines if two types, are equivalent in a `readonly` manner.
|
|
1311
|
-
*
|
|
1312
|
-
* @internal
|
|
1313
|
-
*/
|
|
1314
|
-
type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (<T>() => T extends Y ? true : false)>;
|
|
1315
1257
|
/**
|
|
1316
1258
|
* Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
|
|
1317
1259
|
* 1. If either type is `never`, the result is `true` iff the other type is also `never`.
|
|
@@ -1323,24 +1265,6 @@ type Extends<Left, Right> = IsNever$2<Left> extends true ? IsNever$2<Right> : [L
|
|
|
1323
1265
|
* excluding `any` or `never`.
|
|
1324
1266
|
*/
|
|
1325
1267
|
|
|
1326
|
-
/**
|
|
1327
|
-
* Checks if two types are strictly equal using
|
|
1328
|
-
* the TypeScript internal identical-to operator.
|
|
1329
|
-
*
|
|
1330
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/55188#issuecomment-1656328122 | much history}
|
|
1331
|
-
*/
|
|
1332
|
-
type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends (<T>() => T extends (R & T) | T ? true : false) ? IsNever$2<L> extends IsNever$2<R> ? true : false : false;
|
|
1333
|
-
/**
|
|
1334
|
-
* Checks that {@linkcode Left} and {@linkcode Right} extend each other.
|
|
1335
|
-
* Not quite the same as an equality check since `any` can make it resolve
|
|
1336
|
-
* to `true`. So should only be used when {@linkcode Left} and
|
|
1337
|
-
* {@linkcode Right} are known to avoid `any`.
|
|
1338
|
-
*/
|
|
1339
|
-
type MutuallyExtends<Left, Right> = And<[Extends<Left, Right>, Extends<Right, Left>]>;
|
|
1340
|
-
/**
|
|
1341
|
-
* @internal
|
|
1342
|
-
*/
|
|
1343
|
-
|
|
1344
1268
|
/**
|
|
1345
1269
|
* Convert a union to an intersection.
|
|
1346
1270
|
* `A | B | C` -\> `A & B & C`
|
|
@@ -1375,344 +1299,6 @@ type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
|
1375
1299
|
* ```
|
|
1376
1300
|
*/
|
|
1377
1301
|
//#endregion
|
|
1378
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/overloads.d.ts
|
|
1379
|
-
/**
|
|
1380
|
-
* The simple(ish) way to get overload info from a function
|
|
1381
|
-
* {@linkcode FunctionType}. Recent versions of TypeScript will match any
|
|
1382
|
-
* function against a generic 10-overload type, filling in slots with
|
|
1383
|
-
* duplicates of the function. So, we can just match against a single type
|
|
1384
|
-
* and get all the overloads.
|
|
1385
|
-
*
|
|
1386
|
-
* For older versions of TypeScript, we'll need to painstakingly do
|
|
1387
|
-
* ten separate matches.
|
|
1388
|
-
*/
|
|
1389
|
-
type TSPost53OverloadsInfoUnion<FunctionType> = FunctionType extends {
|
|
1390
|
-
(...args: infer A1): infer R1;
|
|
1391
|
-
(...args: infer A2): infer R2;
|
|
1392
|
-
(...args: infer A3): infer R3;
|
|
1393
|
-
(...args: infer A4): infer R4;
|
|
1394
|
-
(...args: infer A5): infer R5;
|
|
1395
|
-
(...args: infer A6): infer R6;
|
|
1396
|
-
(...args: infer A7): infer R7;
|
|
1397
|
-
(...args: infer A8): infer R8;
|
|
1398
|
-
(...args: infer A9): infer R9;
|
|
1399
|
-
(...args: infer A10): infer R10;
|
|
1400
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) | ((...p: A10) => R10) : never;
|
|
1401
|
-
/**
|
|
1402
|
-
* A function with `unknown` parameters and return type.
|
|
1403
|
-
*/
|
|
1404
|
-
type UnknownFunction = (...args: unknown[]) => unknown;
|
|
1405
|
-
/**
|
|
1406
|
-
* `true` iff {@linkcode FunctionType} is
|
|
1407
|
-
* equivalent to `(...args: unknown[]) => unknown`,
|
|
1408
|
-
* which is what an overload variant looks like for a non-existent overload.
|
|
1409
|
-
* This is useful because older versions of TypeScript end up with
|
|
1410
|
-
* 9 "useless" overloads and one real one for parameterless/generic functions.
|
|
1411
|
-
*
|
|
1412
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
|
|
1413
|
-
*/
|
|
1414
|
-
type IsUselessOverloadInfo<FunctionType> = StrictEqualUsingTSInternalIdenticalToOperator<FunctionType, UnknownFunction>;
|
|
1415
|
-
/**
|
|
1416
|
-
* Old versions of TypeScript can sometimes seem to refuse to separate out
|
|
1417
|
-
* union members unless you put them each in a pointless tuple and add an
|
|
1418
|
-
* extra `infer X` expression. There may be a better way to work around this
|
|
1419
|
-
* problem, but since it's not a problem in newer versions of TypeScript,
|
|
1420
|
-
* it's not a priority right now.
|
|
1421
|
-
*/
|
|
1422
|
-
type Tuplify<Union> = Union extends infer X ? [X] : never;
|
|
1423
|
-
/**
|
|
1424
|
-
* For older versions of TypeScript, we need two separate workarounds
|
|
1425
|
-
* to get overload info. First, we need need to use
|
|
1426
|
-
* {@linkcode DecreasingOverloadsInfoUnion} to get the overload info for
|
|
1427
|
-
* functions with 1-10 overloads. Then, we need to filter out the
|
|
1428
|
-
* "useless" overloads that are present in older versions of TypeScript,
|
|
1429
|
-
* for parameterless functions. To do this we use
|
|
1430
|
-
* {@linkcode IsUselessOverloadInfo} to remove useless overloads.
|
|
1431
|
-
*
|
|
1432
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
|
|
1433
|
-
*/
|
|
1434
|
-
type TSPre53OverloadsInfoUnion<FunctionType> = Tuplify<DecreasingOverloadsInfoUnion<FunctionType>> extends infer Tup ? Tup extends [infer Fn] ? IsUselessOverloadInfo<Fn> extends true ? never : Fn : never : never;
|
|
1435
|
-
/**
|
|
1436
|
-
* For versions of TypeScript below 5.3, we need to check for 10 overloads,
|
|
1437
|
-
* then 9, then 8, etc., to get a union of the overload variants.
|
|
1438
|
-
*/
|
|
1439
|
-
type DecreasingOverloadsInfoUnion<F> = F extends {
|
|
1440
|
-
(...args: infer A1): infer R1;
|
|
1441
|
-
(...args: infer A2): infer R2;
|
|
1442
|
-
(...args: infer A3): infer R3;
|
|
1443
|
-
(...args: infer A4): infer R4;
|
|
1444
|
-
(...args: infer A5): infer R5;
|
|
1445
|
-
(...args: infer A6): infer R6;
|
|
1446
|
-
(...args: infer A7): infer R7;
|
|
1447
|
-
(...args: infer A8): infer R8;
|
|
1448
|
-
(...args: infer A9): infer R9;
|
|
1449
|
-
(...args: infer A10): infer R10;
|
|
1450
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) | ((...p: A10) => R10) : F extends {
|
|
1451
|
-
(...args: infer A1): infer R1;
|
|
1452
|
-
(...args: infer A2): infer R2;
|
|
1453
|
-
(...args: infer A3): infer R3;
|
|
1454
|
-
(...args: infer A4): infer R4;
|
|
1455
|
-
(...args: infer A5): infer R5;
|
|
1456
|
-
(...args: infer A6): infer R6;
|
|
1457
|
-
(...args: infer A7): infer R7;
|
|
1458
|
-
(...args: infer A8): infer R8;
|
|
1459
|
-
(...args: infer A9): infer R9;
|
|
1460
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) : F extends {
|
|
1461
|
-
(...args: infer A1): infer R1;
|
|
1462
|
-
(...args: infer A2): infer R2;
|
|
1463
|
-
(...args: infer A3): infer R3;
|
|
1464
|
-
(...args: infer A4): infer R4;
|
|
1465
|
-
(...args: infer A5): infer R5;
|
|
1466
|
-
(...args: infer A6): infer R6;
|
|
1467
|
-
(...args: infer A7): infer R7;
|
|
1468
|
-
(...args: infer A8): infer R8;
|
|
1469
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) : F extends {
|
|
1470
|
-
(...args: infer A1): infer R1;
|
|
1471
|
-
(...args: infer A2): infer R2;
|
|
1472
|
-
(...args: infer A3): infer R3;
|
|
1473
|
-
(...args: infer A4): infer R4;
|
|
1474
|
-
(...args: infer A5): infer R5;
|
|
1475
|
-
(...args: infer A6): infer R6;
|
|
1476
|
-
(...args: infer A7): infer R7;
|
|
1477
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) : F extends {
|
|
1478
|
-
(...args: infer A1): infer R1;
|
|
1479
|
-
(...args: infer A2): infer R2;
|
|
1480
|
-
(...args: infer A3): infer R3;
|
|
1481
|
-
(...args: infer A4): infer R4;
|
|
1482
|
-
(...args: infer A5): infer R5;
|
|
1483
|
-
(...args: infer A6): infer R6;
|
|
1484
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) : F extends {
|
|
1485
|
-
(...args: infer A1): infer R1;
|
|
1486
|
-
(...args: infer A2): infer R2;
|
|
1487
|
-
(...args: infer A3): infer R3;
|
|
1488
|
-
(...args: infer A4): infer R4;
|
|
1489
|
-
(...args: infer A5): infer R5;
|
|
1490
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) : F extends {
|
|
1491
|
-
(...args: infer A1): infer R1;
|
|
1492
|
-
(...args: infer A2): infer R2;
|
|
1493
|
-
(...args: infer A3): infer R3;
|
|
1494
|
-
(...args: infer A4): infer R4;
|
|
1495
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) : F extends {
|
|
1496
|
-
(...args: infer A1): infer R1;
|
|
1497
|
-
(...args: infer A2): infer R2;
|
|
1498
|
-
(...args: infer A3): infer R3;
|
|
1499
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) : F extends {
|
|
1500
|
-
(...args: infer A1): infer R1;
|
|
1501
|
-
(...args: infer A2): infer R2;
|
|
1502
|
-
} ? ((...p: A1) => R1) | ((...p: A2) => R2) : F extends ((...args: infer A1) => infer R1) ? ((...p: A1) => R1) : never;
|
|
1503
|
-
/**
|
|
1504
|
-
* Get a union of overload variants for a function {@linkcode FunctionType}.
|
|
1505
|
-
* Does a check for whether we can do the one-shot
|
|
1506
|
-
* 10-overload matcher (which works for ts\>5.3), and if not,
|
|
1507
|
-
* falls back to the more complicated utility.
|
|
1508
|
-
*/
|
|
1509
|
-
type OverloadsInfoUnion<FunctionType> = IsNever$2<TSPost53OverloadsInfoUnion<(a: 1) => 2>> extends true ? TSPre53OverloadsInfoUnion<FunctionType> : TSPost53OverloadsInfoUnion<FunctionType>;
|
|
1510
|
-
/**
|
|
1511
|
-
* Allows inferring any function using the `infer` keyword.
|
|
1512
|
-
*/
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* The simple(ish) way to get overload info from a constructor
|
|
1516
|
-
* {@linkcode ConstructorType}. Recent versions of TypeScript will match any
|
|
1517
|
-
* constructor against a generic 10-overload type, filling in slots with
|
|
1518
|
-
* duplicates of the constructor. So, we can just match against a single type
|
|
1519
|
-
* and get all the overloads.
|
|
1520
|
-
*
|
|
1521
|
-
* For older versions of TypeScript,
|
|
1522
|
-
* we'll need to painstakingly do ten separate matches.
|
|
1523
|
-
*/
|
|
1524
|
-
type TSPost53ConstructorOverloadsInfoUnion<ConstructorType> = ConstructorType extends {
|
|
1525
|
-
new (...args: infer A1): infer R1;
|
|
1526
|
-
new (...args: infer A2): infer R2;
|
|
1527
|
-
new (...args: infer A3): infer R3;
|
|
1528
|
-
new (...args: infer A4): infer R4;
|
|
1529
|
-
new (...args: infer A5): infer R5;
|
|
1530
|
-
new (...args: infer A6): infer R6;
|
|
1531
|
-
new (...args: infer A7): infer R7;
|
|
1532
|
-
new (...args: infer A8): infer R8;
|
|
1533
|
-
new (...args: infer A9): infer R9;
|
|
1534
|
-
new (...args: infer A10): infer R10;
|
|
1535
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) | (new (...p: A10) => R10) : never;
|
|
1536
|
-
/**
|
|
1537
|
-
* A constructor function with `unknown` parameters and return type.
|
|
1538
|
-
*/
|
|
1539
|
-
type UnknownConstructor = new (...args: unknown[]) => unknown;
|
|
1540
|
-
/**
|
|
1541
|
-
* Same as {@linkcode IsUselessOverloadInfo}, but for constructors.
|
|
1542
|
-
*/
|
|
1543
|
-
type IsUselessConstructorOverloadInfo<FunctionType> = StrictEqualUsingTSInternalIdenticalToOperator<FunctionType, UnknownConstructor>;
|
|
1544
|
-
/**
|
|
1545
|
-
* For older versions of TypeScript, we need two separate workarounds to
|
|
1546
|
-
* get constructor overload info. First, we need need to use
|
|
1547
|
-
* {@linkcode DecreasingConstructorOverloadsInfoUnion} to get the overload
|
|
1548
|
-
* info for constructors with 1-10 overloads. Then, we need to filter out the
|
|
1549
|
-
* "useless" overloads that are present in older versions of TypeScript,
|
|
1550
|
-
* for parameterless constructors. To do this we use
|
|
1551
|
-
* {@linkcode IsUselessConstructorOverloadInfo} to remove useless overloads.
|
|
1552
|
-
*
|
|
1553
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
|
|
1554
|
-
*/
|
|
1555
|
-
type TSPre53ConstructorOverloadsInfoUnion<ConstructorType> = Tuplify<DecreasingConstructorOverloadsInfoUnion<ConstructorType>> extends infer Tup ? Tup extends [infer Ctor] ? IsUselessConstructorOverloadInfo<Ctor> extends true ? never : Ctor : never : never;
|
|
1556
|
-
/**
|
|
1557
|
-
* For versions of TypeScript below 5.3, we need to check for 10 overloads,
|
|
1558
|
-
* then 9, then 8, etc., to get a union of the overload variants.
|
|
1559
|
-
*/
|
|
1560
|
-
type DecreasingConstructorOverloadsInfoUnion<ConstructorType> = ConstructorType extends {
|
|
1561
|
-
new (...args: infer A1): infer R1;
|
|
1562
|
-
new (...args: infer A2): infer R2;
|
|
1563
|
-
new (...args: infer A3): infer R3;
|
|
1564
|
-
new (...args: infer A4): infer R4;
|
|
1565
|
-
new (...args: infer A5): infer R5;
|
|
1566
|
-
new (...args: infer A6): infer R6;
|
|
1567
|
-
new (...args: infer A7): infer R7;
|
|
1568
|
-
new (...args: infer A8): infer R8;
|
|
1569
|
-
new (...args: infer A9): infer R9;
|
|
1570
|
-
new (...args: infer A10): infer R10;
|
|
1571
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) | (new (...p: A10) => R10) : ConstructorType extends {
|
|
1572
|
-
new (...args: infer A1): infer R1;
|
|
1573
|
-
new (...args: infer A2): infer R2;
|
|
1574
|
-
new (...args: infer A3): infer R3;
|
|
1575
|
-
new (...args: infer A4): infer R4;
|
|
1576
|
-
new (...args: infer A5): infer R5;
|
|
1577
|
-
new (...args: infer A6): infer R6;
|
|
1578
|
-
new (...args: infer A7): infer R7;
|
|
1579
|
-
new (...args: infer A8): infer R8;
|
|
1580
|
-
new (...args: infer A9): infer R9;
|
|
1581
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) : ConstructorType extends {
|
|
1582
|
-
new (...args: infer A1): infer R1;
|
|
1583
|
-
new (...args: infer A2): infer R2;
|
|
1584
|
-
new (...args: infer A3): infer R3;
|
|
1585
|
-
new (...args: infer A4): infer R4;
|
|
1586
|
-
new (...args: infer A5): infer R5;
|
|
1587
|
-
new (...args: infer A6): infer R6;
|
|
1588
|
-
new (...args: infer A7): infer R7;
|
|
1589
|
-
new (...args: infer A8): infer R8;
|
|
1590
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) : ConstructorType extends {
|
|
1591
|
-
new (...args: infer A1): infer R1;
|
|
1592
|
-
new (...args: infer A2): infer R2;
|
|
1593
|
-
new (...args: infer A3): infer R3;
|
|
1594
|
-
new (...args: infer A4): infer R4;
|
|
1595
|
-
new (...args: infer A5): infer R5;
|
|
1596
|
-
new (...args: infer A6): infer R6;
|
|
1597
|
-
new (...args: infer A7): infer R7;
|
|
1598
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) : ConstructorType extends {
|
|
1599
|
-
new (...args: infer A1): infer R1;
|
|
1600
|
-
new (...args: infer A2): infer R2;
|
|
1601
|
-
new (...args: infer A3): infer R3;
|
|
1602
|
-
new (...args: infer A4): infer R4;
|
|
1603
|
-
new (...args: infer A5): infer R5;
|
|
1604
|
-
new (...args: infer A6): infer R6;
|
|
1605
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) : ConstructorType extends {
|
|
1606
|
-
new (...args: infer A1): infer R1;
|
|
1607
|
-
new (...args: infer A2): infer R2;
|
|
1608
|
-
new (...args: infer A3): infer R3;
|
|
1609
|
-
new (...args: infer A4): infer R4;
|
|
1610
|
-
new (...args: infer A5): infer R5;
|
|
1611
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) : ConstructorType extends {
|
|
1612
|
-
new (...args: infer A1): infer R1;
|
|
1613
|
-
new (...args: infer A2): infer R2;
|
|
1614
|
-
new (...args: infer A3): infer R3;
|
|
1615
|
-
new (...args: infer A4): infer R4;
|
|
1616
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) : ConstructorType extends {
|
|
1617
|
-
new (...args: infer A1): infer R1;
|
|
1618
|
-
new (...args: infer A2): infer R2;
|
|
1619
|
-
new (...args: infer A3): infer R3;
|
|
1620
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) : ConstructorType extends {
|
|
1621
|
-
new (...args: infer A1): infer R1;
|
|
1622
|
-
new (...args: infer A2): infer R2;
|
|
1623
|
-
} ? (new (...p: A1) => R1) | (new (...p: A2) => R2) : ConstructorType extends (new (...args: infer A1) => infer R1) ? (new (...p: A1) => R1) : never;
|
|
1624
|
-
/**
|
|
1625
|
-
* Get a union of overload variants for a constructor
|
|
1626
|
-
* {@linkcode ConstructorType}. Does a check for whether we can do the
|
|
1627
|
-
* one-shot 10-overload matcher (which works for ts\>5.3), and if not,
|
|
1628
|
-
* falls back to the more complicated utility.
|
|
1629
|
-
*/
|
|
1630
|
-
type ConstructorOverloadsUnion<ConstructorType> = IsNever$2<TSPost53ConstructorOverloadsInfoUnion<new (a: 1) => any>> extends true ? TSPre53ConstructorOverloadsInfoUnion<ConstructorType> : TSPost53ConstructorOverloadsInfoUnion<ConstructorType>;
|
|
1631
|
-
/**
|
|
1632
|
-
* Allows inferring any constructor using the `infer` keyword.
|
|
1633
|
-
*/
|
|
1634
|
-
type InferConstructor<ConstructorType extends new (...args: any) => any> = ConstructorType;
|
|
1635
|
-
/**
|
|
1636
|
-
* A union type of the parameters allowed for any overload
|
|
1637
|
-
* of constructor {@linkcode ConstructorType}.
|
|
1638
|
-
*/
|
|
1639
|
-
type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<ConstructorType> extends InferConstructor<infer Ctor> ? ConstructorParameters<Ctor> : never;
|
|
1640
|
-
/**
|
|
1641
|
-
* Calculates the number of overloads for a given function type.
|
|
1642
|
-
*/
|
|
1643
|
-
type NumOverloads<FunctionType> = UnionToTuple$1<OverloadsInfoUnion<FunctionType>>['length'];
|
|
1644
|
-
//#endregion
|
|
1645
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/branding.d.ts
|
|
1646
|
-
/**
|
|
1647
|
-
* Represents a deeply branded type.
|
|
1648
|
-
*
|
|
1649
|
-
* Recursively walk a type and replace it with a branded type related to the
|
|
1650
|
-
* original. This is useful for equality-checking stricter than
|
|
1651
|
-
* `A extends B ? B extends A ? true : false : false`, because it detects the
|
|
1652
|
-
* difference between a few edge-case types that vanilla TypeScript
|
|
1653
|
-
* doesn't by default:
|
|
1654
|
-
* - `any` vs `unknown`
|
|
1655
|
-
* - `{ readonly a: string }` vs `{ a: string }`
|
|
1656
|
-
* - `{ a?: string }` vs `{ a: string | undefined }`
|
|
1657
|
-
*
|
|
1658
|
-
* __Note__: not very performant for complex types - this should only be used
|
|
1659
|
-
* when you know you need it. If doing an equality check, it's almost always
|
|
1660
|
-
* better to use {@linkcode StrictEqualUsingTSInternalIdenticalToOperator}.
|
|
1661
|
-
*/
|
|
1662
|
-
type DeepBrand<T> = IsNever$2<T> extends true ? {
|
|
1663
|
-
type: 'never';
|
|
1664
|
-
} : IsAny$2<T> extends true ? {
|
|
1665
|
-
type: 'any';
|
|
1666
|
-
} : IsUnknown$1<T> extends true ? {
|
|
1667
|
-
type: 'unknown';
|
|
1668
|
-
} : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
|
|
1669
|
-
type: 'primitive';
|
|
1670
|
-
value: T;
|
|
1671
|
-
} : T extends (new (...args: any[]) => any) ? {
|
|
1672
|
-
type: 'constructor';
|
|
1673
|
-
params: ConstructorOverloadParameters<T>;
|
|
1674
|
-
instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>;
|
|
1675
|
-
} : T extends ((...args: infer P) => infer R) ? NumOverloads<T> extends 1 ? {
|
|
1676
|
-
type: 'function';
|
|
1677
|
-
params: DeepBrand<P>;
|
|
1678
|
-
return: DeepBrand<R>;
|
|
1679
|
-
this: DeepBrand<ThisParameterType<T>>;
|
|
1680
|
-
props: DeepBrand<Omit<T, keyof Function>>;
|
|
1681
|
-
} : UnionToTuple$1<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
|
|
1682
|
-
type: 'overloads';
|
|
1683
|
-
overloads: { [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]> };
|
|
1684
|
-
} : never : T extends any[] ? {
|
|
1685
|
-
type: 'array';
|
|
1686
|
-
items: { [K in keyof T]: T[K] };
|
|
1687
|
-
} : {
|
|
1688
|
-
type: 'object';
|
|
1689
|
-
properties: { [K in keyof T]: DeepBrand<T[K]> };
|
|
1690
|
-
readonly: ReadonlyKeys<T>;
|
|
1691
|
-
required: RequiredKeys<T>;
|
|
1692
|
-
optional: OptionalKeys<T>;
|
|
1693
|
-
constructorParams: DeepBrand<ConstructorOverloadParameters<T>>;
|
|
1694
|
-
};
|
|
1695
|
-
/**
|
|
1696
|
-
* Checks if two types are strictly equal using branding.
|
|
1697
|
-
*/
|
|
1698
|
-
type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
|
|
1699
|
-
//#endregion
|
|
1700
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/messages.d.ts
|
|
1701
|
-
/**
|
|
1702
|
-
* Determines the printable type representation for a given type.
|
|
1703
|
-
*/
|
|
1704
|
-
type PrintType<T> = IsUnknown$1<T> extends true ? 'unknown' : IsNever$2<T> extends true ? 'never' : IsAny$2<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : bigint extends T ? 'bigint' : T extends bigint ? `literal bigint: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends ((...args: any[]) => any) ? 'function' : '...';
|
|
1705
|
-
/**
|
|
1706
|
-
* Helper for showing end-user a hint why their type assertion is failing.
|
|
1707
|
-
* This swaps "leaf" types with a literal message about what the actual and
|
|
1708
|
-
* expected types are. Needs to check for `Not<IsAny<Actual>>` because
|
|
1709
|
-
* otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
|
|
1710
|
-
*/
|
|
1711
|
-
type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, Not<IsAny$2<Actual>>]> extends true ? And<[Extends<any[], Actual>, Extends<any[], Expected>]> extends true ? Array<MismatchInfo<Extract<Actual, any[]>[number], Extract<Expected, any[]>[number]>> : { [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never> } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `Expected: ${PrintType<Expected>}, Actual: ${PrintType<Exclude<Actual, Expected>>}`;
|
|
1712
|
-
/**
|
|
1713
|
-
* @internal
|
|
1714
|
-
*/
|
|
1715
|
-
//#endregion
|
|
1716
1302
|
//#region src/types/core/variants.types.d.ts
|
|
1717
1303
|
|
|
1718
1304
|
type MaybeVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleStatus<TState, TRules, TShortcuts>, '$fields' | keyof RegleStatus<TState, TRules, TShortcuts>['$fields']> & {
|
|
@@ -1722,9 +1308,9 @@ type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRule
|
|
|
1722
1308
|
type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
|
|
1723
1309
|
//#endregion
|
|
1724
1310
|
//#region src/core/useRegle/useRegle.d.ts
|
|
1725
|
-
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations
|
|
1311
|
+
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends DeepExact<TRules, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations>>>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends MaybeInput<PrimitiveTypes> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? (TRules extends Record<string, any> ? TRules : {}) : {}, TValidationGroups> & TAdditionalOptions;
|
|
1726
1312
|
interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
1727
|
-
<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules
|
|
1313
|
+
<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends DeepExact<TRules, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<MaybeRef<TState> | DeepReactiveState<TState>>, rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleField<NonNullable<TState>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules extends Record<string, any> ? TRules : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
|
|
1728
1314
|
__config?: {
|
|
1729
1315
|
rules?: () => CustomRulesDeclarationTree;
|
|
1730
1316
|
modifiers?: RegleBehaviourOptions;
|
|
@@ -1751,6 +1337,21 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
|
|
|
1751
1337
|
* Docs: {@link https://reglejs.dev/core-concepts/}
|
|
1752
1338
|
*/
|
|
1753
1339
|
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region src/types/utils/mismatch.types.d.ts
|
|
1342
|
+
/**
|
|
1343
|
+
/**
|
|
1344
|
+
* DeepExact<T, S> is a TypeScript utility type that recursively checks whether the structure of type S
|
|
1345
|
+
* exactly matches the structure of type T, including all nested properties.
|
|
1346
|
+
*
|
|
1347
|
+
* Used in `useRegle` and `inferRules` to enforce that the rules object matches the expected shape exactly.
|
|
1348
|
+
*/
|
|
1349
|
+
type DeepExact<T, S> = NonNullable<S> extends MaybeRef<RegleRuleDecl> ? S : NonNullable<S> extends MaybeRef<RegleCollectionRuleDecl> ? S : [keyof T] extends [keyof ExtractFromGetter<S>] ? ExactObject<T, S> : { [K in keyof T as K extends keyof S ? never : K]: TypeError<`Unknown property: <${Coerce<K>}>`> };
|
|
1350
|
+
type ExactObject<T, S> = { [K in keyof S]: ExtendOnlyRealRecord<S[K]> extends true ? NonNullable<S[K]> extends MaybeRef<RegleRuleDecl> ? S[K] : K extends keyof T ? DeepExact<T[K], NonNullable<S[K]>> : S[K] : S[K] };
|
|
1351
|
+
type TypeError<Msg> = {
|
|
1352
|
+
[' TypeError']: Msg;
|
|
1353
|
+
};
|
|
1354
|
+
type Coerce<T> = `${T & string}`;
|
|
1754
1355
|
//#endregion
|
|
1755
1356
|
//#region src/types/utils/object.types.d.ts
|
|
1756
1357
|
type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
|
|
@@ -1793,10 +1394,6 @@ type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
|
1793
1394
|
type HasNamedKeys<T> = IsUnion<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
|
|
1794
1395
|
type ProcessHasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
|
|
1795
1396
|
//#endregion
|
|
1796
|
-
//#region src/types/utils/mismatch.types.d.ts
|
|
1797
|
-
type isDeepExact<TRules, TTree> = { [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never> }[keyof TRules] extends true ? true : false;
|
|
1798
|
-
type CheckDeepExact<TRules, TTree> = [TTree] extends [never] ? false : TRules extends RegleCollectionRuleDecl ? TTree extends Array<any> ? isDeepExact<NonNullable<TRules['$each']>, JoinDiscriminatedUnions<NonNullable<ArrayElement$1<TTree>>>> : TRules extends MaybeRef<RegleRuleDecl> ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<UnwrapRef<TRules>, TTree> : false : TRules extends MaybeRef<RegleRuleDecl> ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<UnwrapRef<TRules>, TTree> : false;
|
|
1799
|
-
//#endregion
|
|
1800
1397
|
//#region src/types/utils/infer.types.d.ts
|
|
1801
1398
|
|
|
1802
1399
|
//#endregion
|
|
@@ -2012,10 +1609,6 @@ type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
|
|
|
2012
1609
|
* @public
|
|
2013
1610
|
*/
|
|
2014
1611
|
type ReglePartialRuleTree<TForm extends Record<string, any> = Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = { [TKey in keyof TForm]?: RegleFormPropertyType<TForm[TKey], TCustomRules> };
|
|
2015
|
-
/**
|
|
2016
|
-
* @public
|
|
2017
|
-
*/
|
|
2018
|
-
type RegleRuleTree<TForm extends Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = { [TKey in keyof TForm]: RegleFormPropertyType<TForm[TKey], TCustomRules> };
|
|
2019
1612
|
/**
|
|
2020
1613
|
* @public
|
|
2021
1614
|
*/
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-beta.1",
|
|
4
4
|
"description": "Schemas adapter for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@standard-schema/spec": "1.0.0",
|
|
7
|
-
"@regle/core": "1.
|
|
8
|
-
"@regle/rules": "1.
|
|
7
|
+
"@regle/core": "1.8.0-beta.1",
|
|
8
|
+
"@regle/rules": "1.8.0-beta.1"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"valibot": "^1.0.0",
|