@bemedev/typings 0.5.2 → 0.5.3

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,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" | "number" | "boolean";
4
- type: "string" | "number" | "boolean";
3
+ const: import("..").UnionCustom<["string", "number", "boolean"]>;
4
+ type: import("..").UnionCustom<["string", "number", "boolean"]>;
5
5
  }>;
@@ -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[number]), {
4
- readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => T[number];
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/type.d.ts CHANGED
@@ -1,2 +1,23 @@
1
- import type { Transform_F } from './type.types';
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,5 +1,5 @@
1
- import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } from './constants';
2
- import type { StandardSchemaV1 } from './standard.types';
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,15 +27,18 @@ 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 '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;
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 'date' ? Date : T extends 'any' ? any : T extends 'unknown' ? unknown : object;
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
  };
36
- export type SoaCustom<T extends ObjectT = any> = {
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
  }
@@ -77,8 +80,8 @@ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
77
80
  type ReduceTupleU<T extends AnyArray> = T extends [
78
81
  infer First,
79
82
  ...infer Rest extends AnyArray
80
- ] ? [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 : {
83
+ ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T["length"] extends 0 ? [] : number extends T["length"] ? T : Undefiny<T[number]>[];
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;
@@ -98,7 +101,7 @@ export type Sh<T = any> = StandardHelper<T>;
98
101
  export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
99
102
  export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
100
103
  export type inferSh<T extends ObjectT = ObjectT> = Sh<inferO<T>>;
101
- export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T['~standard']['types'], undefined>['output'];
104
+ export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T["~standard"]["types"], undefined>["output"];
102
105
  export type ProduceObject<T extends ObjectT = ObjectT> = T;
103
106
  export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
104
107
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
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.2",
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.4",
108
- "@vitest/ui": "4.1.4",
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.45.0",
114
- "oxlint": "^1.60.0",
113
+ "oxfmt": "^0.46.0",
114
+ "oxlint": "^1.61.0",
115
115
  "pretty-quick": "^4.2.2",
116
- "rolldown": "1.0.0-rc.16",
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.4"
120
+ "vitest": "^4.1.5"
121
121
  },
122
122
  "pnpm": {
123
123
  "onlyBuiltDependencies": [
@@ -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>;