@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 CHANGED
@@ -5,7 +5,7 @@ Typings by variables
5
5
  ## Usage
6
6
 
7
7
  ```ts
8
- import { type } from "@bemedev/typings";
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: "number",
17
- y: "number",
16
+ x: 'number',
17
+ y: 'number',
18
18
  },
19
19
  data: {
20
- label: optional("string"),
21
- content: "string",
20
+ label: optional('string'),
21
+ content: 'string',
22
22
  },
23
- input: "boolean",
23
+ input: 'boolean',
24
24
  },
25
- { id: "string" },
25
+ { id: 'string' },
26
26
  ),
27
27
  ),
28
28
  ),
@@ -1,4 +1,4 @@
1
- import type { NotReadonly, ObjectT } from "../types";
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";
@@ -1,4 +1,4 @@
1
- import type { ArrayCustom, ObjectT } from "../types";
1
+ import type { ArrayCustom, ObjectT } from '../types';
2
2
  export declare const array: import("..").FnBasic<(<T extends ObjectT>(value: T) => ArrayCustom<T>), object & {
3
3
  const: ArrayCustom;
4
4
  type: ArrayCustom;
@@ -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,16 +1,16 @@
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
+ 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 "../types";
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 "../types";
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";
@@ -1,4 +1,4 @@
1
- import type { NotReadonly, ObjectMapS } from "../types";
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 "../types";
1
+ import type { CanOptional, NotReadonly, Optional } from '../types';
2
2
  export declare const optional: <const T extends CanOptional>(value?: T) => Optional<NotReadonly<T>>;
@@ -1,2 +1,2 @@
1
- import type { NotReadonly, ObjectT, PartialCustom } from "../types";
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 "../types";
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 "../types";
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 "../types";
1
+ import type { ObjectT } from '../types';
2
2
  export declare const readonly: <const T extends ObjectT>(value: T) => T;
@@ -1,4 +1,4 @@
1
- import type { Keys, ObjectT } from "../types";
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;
@@ -1,2 +1,2 @@
1
- import type { NotReadonly, ObjectT, SoaCustom } from "../types";
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>>;
@@ -1,4 +1,4 @@
1
- import type { Custom, StateValue } from "../types";
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>;
@@ -1,4 +1,4 @@
1
- import type { NotReadonly, ObjectT } from "../types";
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;
@@ -1,4 +1,4 @@
1
- import type { Keys, ObjectMapS, ObjectT } from "../types";
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 "./constants";
2
- export * from "./type";
3
- export * from "./types";
1
+ export * from './constants';
2
+ export * from './type';
3
+ export * from './types';
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
  value: T;
4
4
  } & StandardSchemaV1<T, T>;
@@ -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 "~standard": StandardSchemaV1.Props<Input, Output>;
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: "@bemedev/typings";
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["~standard"]["types"]>["input"];
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["~standard"]["types"]>["output"];
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 "./type.types";
1
+ import type { Transform_F } from './type.types';
2
2
  export declare const type: Transform_F;
@@ -1,5 +1,5 @@
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";
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 "./constants";
2
- import type { StandardSchemaV1 } from "./standard.types";
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 "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
  };
@@ -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["length"] extends 0 ? [] : number extends T["length"] ? T : Undefiny<T[number]>[];
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 Sh> = T["value"];
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 {};
@@ -1,4 +1,4 @@
1
- import type { Fn, FnBasic, ObjectT } from "../types";
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;
@@ -1,3 +1,3 @@
1
- import type { ObjectT } from "../types";
2
- export * from "./expandFn";
1
+ import type { ObjectT } from '../types';
2
+ export * from './expandFn';
3
3
  export declare const _const: <T extends ObjectT>(value?: T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",