@hz-9/a5-core 0.2.0-alpha.19 → 0.2.0-alpha.21

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/all.d.ts CHANGED
@@ -435,6 +435,13 @@ export declare class A5Util {
435
435
  static tryWithAbsolutePath(sourcePath: string, basePath: string): string;
436
436
  }
437
437
 
438
+ /**
439
+ * 类型断言工具 - 判断两个类型结构相似
440
+ *
441
+ * @public
442
+ */
443
+ export declare type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
444
+
438
445
  /**
439
446
  * @public
440
447
  */
@@ -462,16 +469,67 @@ export declare class ColorUtil {
462
469
  static clear(text: string): string;
463
470
  }
464
471
 
472
+ /**
473
+ * 类型调试工具 - 展开类型定义
474
+ *
475
+ * @public
476
+ */
477
+ export declare type Debug<T> = {
478
+ [K in keyof T]: T[K];
479
+ };
480
+
465
481
  /**
466
482
  * @public
467
483
  */
468
484
  export declare const DEFAULT_LOG_LEVELS: LogLevel[];
469
485
 
486
+ /**
487
+ * 类型断言工具 - 判断两个类型相等
488
+ *
489
+ * @public
490
+ */
491
+ export declare type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
492
+
470
493
  /**
471
494
  * @public
472
495
  */
473
496
  export declare const ERROR_WELCOME_MSG: string;
474
497
 
498
+ /**
499
+ * 类型断言工具 - 期望类型为 true
500
+ *
501
+ * @public
502
+ */
503
+ export declare type Expect<T extends true> = T;
504
+
505
+ /**
506
+ * 类型断言工具 - 期望类型扩展自目标类型
507
+ *
508
+ * @public
509
+ */
510
+ export declare type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : false;
511
+
512
+ /**
513
+ * 类型断言工具 - 期望值为 false
514
+ *
515
+ * @public
516
+ */
517
+ export declare type ExpectFalse<T extends false> = T;
518
+
519
+ /**
520
+ * 类型断言工具 - 期望值为 true
521
+ *
522
+ * @public
523
+ */
524
+ export declare type ExpectTrue<T extends true> = T;
525
+
526
+ /**
527
+ * 类型断言工具 - 验证函数参数类型
528
+ *
529
+ * @public
530
+ */
531
+ export declare type ExpectValidArgs<FUNC extends (...args: any[]) => any, ARGS extends any[]> = ARGS extends Parameters<FUNC> ? true : false;
532
+
475
533
  /**
476
534
  * @public
477
535
  */
@@ -535,6 +593,27 @@ export declare abstract class IA5ConfigModule {
535
593
  export declare abstract class IA5LogModule {
536
594
  }
537
595
 
596
+ /**
597
+ * 类型断言工具 - 判断是否为 any 类型
598
+ *
599
+ * @public
600
+ */
601
+ export declare type IsAny<T> = 0 extends 1 & T ? true : false;
602
+
603
+ /**
604
+ * 类型断言工具 - 判断是否为 false
605
+ *
606
+ * @public
607
+ */
608
+ export declare type IsFalse<T extends false> = T;
609
+
610
+ /**
611
+ * 类型断言工具 - 判断是否为 true
612
+ *
613
+ * @public
614
+ */
615
+ export declare type IsTrue<T extends true> = T;
616
+
538
617
  /**
539
618
  * 包加载工具类
540
619
  * 用于统一处理可选依赖的动态导入
@@ -602,6 +681,15 @@ export declare class LogoUtil {
602
681
  */
603
682
  export declare const MAIN_STATIC_PATH: string;
604
683
 
684
+ /**
685
+ * 类型合并工具 - 合并嵌套类型
686
+ *
687
+ * @public
688
+ */
689
+ export declare type MergeInsertions<T> = T extends object ? {
690
+ [K in keyof T]: MergeInsertions<T[K]>;
691
+ } : T;
692
+
605
693
  /**
606
694
  *
607
695
  * @public
@@ -622,6 +710,20 @@ export declare const MODULE_CONFIG_PATH_A5_LOG: <T extends string>(str: T) => `A
622
710
 
623
711
  export { nanoid }
624
712
 
713
+ /**
714
+ * 类型断言工具 - 判断不是 any 类型
715
+ *
716
+ * @public
717
+ */
718
+ export declare type NotAny<T> = true extends IsAny<T> ? false : true;
719
+
720
+ /**
721
+ * 类型断言工具 - 判断两个类型不相等
722
+ *
723
+ * @public
724
+ */
725
+ export declare type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
726
+
625
727
  /**
626
728
  * @public
627
729
  */
@@ -661,6 +763,13 @@ export declare class RunEnvUtil {
661
763
  static get inJest(): boolean;
662
764
  }
663
765
 
766
+ /**
767
+ * 类型转换工具 - 联合类型转交叉类型
768
+ *
769
+ * @public
770
+ */
771
+ export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
772
+
664
773
  /**
665
774
  * @public
666
775
  */
@@ -1,3 +1,4 @@
1
1
  export * from './base';
2
2
  export * from './http';
3
3
  export * from './provide-token';
4
+ export * from './type-challenges.utils';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base"), exports);
18
18
  __exportStar(require("./http"), exports);
19
19
  __exportStar(require("./provide-token"), exports);
20
+ __exportStar(require("./type-challenges.utils"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,94 @@
1
+ /**
2
+ * 类型断言工具 - 期望类型为 true
3
+ *
4
+ * @public
5
+ */
6
+ export type Expect<T extends true> = T;
7
+ /**
8
+ * 类型断言工具 - 期望值为 true
9
+ *
10
+ * @public
11
+ */
12
+ export type ExpectTrue<T extends true> = T;
13
+ /**
14
+ * 类型断言工具 - 期望值为 false
15
+ *
16
+ * @public
17
+ */
18
+ export type ExpectFalse<T extends false> = T;
19
+ /**
20
+ * 类型断言工具 - 判断是否为 true
21
+ *
22
+ * @public
23
+ */
24
+ export type IsTrue<T extends true> = T;
25
+ /**
26
+ * 类型断言工具 - 判断是否为 false
27
+ *
28
+ * @public
29
+ */
30
+ export type IsFalse<T extends false> = T;
31
+ /**
32
+ * 类型断言工具 - 判断两个类型不相等
33
+ *
34
+ * @public
35
+ */
36
+ export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
37
+ /**
38
+ * 类型断言工具 - 判断两个类型相等
39
+ *
40
+ * @public
41
+ */
42
+ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
43
+ /**
44
+ * 类型断言工具 - 判断是否为 any 类型
45
+ *
46
+ * @public
47
+ */
48
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
49
+ /**
50
+ * 类型断言工具 - 判断不是 any 类型
51
+ *
52
+ * @public
53
+ */
54
+ export type NotAny<T> = true extends IsAny<T> ? false : true;
55
+ /**
56
+ * 类型调试工具 - 展开类型定义
57
+ *
58
+ * @public
59
+ */
60
+ export type Debug<T> = {
61
+ [K in keyof T]: T[K];
62
+ };
63
+ /**
64
+ * 类型合并工具 - 合并嵌套类型
65
+ *
66
+ * @public
67
+ */
68
+ export type MergeInsertions<T> = T extends object ? {
69
+ [K in keyof T]: MergeInsertions<T[K]>;
70
+ } : T;
71
+ /**
72
+ * 类型断言工具 - 判断两个类型结构相似
73
+ *
74
+ * @public
75
+ */
76
+ export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
77
+ /**
78
+ * 类型断言工具 - 期望类型扩展自目标类型
79
+ *
80
+ * @public
81
+ */
82
+ export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : false;
83
+ /**
84
+ * 类型断言工具 - 验证函数参数类型
85
+ *
86
+ * @public
87
+ */
88
+ export type ExpectValidArgs<FUNC extends (...args: any[]) => any, ARGS extends any[]> = ARGS extends Parameters<FUNC> ? true : false;
89
+ /**
90
+ * 类型转换工具 - 联合类型转交叉类型
91
+ *
92
+ * @public
93
+ */
94
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=type-challenges.utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hz-9/a5-core",
3
- "version": "0.2.0-alpha.19",
3
+ "version": "0.2.0-alpha.21",
4
4
  "description": "The core library for the `@hz-9/a5-*` series of repositories.",
5
5
  "keywords": [
6
6
  "nest",
@@ -45,7 +45,6 @@
45
45
  "@types/node": "~20.3.1",
46
46
  "@types/pug": "~2.0.10",
47
47
  "@types/uuid": "~9.0.8",
48
- "@type-challenges/utils": "~0.1.1",
49
48
  "axios": "~1.7.2",
50
49
  "body-parser": "~1.20.2",
51
50
  "dayjs": "~1.11.10",