@bemedev/typings 0.5.0 → 0.5.2
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/README.md +7 -7
- package/lib/helpers/any.d.ts +1 -1
- package/lib/helpers/array.d.ts +1 -1
- package/lib/helpers/custom.d.ts +1 -1
- package/lib/helpers/index.d.ts +16 -16
- package/lib/helpers/intersection.d.ts +1 -1
- package/lib/helpers/litterals.d.ts +1 -1
- package/lib/helpers/object.d.ts +1 -1
- package/lib/helpers/optional.d.ts +1 -1
- package/lib/helpers/partial.d.ts +1 -1
- package/lib/helpers/primitive.d.ts +1 -1
- package/lib/helpers/primitiveObject.d.ts +1 -1
- package/lib/helpers/readonly.d.ts +1 -1
- package/lib/helpers/record.d.ts +1 -1
- package/lib/helpers/soa.d.ts +1 -1
- package/lib/helpers/sv.d.ts +1 -1
- package/lib/helpers/tuple.d.ts +1 -1
- package/lib/helpers/union.d.ts +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/standard.d.ts +1 -1
- package/lib/standard.types.d.ts +4 -4
- package/lib/type.d.ts +1 -1
- package/lib/type.types.d.ts +2 -2
- package/lib/types.d.ts +7 -7
- package/lib/utils/expandFn.d.ts +1 -1
- package/lib/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Typings by variables
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import { type } from
|
|
8
|
+
import { type } from '@bemedev/typings';
|
|
9
9
|
|
|
10
10
|
const result = type(({ array, optional, intersection }) => ({
|
|
11
11
|
nodes: optional(
|
|
@@ -13,16 +13,16 @@ const result = type(({ array, optional, intersection }) => ({
|
|
|
13
13
|
intersection(
|
|
14
14
|
{
|
|
15
15
|
position: {
|
|
16
|
-
x:
|
|
17
|
-
y:
|
|
16
|
+
x: 'number',
|
|
17
|
+
y: 'number',
|
|
18
18
|
},
|
|
19
19
|
data: {
|
|
20
|
-
label: optional(
|
|
21
|
-
content:
|
|
20
|
+
label: optional('string'),
|
|
21
|
+
content: 'string',
|
|
22
22
|
},
|
|
23
|
-
input:
|
|
23
|
+
input: 'boolean',
|
|
24
24
|
},
|
|
25
|
-
{ id:
|
|
25
|
+
{ id: 'string' },
|
|
26
26
|
),
|
|
27
27
|
),
|
|
28
28
|
),
|
package/lib/helpers/any.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectT } from
|
|
1
|
+
import type { NotReadonly, ObjectT } from '../types';
|
|
2
2
|
export declare const any: import("..").FnBasic<(<const T extends ObjectT = ObjectT>(value?: T) => ObjectT extends NotReadonly<T> ? "any" : NotReadonly<T>), object & {
|
|
3
3
|
const: "any";
|
|
4
4
|
type: "any";
|
package/lib/helpers/array.d.ts
CHANGED
package/lib/helpers/custom.d.ts
CHANGED
package/lib/helpers/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
1
|
+
export * from './any';
|
|
2
|
+
export * from './array';
|
|
3
|
+
export * from './custom';
|
|
4
|
+
export * from './intersection';
|
|
5
|
+
export * from './litterals';
|
|
6
|
+
export * from './optional';
|
|
7
|
+
export * from './partial';
|
|
8
|
+
export * from './primitive';
|
|
9
|
+
export * from './primitiveObject';
|
|
10
|
+
export * from './readonly';
|
|
11
|
+
export * from './record';
|
|
12
|
+
export * from './soa';
|
|
13
|
+
export * from './sv';
|
|
14
|
+
export * from './tuple';
|
|
15
|
+
export * from './union';
|
|
16
|
+
export * from './object';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IntersectionCustom, NotReadonly, ObjectMapS } from
|
|
1
|
+
import type { IntersectionCustom, NotReadonly, ObjectMapS } from '../types';
|
|
2
2
|
export declare const intersection: <const T extends [ObjectMapS, ObjectMapS, ...ObjectMapS[]]>(...values: T) => IntersectionCustom<NotReadonly<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Custom } from
|
|
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
3
|
const: "string" | "number" | "boolean";
|
|
4
4
|
type: "string" | "number" | "boolean";
|
package/lib/helpers/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectMapS } from
|
|
1
|
+
import type { NotReadonly, ObjectMapS } from '../types';
|
|
2
2
|
export declare const object: import("..").FnBasic<(<const T extends ObjectMapS>(value?: T) => ObjectMapS extends NotReadonly<T> ? ObjectMapS : NotReadonly<T>), object & {
|
|
3
3
|
const: ObjectMapS;
|
|
4
4
|
type: ObjectMapS;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CanOptional, NotReadonly, Optional } from
|
|
1
|
+
import type { CanOptional, NotReadonly, Optional } from '../types';
|
|
2
2
|
export declare const optional: <const T extends CanOptional>(value?: T) => Optional<NotReadonly<T>>;
|
package/lib/helpers/partial.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectT, PartialCustom } from
|
|
1
|
+
import type { NotReadonly, ObjectT, PartialCustom } from '../types';
|
|
2
2
|
export declare const partial: <const T extends ObjectT>(value: T) => NotReadonly<T> & PartialCustom;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Custom, PrimitiveT } from
|
|
1
|
+
import type { Custom, PrimitiveT } from '../types';
|
|
2
2
|
export declare const primitive: import("..").FnBasic<(<const T extends PrimitiveT>(value?: T) => T), {
|
|
3
3
|
readonly boolean: import("..").FnBasic<(<const T extends boolean>(value?: T) => boolean extends T ? "boolean" : Custom<T>), object & {
|
|
4
4
|
const: "boolean";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IntersectionCustom, NotReadonly, PrimitiveObjectMapS, PrimitiveObjectT } from
|
|
1
|
+
import type { IntersectionCustom, NotReadonly, PrimitiveObjectMapS, PrimitiveObjectT } from '../types';
|
|
2
2
|
export declare const primitiveObject: import("..").FnBasic<(<const T extends PrimitiveObjectT | IntersectionCustom<PrimitiveObjectMapS[]> = PrimitiveObjectT>(value?: T) => NotReadonly<T>), {
|
|
3
3
|
readonly map: import("..").FnBasic<(<const T extends PrimitiveObjectMapS | IntersectionCustom<PrimitiveObjectMapS[]> = PrimitiveObjectMapS>(value?: T) => NotReadonly<T>), object & {
|
|
4
4
|
const: PrimitiveObjectMapS;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ObjectT } from
|
|
1
|
+
import type { ObjectT } from '../types';
|
|
2
2
|
export declare const readonly: <const T extends ObjectT>(value: T) => T;
|
package/lib/helpers/record.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Keys, ObjectT } from
|
|
1
|
+
import type { Keys, ObjectT } from '../types';
|
|
2
2
|
export declare const record: import("..").FnBasic<(<const K extends Keys[], V extends ObjectT>(value: V, ...keys: K) => Record<K[number] extends never ? string | number | symbol : K[number], V>), object & {
|
|
3
3
|
const: import("..").ObjectMapS;
|
|
4
4
|
type: import("..").ObjectMapS;
|
package/lib/helpers/soa.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectT, SoaCustom } from
|
|
1
|
+
import type { NotReadonly, ObjectT, SoaCustom } from '../types';
|
|
2
2
|
export declare const soa: <const T extends ObjectT>(value?: T) => ObjectT extends NotReadonly<T> ? "any" : SoaCustom<NotReadonly<T>>;
|
package/lib/helpers/sv.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Custom, StateValue } from
|
|
1
|
+
import type { Custom, StateValue } from '../types';
|
|
2
2
|
export declare const sv: import("..").FnBasic<(<const T extends StateValue = StateValue>(value?: T) => StateValue extends T ? Custom<StateValue> : Custom<T>), object & {
|
|
3
3
|
const: Custom<StateValue>;
|
|
4
4
|
type: Custom<StateValue>;
|
package/lib/helpers/tuple.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectT } from
|
|
1
|
+
import type { NotReadonly, ObjectT } from '../types';
|
|
2
2
|
export declare const tuple: import("..").FnBasic<(<const T extends [ObjectT, ...ObjectT[]]>(...values: T) => NotReadonly<T>), object & {
|
|
3
3
|
const: import("..").ArrayCustom;
|
|
4
4
|
type: import("..").ArrayCustom;
|
package/lib/helpers/union.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Keys, ObjectMapS, ObjectT } from
|
|
1
|
+
import type { Keys, ObjectMapS, ObjectT } 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) => T[number]), {
|
|
4
4
|
readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => T[number];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './type';
|
|
3
|
+
export * from './types';
|
package/lib/standard.d.ts
CHANGED
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: '@bemedev/typings';
|
|
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,2 @@
|
|
|
1
|
-
import type { Transform_F } from
|
|
1
|
+
import type { Transform_F } from './type.types';
|
|
2
2
|
export declare const type: Transform_F;
|
package/lib/type.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { any, array, custom, intersection, litterals, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union, object } from
|
|
2
|
-
import type { ObjectT, inferSh } from
|
|
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
3
|
export 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 } from
|
|
2
|
-
import type { StandardSchemaV1 } from
|
|
1
|
+
import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } 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
|
};
|
|
@@ -77,7 +77,7 @@ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
|
|
|
77
77
|
type ReduceTupleU<T extends AnyArray> = T extends [
|
|
78
78
|
infer First,
|
|
79
79
|
...infer Rest extends AnyArray
|
|
80
|
-
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T[
|
|
80
|
+
] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
|
|
81
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 : {
|
|
82
82
|
[K in keyof T]: __TransformPrimitiveObject<T[K]>;
|
|
83
83
|
};
|
|
@@ -95,10 +95,10 @@ export type StandardHelper<T = any> = {
|
|
|
95
95
|
value: T;
|
|
96
96
|
} & StandardSchemaV1<T, T>;
|
|
97
97
|
export type Sh<T = any> = StandardHelper<T>;
|
|
98
|
-
export type StandardOutput<T> = StandardSchemaV1<any, T>;
|
|
98
|
+
export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
|
|
99
99
|
export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
|
|
100
100
|
export type inferSh<T extends ObjectT = ObjectT> = Sh<inferO<T>>;
|
|
101
|
-
export type inferT<T extends
|
|
101
|
+
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T['~standard']['types'], undefined>['output'];
|
|
102
102
|
export type ProduceObject<T extends ObjectT = ObjectT> = T;
|
|
103
103
|
export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
|
|
104
104
|
export {};
|
package/lib/utils/expandFn.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fn, FnBasic, ObjectT } from
|
|
1
|
+
import type { Fn, FnBasic, ObjectT } from '../types';
|
|
2
2
|
export declare const expandFn: <Main extends Fn, const Tr extends object = object>(main: Main, extensions?: Tr) => FnBasic<Main, Tr>;
|
|
3
3
|
export declare const expandFn2: <Main extends Fn, C extends ObjectT, const Tr extends object = object>(main: Main, type: C, extensions?: Tr) => FnBasic<Main, Tr & {
|
|
4
4
|
const: C;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ObjectT } from
|
|
2
|
-
export * from
|
|
1
|
+
import type { ObjectT } from '../types';
|
|
2
|
+
export * from './expandFn';
|
|
3
3
|
export declare const _const: <T extends ObjectT>(value?: T) => T;
|