@regle/core 1.7.2 → 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.
Files changed (2) hide show
  1. package/dist/regle-core.d.ts +23 -426
  2. package/package.json +1 -1
@@ -330,7 +330,7 @@ const anyA = get(anyObject, 'a');
330
330
  @category Type Guard
331
331
  @category Utilities
332
332
  */
333
- type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
333
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
334
334
  //#endregion
335
335
  //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-equal.d.ts
336
336
  /**
@@ -653,7 +653,7 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
653
653
  @category Type Guard
654
654
  @category Utilities
655
655
  */
656
- type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
656
+ type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
657
657
  //#endregion
658
658
  //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
659
659
  /**
@@ -725,7 +725,7 @@ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
725
725
  //=> 'IS_NEVER'
726
726
  ```
727
727
  */
728
- type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny$1<T> extends true ? IfAny : IsNever$1<T> extends true ? IfNever : IfNotAnyOrNever;
728
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever$1<T> extends true ? IfNever : IfNotAnyOrNever;
729
729
  //#endregion
730
730
  //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
731
731
  /**
@@ -1292,10 +1292,10 @@ type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
1292
1292
  type PartialFormState<TState extends Record<string, any>> = [unknown] extends [TState] ? {} : Prettify<{ [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? never : TState[K] extends Array<any> ? never : K]?: MaybeOutput<TState[K]> } & { [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? K : TState[K] extends Array<any> ? K : never]: NonNullable<TState[K]> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : PartialFormState<TState[K]> }>;
1293
1293
  type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = {
1294
1294
  valid: false;
1295
- data: IsUnknown<Data> extends true ? unknown : IsAny$1<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? NonNullable<Data> extends Date | File ? MaybeOutput<Data> : NonNullable<Data> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : NonNullable<Data> extends Record<string, any> ? PartialFormState<NonNullable<Data>> : MaybeOutput<Data> : unknown;
1295
+ data: IsUnknown<Data> extends true ? unknown : IsAny<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? NonNullable<Data> extends Date | File ? MaybeOutput<Data> : NonNullable<Data> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : NonNullable<Data> extends Record<string, any> ? PartialFormState<NonNullable<Data>> : MaybeOutput<Data> : unknown;
1296
1296
  } | {
1297
1297
  valid: true;
1298
- data: IsUnknown<Data> extends true ? unknown : IsAny$1<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? Data extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, TRules>[] : Data extends Date | File ? SafeFieldProperty<Data, TRules> : Data extends Record<string, any> ? DeepSafeFormState<Data, TRules> : SafeFieldProperty<Data, TRules> : unknown;
1298
+ data: IsUnknown<Data> extends true ? unknown : IsAny<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? Data extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, TRules>[] : Data extends Date | File ? SafeFieldProperty<Data, TRules> : Data extends Record<string, any> ? DeepSafeFormState<Data, TRules> : SafeFieldProperty<Data, TRules> : unknown;
1299
1299
  };
1300
1300
  /**
1301
1301
  * Infer safe output from any `r$` instance
@@ -1327,24 +1327,6 @@ type Not<T extends boolean> = T extends true ? false : true;
1327
1327
  * {@linkcode Types} array is `true`, otherwise returns `false`.
1328
1328
  */
1329
1329
 
1330
- /**
1331
- * Checks if all the boolean types in the {@linkcode Types} array are `true`.
1332
- */
1333
- type And<Types extends boolean[]> = Types[number] extends true ? true : false;
1334
- /**
1335
- * Represents an equality type that returns {@linkcode Right} if
1336
- * {@linkcode Left} is `true`,
1337
- * otherwise returns the negation of {@linkcode Right}.
1338
- */
1339
-
1340
- /**
1341
- * @internal
1342
- */
1343
- declare const secret: unique symbol;
1344
- /**
1345
- * @internal
1346
- */
1347
- type Secret = typeof secret;
1348
1330
  /**
1349
1331
  * Checks if the given type is `never`.
1350
1332
  */
@@ -1352,47 +1334,7 @@ type IsNever<T> = [T] extends [never] ? true : false;
1352
1334
  /**
1353
1335
  * Checks if the given type is `any`.
1354
1336
  */
1355
- type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
1356
- /**
1357
- * Determines if the given type is `unknown`.
1358
- */
1359
- type IsUnknown$1<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
1360
- /**
1361
- * Determines if a type is either `never` or `any`.
1362
- */
1363
1337
 
1364
- /**
1365
- * Subjective "useful" keys from a type. For objects it's just `keyof` but for
1366
- * tuples/arrays it's the number keys.
1367
- *
1368
- * @example
1369
- * ```ts
1370
- * UsefulKeys<{ a: 1; b: 2 }> // 'a' | 'b'
1371
- *
1372
- * UsefulKeys<['a', 'b']> // '0' | '1'
1373
- *
1374
- * UsefulKeys<string[]> // number
1375
- * ```
1376
- */
1377
- type UsefulKeys<T> = T extends any[] ? { [K in keyof T]: K }[number] : keyof T;
1378
- /**
1379
- * Extracts the keys from a type that are required (not optional).
1380
- */
1381
- type RequiredKeys<T> = Extract<{ [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T], keyof T>;
1382
- /**
1383
- * Gets the keys of an object type that are optional.
1384
- */
1385
- type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
1386
- /**
1387
- * Extracts the keys from a type that are not `readonly`.
1388
- */
1389
- 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>;
1390
- /**
1391
- * Determines if two types, are equivalent in a `readonly` manner.
1392
- *
1393
- * @internal
1394
- */
1395
- type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (<T>() => T extends Y ? true : false)>;
1396
1338
  /**
1397
1339
  * Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
1398
1340
  * 1. If either type is `never`, the result is `true` iff the other type is also `never`.
@@ -1404,24 +1346,6 @@ type Extends<Left, Right> = IsNever<Left> extends true ? IsNever<Right> : [Left]
1404
1346
  * excluding `any` or `never`.
1405
1347
  */
1406
1348
 
1407
- /**
1408
- * Checks if two types are strictly equal using
1409
- * the TypeScript internal identical-to operator.
1410
- *
1411
- * @see {@link https://github.com/microsoft/TypeScript/issues/55188#issuecomment-1656328122 | much history}
1412
- */
1413
- type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends (<T>() => T extends (R & T) | T ? true : false) ? IsNever<L> extends IsNever<R> ? true : false : false;
1414
- /**
1415
- * Checks that {@linkcode Left} and {@linkcode Right} extend each other.
1416
- * Not quite the same as an equality check since `any` can make it resolve
1417
- * to `true`. So should only be used when {@linkcode Left} and
1418
- * {@linkcode Right} are known to avoid `any`.
1419
- */
1420
- type MutuallyExtends<Left, Right> = And<[Extends<Left, Right>, Extends<Right, Left>]>;
1421
- /**
1422
- * @internal
1423
- */
1424
-
1425
1349
  /**
1426
1350
  * Convert a union to an intersection.
1427
1351
  * `A | B | C` -\> `A & B & C`
@@ -1456,344 +1380,6 @@ type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
1456
1380
  * ```
1457
1381
  */
1458
1382
  //#endregion
1459
- //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/overloads.d.ts
1460
- /**
1461
- * The simple(ish) way to get overload info from a function
1462
- * {@linkcode FunctionType}. Recent versions of TypeScript will match any
1463
- * function against a generic 10-overload type, filling in slots with
1464
- * duplicates of the function. So, we can just match against a single type
1465
- * and get all the overloads.
1466
- *
1467
- * For older versions of TypeScript, we'll need to painstakingly do
1468
- * ten separate matches.
1469
- */
1470
- type TSPost53OverloadsInfoUnion<FunctionType> = FunctionType extends {
1471
- (...args: infer A1): infer R1;
1472
- (...args: infer A2): infer R2;
1473
- (...args: infer A3): infer R3;
1474
- (...args: infer A4): infer R4;
1475
- (...args: infer A5): infer R5;
1476
- (...args: infer A6): infer R6;
1477
- (...args: infer A7): infer R7;
1478
- (...args: infer A8): infer R8;
1479
- (...args: infer A9): infer R9;
1480
- (...args: infer A10): infer R10;
1481
- } ? ((...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;
1482
- /**
1483
- * A function with `unknown` parameters and return type.
1484
- */
1485
- type UnknownFunction = (...args: unknown[]) => unknown;
1486
- /**
1487
- * `true` iff {@linkcode FunctionType} is
1488
- * equivalent to `(...args: unknown[]) => unknown`,
1489
- * which is what an overload variant looks like for a non-existent overload.
1490
- * This is useful because older versions of TypeScript end up with
1491
- * 9 "useless" overloads and one real one for parameterless/generic functions.
1492
- *
1493
- * @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
1494
- */
1495
- type IsUselessOverloadInfo<FunctionType> = StrictEqualUsingTSInternalIdenticalToOperator<FunctionType, UnknownFunction>;
1496
- /**
1497
- * Old versions of TypeScript can sometimes seem to refuse to separate out
1498
- * union members unless you put them each in a pointless tuple and add an
1499
- * extra `infer X` expression. There may be a better way to work around this
1500
- * problem, but since it's not a problem in newer versions of TypeScript,
1501
- * it's not a priority right now.
1502
- */
1503
- type Tuplify<Union> = Union extends infer X ? [X] : never;
1504
- /**
1505
- * For older versions of TypeScript, we need two separate workarounds
1506
- * to get overload info. First, we need need to use
1507
- * {@linkcode DecreasingOverloadsInfoUnion} to get the overload info for
1508
- * functions with 1-10 overloads. Then, we need to filter out the
1509
- * "useless" overloads that are present in older versions of TypeScript,
1510
- * for parameterless functions. To do this we use
1511
- * {@linkcode IsUselessOverloadInfo} to remove useless overloads.
1512
- *
1513
- * @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
1514
- */
1515
- type TSPre53OverloadsInfoUnion<FunctionType> = Tuplify<DecreasingOverloadsInfoUnion<FunctionType>> extends infer Tup ? Tup extends [infer Fn] ? IsUselessOverloadInfo<Fn> extends true ? never : Fn : never : never;
1516
- /**
1517
- * For versions of TypeScript below 5.3, we need to check for 10 overloads,
1518
- * then 9, then 8, etc., to get a union of the overload variants.
1519
- */
1520
- type DecreasingOverloadsInfoUnion<F> = F extends {
1521
- (...args: infer A1): infer R1;
1522
- (...args: infer A2): infer R2;
1523
- (...args: infer A3): infer R3;
1524
- (...args: infer A4): infer R4;
1525
- (...args: infer A5): infer R5;
1526
- (...args: infer A6): infer R6;
1527
- (...args: infer A7): infer R7;
1528
- (...args: infer A8): infer R8;
1529
- (...args: infer A9): infer R9;
1530
- (...args: infer A10): infer R10;
1531
- } ? ((...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 {
1532
- (...args: infer A1): infer R1;
1533
- (...args: infer A2): infer R2;
1534
- (...args: infer A3): infer R3;
1535
- (...args: infer A4): infer R4;
1536
- (...args: infer A5): infer R5;
1537
- (...args: infer A6): infer R6;
1538
- (...args: infer A7): infer R7;
1539
- (...args: infer A8): infer R8;
1540
- (...args: infer A9): infer R9;
1541
- } ? ((...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 {
1542
- (...args: infer A1): infer R1;
1543
- (...args: infer A2): infer R2;
1544
- (...args: infer A3): infer R3;
1545
- (...args: infer A4): infer R4;
1546
- (...args: infer A5): infer R5;
1547
- (...args: infer A6): infer R6;
1548
- (...args: infer A7): infer R7;
1549
- (...args: infer A8): infer R8;
1550
- } ? ((...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 {
1551
- (...args: infer A1): infer R1;
1552
- (...args: infer A2): infer R2;
1553
- (...args: infer A3): infer R3;
1554
- (...args: infer A4): infer R4;
1555
- (...args: infer A5): infer R5;
1556
- (...args: infer A6): infer R6;
1557
- (...args: infer A7): infer R7;
1558
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) : F extends {
1559
- (...args: infer A1): infer R1;
1560
- (...args: infer A2): infer R2;
1561
- (...args: infer A3): infer R3;
1562
- (...args: infer A4): infer R4;
1563
- (...args: infer A5): infer R5;
1564
- (...args: infer A6): infer R6;
1565
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) : F extends {
1566
- (...args: infer A1): infer R1;
1567
- (...args: infer A2): infer R2;
1568
- (...args: infer A3): infer R3;
1569
- (...args: infer A4): infer R4;
1570
- (...args: infer A5): infer R5;
1571
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) : F extends {
1572
- (...args: infer A1): infer R1;
1573
- (...args: infer A2): infer R2;
1574
- (...args: infer A3): infer R3;
1575
- (...args: infer A4): infer R4;
1576
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) : F extends {
1577
- (...args: infer A1): infer R1;
1578
- (...args: infer A2): infer R2;
1579
- (...args: infer A3): infer R3;
1580
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) : F extends {
1581
- (...args: infer A1): infer R1;
1582
- (...args: infer A2): infer R2;
1583
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) : F extends ((...args: infer A1) => infer R1) ? ((...p: A1) => R1) : never;
1584
- /**
1585
- * Get a union of overload variants for a function {@linkcode FunctionType}.
1586
- * Does a check for whether we can do the one-shot
1587
- * 10-overload matcher (which works for ts\>5.3), and if not,
1588
- * falls back to the more complicated utility.
1589
- */
1590
- type OverloadsInfoUnion<FunctionType> = IsNever<TSPost53OverloadsInfoUnion<(a: 1) => 2>> extends true ? TSPre53OverloadsInfoUnion<FunctionType> : TSPost53OverloadsInfoUnion<FunctionType>;
1591
- /**
1592
- * Allows inferring any function using the `infer` keyword.
1593
- */
1594
-
1595
- /**
1596
- * The simple(ish) way to get overload info from a constructor
1597
- * {@linkcode ConstructorType}. Recent versions of TypeScript will match any
1598
- * constructor against a generic 10-overload type, filling in slots with
1599
- * duplicates of the constructor. So, we can just match against a single type
1600
- * and get all the overloads.
1601
- *
1602
- * For older versions of TypeScript,
1603
- * we'll need to painstakingly do ten separate matches.
1604
- */
1605
- type TSPost53ConstructorOverloadsInfoUnion<ConstructorType> = 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 (...args: infer A6): infer R6;
1612
- new (...args: infer A7): infer R7;
1613
- new (...args: infer A8): infer R8;
1614
- new (...args: infer A9): infer R9;
1615
- new (...args: infer A10): infer R10;
1616
- } ? (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;
1617
- /**
1618
- * A constructor function with `unknown` parameters and return type.
1619
- */
1620
- type UnknownConstructor = new (...args: unknown[]) => unknown;
1621
- /**
1622
- * Same as {@linkcode IsUselessOverloadInfo}, but for constructors.
1623
- */
1624
- type IsUselessConstructorOverloadInfo<FunctionType> = StrictEqualUsingTSInternalIdenticalToOperator<FunctionType, UnknownConstructor>;
1625
- /**
1626
- * For older versions of TypeScript, we need two separate workarounds to
1627
- * get constructor overload info. First, we need need to use
1628
- * {@linkcode DecreasingConstructorOverloadsInfoUnion} to get the overload
1629
- * info for constructors with 1-10 overloads. Then, we need to filter out the
1630
- * "useless" overloads that are present in older versions of TypeScript,
1631
- * for parameterless constructors. To do this we use
1632
- * {@linkcode IsUselessConstructorOverloadInfo} to remove useless overloads.
1633
- *
1634
- * @see {@link https://github.com/microsoft/TypeScript/issues/28867 | Related}
1635
- */
1636
- type TSPre53ConstructorOverloadsInfoUnion<ConstructorType> = Tuplify<DecreasingConstructorOverloadsInfoUnion<ConstructorType>> extends infer Tup ? Tup extends [infer Ctor] ? IsUselessConstructorOverloadInfo<Ctor> extends true ? never : Ctor : never : never;
1637
- /**
1638
- * For versions of TypeScript below 5.3, we need to check for 10 overloads,
1639
- * then 9, then 8, etc., to get a union of the overload variants.
1640
- */
1641
- type DecreasingConstructorOverloadsInfoUnion<ConstructorType> = ConstructorType extends {
1642
- new (...args: infer A1): infer R1;
1643
- new (...args: infer A2): infer R2;
1644
- new (...args: infer A3): infer R3;
1645
- new (...args: infer A4): infer R4;
1646
- new (...args: infer A5): infer R5;
1647
- new (...args: infer A6): infer R6;
1648
- new (...args: infer A7): infer R7;
1649
- new (...args: infer A8): infer R8;
1650
- new (...args: infer A9): infer R9;
1651
- new (...args: infer A10): infer R10;
1652
- } ? (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 {
1653
- new (...args: infer A1): infer R1;
1654
- new (...args: infer A2): infer R2;
1655
- new (...args: infer A3): infer R3;
1656
- new (...args: infer A4): infer R4;
1657
- new (...args: infer A5): infer R5;
1658
- new (...args: infer A6): infer R6;
1659
- new (...args: infer A7): infer R7;
1660
- new (...args: infer A8): infer R8;
1661
- new (...args: infer A9): infer R9;
1662
- } ? (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 {
1663
- new (...args: infer A1): infer R1;
1664
- new (...args: infer A2): infer R2;
1665
- new (...args: infer A3): infer R3;
1666
- new (...args: infer A4): infer R4;
1667
- new (...args: infer A5): infer R5;
1668
- new (...args: infer A6): infer R6;
1669
- new (...args: infer A7): infer R7;
1670
- new (...args: infer A8): infer R8;
1671
- } ? (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 {
1672
- new (...args: infer A1): infer R1;
1673
- new (...args: infer A2): infer R2;
1674
- new (...args: infer A3): infer R3;
1675
- new (...args: infer A4): infer R4;
1676
- new (...args: infer A5): infer R5;
1677
- new (...args: infer A6): infer R6;
1678
- new (...args: infer A7): infer R7;
1679
- } ? (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 {
1680
- new (...args: infer A1): infer R1;
1681
- new (...args: infer A2): infer R2;
1682
- new (...args: infer A3): infer R3;
1683
- new (...args: infer A4): infer R4;
1684
- new (...args: infer A5): infer R5;
1685
- new (...args: infer A6): infer R6;
1686
- } ? (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 {
1687
- new (...args: infer A1): infer R1;
1688
- new (...args: infer A2): infer R2;
1689
- new (...args: infer A3): infer R3;
1690
- new (...args: infer A4): infer R4;
1691
- new (...args: infer A5): infer R5;
1692
- } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) : ConstructorType extends {
1693
- new (...args: infer A1): infer R1;
1694
- new (...args: infer A2): infer R2;
1695
- new (...args: infer A3): infer R3;
1696
- new (...args: infer A4): infer R4;
1697
- } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) : ConstructorType extends {
1698
- new (...args: infer A1): infer R1;
1699
- new (...args: infer A2): infer R2;
1700
- new (...args: infer A3): infer R3;
1701
- } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) : ConstructorType extends {
1702
- new (...args: infer A1): infer R1;
1703
- new (...args: infer A2): infer R2;
1704
- } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) : ConstructorType extends (new (...args: infer A1) => infer R1) ? (new (...p: A1) => R1) : never;
1705
- /**
1706
- * Get a union of overload variants for a constructor
1707
- * {@linkcode ConstructorType}. Does a check for whether we can do the
1708
- * one-shot 10-overload matcher (which works for ts\>5.3), and if not,
1709
- * falls back to the more complicated utility.
1710
- */
1711
- type ConstructorOverloadsUnion<ConstructorType> = IsNever<TSPost53ConstructorOverloadsInfoUnion<new (a: 1) => any>> extends true ? TSPre53ConstructorOverloadsInfoUnion<ConstructorType> : TSPost53ConstructorOverloadsInfoUnion<ConstructorType>;
1712
- /**
1713
- * Allows inferring any constructor using the `infer` keyword.
1714
- */
1715
- type InferConstructor<ConstructorType extends new (...args: any) => any> = ConstructorType;
1716
- /**
1717
- * A union type of the parameters allowed for any overload
1718
- * of constructor {@linkcode ConstructorType}.
1719
- */
1720
- type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<ConstructorType> extends InferConstructor<infer Ctor> ? ConstructorParameters<Ctor> : never;
1721
- /**
1722
- * Calculates the number of overloads for a given function type.
1723
- */
1724
- type NumOverloads<FunctionType> = UnionToTuple$1<OverloadsInfoUnion<FunctionType>>['length'];
1725
- //#endregion
1726
- //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/branding.d.ts
1727
- /**
1728
- * Represents a deeply branded type.
1729
- *
1730
- * Recursively walk a type and replace it with a branded type related to the
1731
- * original. This is useful for equality-checking stricter than
1732
- * `A extends B ? B extends A ? true : false : false`, because it detects the
1733
- * difference between a few edge-case types that vanilla TypeScript
1734
- * doesn't by default:
1735
- * - `any` vs `unknown`
1736
- * - `{ readonly a: string }` vs `{ a: string }`
1737
- * - `{ a?: string }` vs `{ a: string | undefined }`
1738
- *
1739
- * __Note__: not very performant for complex types - this should only be used
1740
- * when you know you need it. If doing an equality check, it's almost always
1741
- * better to use {@linkcode StrictEqualUsingTSInternalIdenticalToOperator}.
1742
- */
1743
- type DeepBrand<T> = IsNever<T> extends true ? {
1744
- type: 'never';
1745
- } : IsAny<T> extends true ? {
1746
- type: 'any';
1747
- } : IsUnknown$1<T> extends true ? {
1748
- type: 'unknown';
1749
- } : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
1750
- type: 'primitive';
1751
- value: T;
1752
- } : T extends (new (...args: any[]) => any) ? {
1753
- type: 'constructor';
1754
- params: ConstructorOverloadParameters<T>;
1755
- instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>;
1756
- } : T extends ((...args: infer P) => infer R) ? NumOverloads<T> extends 1 ? {
1757
- type: 'function';
1758
- params: DeepBrand<P>;
1759
- return: DeepBrand<R>;
1760
- this: DeepBrand<ThisParameterType<T>>;
1761
- props: DeepBrand<Omit<T, keyof Function>>;
1762
- } : UnionToTuple$1<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
1763
- type: 'overloads';
1764
- overloads: { [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]> };
1765
- } : never : T extends any[] ? {
1766
- type: 'array';
1767
- items: { [K in keyof T]: T[K] };
1768
- } : {
1769
- type: 'object';
1770
- properties: { [K in keyof T]: DeepBrand<T[K]> };
1771
- readonly: ReadonlyKeys<T>;
1772
- required: RequiredKeys<T>;
1773
- optional: OptionalKeys<T>;
1774
- constructorParams: DeepBrand<ConstructorOverloadParameters<T>>;
1775
- };
1776
- /**
1777
- * Checks if two types are strictly equal using branding.
1778
- */
1779
- type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
1780
- //#endregion
1781
- //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/messages.d.ts
1782
- /**
1783
- * Determines the printable type representation for a given type.
1784
- */
1785
- type PrintType<T> = IsUnknown$1<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<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' : '...';
1786
- /**
1787
- * Helper for showing end-user a hint why their type assertion is failing.
1788
- * This swaps "leaf" types with a literal message about what the actual and
1789
- * expected types are. Needs to check for `Not<IsAny<Actual>>` because
1790
- * otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
1791
- */
1792
- type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, Not<IsAny<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>>}`;
1793
- /**
1794
- * @internal
1795
- */
1796
- //#endregion
1797
1383
  //#region src/types/core/variants.types.d.ts
1798
1384
  type NarrowVariant<TRoot extends {
1799
1385
  [x: string]: unknown;
@@ -1816,9 +1402,9 @@ type RequiredForm<T extends Record<string, any>, TKey extends keyof T> = Omit<Re
1816
1402
  type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [RequiredForm<T, TKey>, ...RequiredForm<T, TKey>[]];
1817
1403
  //#endregion
1818
1404
  //#region src/core/useRegle/useRegle.d.ts
1819
- type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends 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 : {}, TValidationGroups> & TAdditionalOptions;
1405
+ 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;
1820
1406
  interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
1821
- <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TValid = (isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<RegleRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>, NoInferLegacy<TRules>>)>(...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, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
1407
+ <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>;
1822
1408
  __config?: {
1823
1409
  rules?: () => CustomRulesDeclarationTree;
1824
1410
  modifiers?: RegleBehaviourOptions;
@@ -1848,7 +1434,7 @@ declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutD
1848
1434
  //#endregion
1849
1435
  //#region src/core/useRegle/inferRules.d.ts
1850
1436
  interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
1851
- <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValid = (isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<NoInferLegacy<TRules>, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>>)>(state: MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? TDecl : TState extends Record<string, any> ? TRules : {}): NonNullable<TState> extends PrimitiveTypes ? TDecl : TRules;
1437
+ <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>>(state: MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? TDecl : TState extends Record<string, any> ? TRules : {}): NonNullable<TState> extends PrimitiveTypes ? TDecl : TRules;
1852
1438
  }
1853
1439
  /**
1854
1440
  * Rule type helper to provide autocomplete and typecheck to your form rules or part of your form rules
@@ -1927,6 +1513,21 @@ type RegleEnforceCustomRequiredRules<T extends useRegleFn<any, any>, TRules exte
1927
1513
  */
1928
1514
  type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState extends unknown = any, TRules extends keyof InferRegleRules<T> = never> = RegleFieldStatus<TState, [TRules] extends [never] ? Partial<InferRegleRules<T>> : RegleEnforceCustomRequiredRules<T, TRules>, InferRegleShortcuts<T>>;
1929
1515
  //#endregion
1516
+ //#region src/types/utils/mismatch.types.d.ts
1517
+ /**
1518
+ /**
1519
+ * DeepExact<T, S> is a TypeScript utility type that recursively checks whether the structure of type S
1520
+ * exactly matches the structure of type T, including all nested properties.
1521
+ *
1522
+ * Used in `useRegle` and `inferRules` to enforce that the rules object matches the expected shape exactly.
1523
+ */
1524
+ 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>}>`> };
1525
+ 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] };
1526
+ type TypeError<Msg> = {
1527
+ [' TypeError']: Msg;
1528
+ };
1529
+ type Coerce<T> = `${T & string}`;
1530
+ //#endregion
1930
1531
  //#region src/types/utils/object.types.d.ts
1931
1532
  type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
1932
1533
  /**
@@ -1969,10 +1570,6 @@ type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
1969
1570
  type HasNamedKeys<T> = IsUnion<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
1970
1571
  type ProcessHasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
1971
1572
  //#endregion
1972
- //#region src/types/utils/mismatch.types.d.ts
1973
- 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;
1974
- type CheckDeepExact<TRules, TTree> = [TTree] extends [never] ? false : TRules extends RegleCollectionRuleDecl ? TTree extends Array<any> ? isDeepExact<NonNullable<TRules['$each']>, JoinDiscriminatedUnions<NonNullable<ArrayElement<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;
1975
- //#endregion
1976
1573
  //#region src/types/utils/infer.types.d.ts
1977
1574
  type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>), TMarkMaybe extends boolean = true> = IsUnion$1<UnwrapSimple<TRules>> extends true ? InferTupleUnionInput<UnionToTuple<UnwrapSimple<TRules>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules>]?: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules>]: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }>;
1978
1575
  type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/core",
3
- "version": "1.7.2",
3
+ "version": "1.8.0-beta.1",
4
4
  "description": "Headless form validation library for Vue 3",
5
5
  "peerDependencies": {
6
6
  "pinia": ">=2.2.5",