@bemedev/typings 1.1.0 → 1.1.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/lib/types.d.ts +9 -10
- package/package.json +4 -3
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION } from
|
|
2
|
-
import type { StandardSchemaV1 } from
|
|
1
|
+
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION } from './constants';
|
|
2
|
+
import type { StandardSchemaV1 } from './standard.types';
|
|
3
3
|
export type Ru = Record<Keys, unknown>;
|
|
4
4
|
type Equals<T, U> = T extends U ? (U extends T ? true : false) : false;
|
|
5
5
|
export type TrueObject = Ru & {
|
|
@@ -28,9 +28,9 @@ export type SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
|
|
|
28
28
|
export type SoRa<T> = SingleOrRecursiveArrayOf<T>;
|
|
29
29
|
export type Primitive = string | number | boolean | bigint | null | undefined | symbol | never;
|
|
30
30
|
export type PrimitiveT = (typeof PRIMITIVES)[number];
|
|
31
|
-
type TransformPrimitiveS<T extends PrimitiveT> = T extends
|
|
31
|
+
type TransformPrimitiveS<T extends PrimitiveT> = T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'bigint' ? bigint : T extends 'null' ? null : T extends 'undefined' ? undefined : T extends 'symbol' ? symbol : T extends 'never' ? never : Primitive;
|
|
32
32
|
export type Types = PrimitiveT | (typeof PRIMITIVE_OBJECTS)[number];
|
|
33
|
-
export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends
|
|
33
|
+
export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends 'date' ? Date : T extends 'any' ? any : T extends 'unknown' ? unknown : object;
|
|
34
34
|
export type Custom<T = any> = {
|
|
35
35
|
[CUSTOM]: T;
|
|
36
36
|
};
|
|
@@ -84,7 +84,7 @@ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
|
|
|
84
84
|
type ReduceTupleU<T extends AnyArray> = T extends [
|
|
85
85
|
infer First,
|
|
86
86
|
...infer Rest extends AnyArray
|
|
87
|
-
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T[
|
|
87
|
+
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
|
|
88
88
|
type EmptyObject = {};
|
|
89
89
|
type __TransformUnion<T extends UnionCustom> = T extends UnionCustom<infer TCustom> ? Omit<T, typeof UNION> extends infer Ot ? Equals<Ot, EmptyObject> extends true ? TransformT<TCustom[number]> : TransformT<TCustom[number]> & TransformT<Ot> : never : never;
|
|
90
90
|
type HasUndefined<T> = unknown extends T ? false : OptionalHelperClass extends T ? true : false;
|
|
@@ -96,10 +96,9 @@ type UndefinyObject<T extends object> = {
|
|
|
96
96
|
[K in keyof F]: F[K];
|
|
97
97
|
} : never;
|
|
98
98
|
type Undefiny<T, U = Exclude<T, OptionalHelperClass>> = U extends AnyArray ? ReduceTupleU<U> : U extends Ru ? UndefinyObject<U> : U;
|
|
99
|
-
type
|
|
100
|
-
[K in keyof T]:
|
|
99
|
+
type TransformT<T> = Equals<ObjectMapS, T> extends true ? object : T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends UnionCustom ? __TransformUnion<T> : T extends SoRaCustom<infer TSoA> ? SoRa<TransformT<TSoA>> : T extends SoaCustom<infer TSoA> ? SoA<TransformT<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom<infer TPartial> ? Partial<TransformT<TPartial>> : T extends Optional<infer TOptional> ? TransformT<TOptional> | OptionalHelperClass : Undefiny<{
|
|
100
|
+
[K in keyof T]: TransformT<T[K]>;
|
|
101
101
|
}>;
|
|
102
|
-
type TransformT<T> = __TransformPrimitiveObject<T>;
|
|
103
102
|
export type StandardHelper<T1 = any, T2 = any> = {
|
|
104
103
|
__type: T1;
|
|
105
104
|
type: T2;
|
|
@@ -115,7 +114,7 @@ export type StandardOutput<T = any> = {
|
|
|
115
114
|
};
|
|
116
115
|
export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : T extends Optional<infer U> ? TransformT<U> | undefined : TransformT<T>;
|
|
117
116
|
export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
|
|
118
|
-
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY][
|
|
117
|
+
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY]['types'], undefined>['output'];
|
|
119
118
|
export type ProduceObject<T extends ObjectT = ObjectT> = T;
|
|
120
119
|
export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
|
|
121
|
-
export * from
|
|
120
|
+
export * from './standard.types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/typings",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Typings by variables",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "pnpm rm:lib && pnpm run rolldown",
|
|
67
|
-
"
|
|
68
|
-
"ci
|
|
67
|
+
"_ci": "pnpm run config:off && pnpm run lint && pnpm run test",
|
|
68
|
+
"ci": "CI_START=$(date +%s) && pnpm run _ci && pnpm run p-q && echo \"\n✅ CI takes $(($(date +%s) - CI_START))s\n\"",
|
|
69
|
+
"ci:admin": "CI_START=$(date +%s) && pnpm run rm && pnpm run upgrade:fast && pnpm run _ci && echo \"\n✅ Admin CI takes $(($(date +%s) - CI_START))s\n\"",
|
|
69
70
|
"clean": "pnpm run rm && pnpm run config",
|
|
70
71
|
"config": "pnpm install",
|
|
71
72
|
"config:off": "pnpm run config --offline",
|