@bemedev/typings 0.5.3 → 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/union.d.ts +1 -1
- package/lib/standard.types.d.ts +4 -4
- package/lib/type.d.ts +2 -2
- package/lib/types.d.ts +6 -6
- package/package.json +1 -1
package/lib/helpers/union.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Keys, ObjectMapS, ObjectT, UnionCustom } from
|
|
1
|
+
import type { Keys, ObjectMapS, ObjectT, UnionCustom } from '../types';
|
|
2
2
|
type Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;
|
|
3
3
|
export declare const union: import("..").FnBasic<(<T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => UnionCustom<T>), {
|
|
4
4
|
readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => UnionCustom<T>;
|
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,5 +1,5 @@
|
|
|
1
|
-
import type { inferSh, ObjectT } from
|
|
2
|
-
import { any, array, custom, intersection, litterals, object, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union } from
|
|
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
3
|
type Helpers = {
|
|
4
4
|
any: typeof any;
|
|
5
5
|
custom: typeof custom;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION } from
|
|
2
|
-
import type { StandardSchemaV1 } from
|
|
1
|
+
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION } from './constants';
|
|
2
|
+
import type { StandardSchemaV1 } from './standard.types';
|
|
3
3
|
export type Ru = Record<Keys, unknown>;
|
|
4
4
|
export type TrueObject = Ru & {
|
|
5
5
|
[Symbol.iterator]?: never;
|
|
@@ -27,9 +27,9 @@ export type SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
|
|
|
27
27
|
export type SoRa<T> = SingleOrRecursiveArrayOf<T>;
|
|
28
28
|
export type Primitive = string | number | boolean | bigint | null | undefined | symbol | never;
|
|
29
29
|
export type PrimitiveT = (typeof PRIMITIVES)[number];
|
|
30
|
-
type TransformPrimitiveS<T extends PrimitiveT> = T extends
|
|
30
|
+
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;
|
|
31
31
|
export type Types = PrimitiveT | (typeof PRIMITIVE_OBJECTS)[number];
|
|
32
|
-
export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends
|
|
32
|
+
export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends 'date' ? Date : T extends 'any' ? any : T extends 'unknown' ? unknown : object;
|
|
33
33
|
export type Custom<T = any> = {
|
|
34
34
|
[CUSTOM]: T;
|
|
35
35
|
};
|
|
@@ -80,7 +80,7 @@ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
|
|
|
80
80
|
type ReduceTupleU<T extends AnyArray> = T extends [
|
|
81
81
|
infer First,
|
|
82
82
|
...infer Rest extends AnyArray
|
|
83
|
-
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T[
|
|
83
|
+
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
|
|
84
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 : {
|
|
85
85
|
[K in keyof T]: __TransformPrimitiveObject<T[K]>;
|
|
86
86
|
};
|
|
@@ -101,7 +101,7 @@ export type Sh<T = any> = StandardHelper<T>;
|
|
|
101
101
|
export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
|
|
102
102
|
export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
|
|
103
103
|
export type inferSh<T extends ObjectT = ObjectT> = Sh<inferO<T>>;
|
|
104
|
-
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[
|
|
104
|
+
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T['~standard']['types'], undefined>['output'];
|
|
105
105
|
export type ProduceObject<T extends ObjectT = ObjectT> = T;
|
|
106
106
|
export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
|
|
107
107
|
export {};
|