@bemedev/typings 0.5.2 → 0.5.4
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/helpers/litterals.d.ts +2 -2
- package/lib/helpers/union.d.ts +3 -3
- package/lib/standard.types.d.ts +4 -4
- package/lib/type.d.ts +22 -1
- package/lib/types.d.ts +7 -4
- package/package.json +8 -8
- package/lib/type.types.d.ts +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Custom } from '../types';
|
|
2
2
|
export declare const litterals: import("..").FnBasic<(<const T extends (string | number | boolean)[]>(...values: T) => Custom<T[number]>), object & {
|
|
3
|
-
const: "string"
|
|
4
|
-
type: "string"
|
|
3
|
+
const: import("..").UnionCustom<["string", "number", "boolean"]>;
|
|
4
|
+
type: import("..").UnionCustom<["string", "number", "boolean"]>;
|
|
5
5
|
}>;
|
package/lib/helpers/union.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Keys, ObjectMapS, ObjectT } from '../types';
|
|
1
|
+
import type { Keys, ObjectMapS, ObjectT, UnionCustom } from '../types';
|
|
2
2
|
type Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;
|
|
3
|
-
export declare const union: import("..").FnBasic<(<T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => T
|
|
4
|
-
readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => T
|
|
3
|
+
export declare const union: import("..").FnBasic<(<T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => UnionCustom<T>), {
|
|
4
|
+
readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => UnionCustom<T>;
|
|
5
5
|
}>;
|
|
6
6
|
export {};
|
package/lib/standard.types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The Standard Schema interface. */
|
|
2
2
|
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
3
|
/** The Standard Schema properties. */
|
|
4
|
-
readonly
|
|
4
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
5
5
|
}
|
|
6
6
|
export declare namespace StandardSchemaV1 {
|
|
7
7
|
/** The Standard Schema properties interface. */
|
|
@@ -9,7 +9,7 @@ export declare namespace StandardSchemaV1 {
|
|
|
9
9
|
/** The version number of the standard. */
|
|
10
10
|
readonly version: 1;
|
|
11
11
|
/** The vendor name of the schema library. */
|
|
12
|
-
readonly vendor:
|
|
12
|
+
readonly vendor: string;
|
|
13
13
|
/** Validates unknown input values. */
|
|
14
14
|
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
15
15
|
/** Inferred types associated with the schema. */
|
|
@@ -53,7 +53,7 @@ export declare namespace StandardSchemaV1 {
|
|
|
53
53
|
readonly output: Output;
|
|
54
54
|
}
|
|
55
55
|
/** Infers the input type of a Standard Schema. */
|
|
56
|
-
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema[
|
|
56
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
57
57
|
/** Infers the output type of a Standard Schema. */
|
|
58
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema[
|
|
58
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
59
59
|
}
|
package/lib/type.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { inferSh, ObjectT } from './types';
|
|
2
|
+
import { any, array, custom, intersection, litterals, object, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union } from './helpers';
|
|
3
|
+
type Helpers = {
|
|
4
|
+
any: typeof any;
|
|
5
|
+
custom: typeof custom;
|
|
6
|
+
intersection: typeof intersection;
|
|
7
|
+
litterals: typeof litterals;
|
|
8
|
+
optional: typeof optional;
|
|
9
|
+
partial: typeof partial;
|
|
10
|
+
record: typeof record;
|
|
11
|
+
soa: typeof soa;
|
|
12
|
+
sv: typeof sv;
|
|
13
|
+
union: typeof union;
|
|
14
|
+
array: typeof array;
|
|
15
|
+
tuple: typeof tuple;
|
|
16
|
+
primitiveObject: typeof primitiveObject;
|
|
17
|
+
primitive: typeof primitive;
|
|
18
|
+
readonly: typeof readonly;
|
|
19
|
+
object: typeof object;
|
|
20
|
+
};
|
|
21
|
+
export type Transform_F = <T extends ObjectT = ObjectT>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
|
|
2
22
|
export declare const type: Transform_F;
|
|
23
|
+
export {};
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } from './constants';
|
|
1
|
+
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION } from './constants';
|
|
2
2
|
import type { StandardSchemaV1 } from './standard.types';
|
|
3
3
|
export type Ru = Record<Keys, unknown>;
|
|
4
4
|
export type TrueObject = Ru & {
|
|
@@ -33,9 +33,12 @@ export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPr
|
|
|
33
33
|
export type Custom<T = any> = {
|
|
34
34
|
[CUSTOM]: T;
|
|
35
35
|
};
|
|
36
|
-
export type SoaCustom<T extends ObjectT =
|
|
36
|
+
export type SoaCustom<T extends ObjectT = ObjectT> = {
|
|
37
37
|
[SOA]: T;
|
|
38
38
|
};
|
|
39
|
+
export type UnionCustom<T extends ObjectT[] = ObjectT[]> = {
|
|
40
|
+
[UNION]: T;
|
|
41
|
+
};
|
|
39
42
|
export type PartialCustom = {
|
|
40
43
|
[PARTIAL]: undefined;
|
|
41
44
|
};
|
|
@@ -59,7 +62,7 @@ export type IntersectionCustom<T extends ObjectMapS[]> = T extends [
|
|
|
59
62
|
...infer Rest extends ObjectMapS[]
|
|
60
63
|
] ? First & IntersectionCustom<Rest> : unknown;
|
|
61
64
|
type _ObjectT = __ObjectT | Optional | ArrayCustom;
|
|
62
|
-
export type PrimitiveObjectT = SoRa<Types | ArrayCustom<Types> | Optional<Types> | PrimitiveObjectMapS | (PrimitiveObjectMapS & PartialCustom)>;
|
|
65
|
+
export type PrimitiveObjectT = SoRa<Types | PrimitiveObjectMapS | ArrayCustom<Types | PrimitiveObjectMapS> | Optional<Types | PrimitiveObjectMapS> | UnionCustom<Types[] | PrimitiveObjectMapS[]> | (PrimitiveObjectMapS & PartialCustom)>;
|
|
63
66
|
export interface PrimitiveObjectMapS {
|
|
64
67
|
[key: Keys]: PrimitiveObjectT;
|
|
65
68
|
}
|
|
@@ -78,7 +81,7 @@ type ReduceTupleU<T extends AnyArray> = T extends [
|
|
|
78
81
|
infer First,
|
|
79
82
|
...infer Rest extends AnyArray
|
|
80
83
|
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
|
|
81
|
-
type __TransformPrimitiveObject<T> = T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom ? Partial<__TransformPrimitiveObject<NOmit<T, typeof PARTIAL>>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
|
|
84
|
+
type __TransformPrimitiveObject<T> = T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends UnionCustom<infer TCustom> ? TransformT<TCustom[number]> : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom ? Partial<__TransformPrimitiveObject<NOmit<T, typeof PARTIAL>>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
|
|
82
85
|
[K in keyof T]: __TransformPrimitiveObject<T[K]>;
|
|
83
86
|
};
|
|
84
87
|
type HasUndefined<T> = unknown extends T ? false : OptionalHelperClass extends T ? true : false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/typings",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Typings by variables",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -100,24 +100,24 @@
|
|
|
100
100
|
}
|
|
101
101
|
],
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@bemedev/dev-utils": "^0.6.
|
|
103
|
+
"@bemedev/dev-utils": "^0.6.4",
|
|
104
104
|
"@bemedev/fsf": "^1.0.1",
|
|
105
105
|
"@size-limit/file": "^12.1.0",
|
|
106
106
|
"@types/node": "^25.6.0",
|
|
107
|
-
"@vitest/coverage-v8": "^4.1.
|
|
108
|
-
"@vitest/ui": "4.1.
|
|
107
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
108
|
+
"@vitest/ui": "4.1.5",
|
|
109
109
|
"glob": "^13.0.6",
|
|
110
110
|
"globals": "^17.5.0",
|
|
111
111
|
"husky": "^9.1.7",
|
|
112
112
|
"onchange": "^7.1.0",
|
|
113
|
-
"oxfmt": "^0.
|
|
114
|
-
"oxlint": "^1.
|
|
113
|
+
"oxfmt": "^0.46.0",
|
|
114
|
+
"oxlint": "^1.61.0",
|
|
115
115
|
"pretty-quick": "^4.2.2",
|
|
116
|
-
"rolldown": "1.0.0-rc.
|
|
116
|
+
"rolldown": "1.0.0-rc.17",
|
|
117
117
|
"size-limit": "^12.1.0",
|
|
118
118
|
"tslib": "^2.8.1",
|
|
119
119
|
"typescript": "^6.0.3",
|
|
120
|
-
"vitest": "^4.1.
|
|
120
|
+
"vitest": "^4.1.5"
|
|
121
121
|
},
|
|
122
122
|
"pnpm": {
|
|
123
123
|
"onlyBuiltDependencies": [
|
package/lib/type.types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { any, array, custom, intersection, litterals, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union, object } from './helpers';
|
|
2
|
-
import type { ObjectT, inferSh } from './types';
|
|
3
|
-
export type Helpers = {
|
|
4
|
-
any: typeof any;
|
|
5
|
-
custom: typeof custom;
|
|
6
|
-
intersection: typeof intersection;
|
|
7
|
-
litterals: typeof litterals;
|
|
8
|
-
optional: typeof optional;
|
|
9
|
-
partial: typeof partial;
|
|
10
|
-
record: typeof record;
|
|
11
|
-
soa: typeof soa;
|
|
12
|
-
sv: typeof sv;
|
|
13
|
-
union: typeof union;
|
|
14
|
-
array: typeof array;
|
|
15
|
-
tuple: typeof tuple;
|
|
16
|
-
primitiveObject: typeof primitiveObject;
|
|
17
|
-
primitive: typeof primitive;
|
|
18
|
-
readonly: typeof readonly;
|
|
19
|
-
object: typeof object;
|
|
20
|
-
};
|
|
21
|
-
export type Transform_F = <T extends ObjectT = ObjectT>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
|