@bemedev/typings 1.0.0 → 1.1.0

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.
@@ -1,4 +1,4 @@
1
- import type { Custom, ObjectT } from "../types";
1
+ import type { Custom, ObjectT } from '../types';
2
2
  /**
3
3
  * Create a custom value that can be used in the state value or as a literal.
4
4
  * @param value The value to create the custom value from.
@@ -1,19 +1,19 @@
1
- export * from "./any";
2
- export * from "./array";
3
- export * from "./custom";
4
- export * from "./intersection";
5
- export * from "./use";
6
- export * from "./litterals";
7
- export * from "./optional";
8
- export * from "./partial";
9
- export * from "./primitive";
10
- export * from "./primitiveObject";
11
- export * from "./readonly";
12
- export * from "./record";
13
- export * from "./soa";
14
- export * from "./sora";
15
- export * from "./sv";
16
- export * from "./tuple";
17
- export * from "./union";
18
- export * from "./object";
19
- export * from "./omit";
1
+ export * from './any';
2
+ export * from './array';
3
+ export * from './custom';
4
+ export * from './intersection';
5
+ export * from './use';
6
+ export * from './litterals';
7
+ export * from './optional';
8
+ export * from './partial';
9
+ export * from './primitive';
10
+ export * from './primitiveObject';
11
+ export * from './readonly';
12
+ export * from './record';
13
+ export * from './soa';
14
+ export * from './sora';
15
+ export * from './sv';
16
+ export * from './tuple';
17
+ export * from './union';
18
+ export * from './object';
19
+ export * from './omit';
@@ -1,2 +1,2 @@
1
- import type { Sh } from "../types";
1
+ import type { Sh } from '../types';
2
2
  export declare const use: <T extends Sh>({ __type }: T) => T["__type"];
package/lib/standard.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StandardSchemaV1 } from "./standard.types";
1
+ import type { StandardSchemaV1 } from './standard.types';
2
2
  type Standardize_F = <T>(value: T) => {
3
3
  __type: T;
4
4
  type: T;
@@ -1,3 +1,3 @@
1
- import type { StandardSchemaV1 } from "@standard-schema/spec";
2
- export type * from "@standard-schema/spec";
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ export type * from '@standard-schema/spec';
3
3
  export type StandardKey = keyof StandardSchemaV1;
package/lib/type.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { inferSh, ObjectT } from "./types";
2
- import { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union, sora, use } from "./helpers";
1
+ import type { inferSh, ObjectT } from './types';
2
+ import { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union, sora, use } 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, SORA, UNION } from "./constants";
2
- import type { StandardKey, StandardSchemaV1 } from "./standard.types";
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 & {
@@ -87,9 +87,6 @@ type ReduceTupleU<T extends AnyArray> = T extends [
87
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
- type __TransformPrimitiveObject<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<__TransformPrimitiveObject<TSoA>> : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom<infer TPartial> ? Partial<__TransformPrimitiveObject<TPartial>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
91
- [K in keyof T]: __TransformPrimitiveObject<T[K]>;
92
- };
93
90
  type HasUndefined<T> = unknown extends T ? false : OptionalHelperClass extends T ? true : false;
94
91
  type UndefinyObject<T extends object> = {
95
92
  [K in keyof T as HasUndefined<T[K]> extends true ? never : K]: Undefiny<T[K]>;
@@ -99,17 +96,26 @@ type UndefinyObject<T extends object> = {
99
96
  [K in keyof F]: F[K];
100
97
  } : never;
101
98
  type Undefiny<T, U = Exclude<T, OptionalHelperClass>> = U extends AnyArray ? ReduceTupleU<U> : U extends Ru ? UndefinyObject<U> : U;
102
- type TransformT<T> = Undefiny<__TransformPrimitiveObject<T>>;
99
+ type __TransformPrimitiveObject<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<__TransformPrimitiveObject<TSoA>> : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom<infer TPartial> ? Partial<__TransformPrimitiveObject<TPartial>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : Undefiny<{
100
+ [K in keyof T]: __TransformPrimitiveObject<T[K]>;
101
+ }>;
102
+ type TransformT<T> = __TransformPrimitiveObject<T>;
103
103
  export type StandardHelper<T1 = any, T2 = any> = {
104
104
  __type: T1;
105
105
  type: T2;
106
106
  } & StandardSchemaV1<T2, T2>;
107
107
  type _Sh<T1 = any, T2 = any> = StandardHelper<T1, T2>;
108
108
  export type Sh<T extends ObjectT = ObjectT> = StandardHelper<T, inferO<T>>;
109
- export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
110
- export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
109
+ export type StandardOutput<T = any> = {
110
+ [STANDARD_KEY]: {
111
+ types?: {
112
+ output: T;
113
+ };
114
+ };
115
+ };
116
+ export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : T extends Optional<infer U> ? TransformT<U> | undefined : TransformT<T>;
111
117
  export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
112
- export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[StandardKey]["types"], undefined>["output"];
118
+ export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY]["types"], undefined>["output"];
113
119
  export type ProduceObject<T extends ObjectT = ObjectT> = T;
114
120
  export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
115
121
  export * from "./standard.types";
@@ -1,2 +1,2 @@
1
- import type { ObjectT } from "../types";
1
+ import type { ObjectT } from '../types';
2
2
  export declare const _const: <T extends ObjectT>(value?: T) => T;
@@ -1,3 +1,3 @@
1
- export * from "./_const";
2
- export * from "./expandFn";
3
- export * from "./isSh";
1
+ export * from './_const';
2
+ export * from './expandFn';
3
+ export * from './isSh';
@@ -1,2 +1,2 @@
1
- import type { ObjectT, Sh } from "../types";
1
+ import type { ObjectT, Sh } from '../types';
2
2
  export declare const isSh: <T extends ObjectT = ObjectT>(value: unknown) => value is Sh<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",