@bemedev/typings 1.1.1 → 1.1.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.
package/lib/index.cjs CHANGED
@@ -1,17 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_constants = require("./constants.cjs");
3
2
  const require_type = require("./type.cjs");
4
- exports.ARRAY = require_constants.ARRAY;
5
- exports.CUSTOM = require_constants.CUSTOM;
6
- exports.LITTERALS = require_constants.LITTERALS;
7
- exports.OPTIONAL = require_constants.OPTIONAL;
8
- exports.PARTIAL = require_constants.PARTIAL;
9
- exports.PRIMITIVES = require_constants.PRIMITIVES;
10
- exports.PRIMITIVE_OBJECTS = require_constants.PRIMITIVE_OBJECTS;
11
- exports.SOA = require_constants.SOA;
12
- exports.SORA = require_constants.SORA;
13
- exports.STANDARD_KEY = require_constants.STANDARD_KEY;
14
- exports.UNION = require_constants.UNION;
15
3
  exports.pretype = require_type.pretype;
16
4
  exports.type = require_type.type;
17
- exports.vendor = require_constants.vendor;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './constants';
2
1
  export * from './type';
3
2
  export * from './types';
package/lib/index.js CHANGED
@@ -1,3 +1,2 @@
1
- import { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, vendor } from "./constants.js";
2
1
  import { pretype, type } from "./type.js";
3
- export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, pretype, type, vendor };
2
+ export { pretype, type };
package/lib/type.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("./standard.cjs");
3
+ const require_utils_expandFn = require("./utils/expandFn.cjs");
3
4
  const require_helpers_any = require("./helpers/any.cjs");
4
5
  const require_helpers_array = require("./helpers/array.cjs");
5
6
  const require_helpers_custom = require("./helpers/custom.cjs");
@@ -51,7 +52,7 @@ const type = (option) => {
51
52
  else out = _transform(option);
52
53
  return require_standard.standardize(out);
53
54
  };
54
- const pretype = () => type;
55
+ const pretype = (_) => require_utils_expandFn.expandFn(type, { type });
55
56
  //#endregion
56
57
  exports.pretype = pretype;
57
58
  exports.type = type;
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 { FnBasic, inferSh, ObjectT, SafePre } from './types';
2
+ import { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sora, sv, tuple, union, use } from './helpers';
3
3
  type Helpers = {
4
4
  any: typeof any;
5
5
  custom: typeof custom;
@@ -22,7 +22,10 @@ type Helpers = {
22
22
  sora: typeof sora;
23
23
  };
24
24
  export type Transform_F = <T extends ObjectT = ObjectT>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
25
- export type PreTransform = <U extends ObjectT>() => <T extends U = U>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
25
+ type _PreTransform_F<U extends ObjectT> = <T extends SafePre<U> = SafePre<U>>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
26
+ export type PreTransform_F = <U extends ObjectT>(_?: inferSh<U>) => FnBasic<_PreTransform_F<U>, {
27
+ type: _PreTransform_F<U>;
28
+ }>;
26
29
  export declare const type: Transform_F;
27
- export declare const pretype: PreTransform;
30
+ export declare const pretype: PreTransform_F;
28
31
  export {};
package/lib/type.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { standardize } from "./standard.js";
2
+ import { expandFn } from "./utils/expandFn.js";
2
3
  import { any } from "./helpers/any.js";
3
4
  import { array } from "./helpers/array.js";
4
5
  import { custom } from "./helpers/custom.js";
@@ -50,6 +51,6 @@ const type = (option) => {
50
51
  else out = _transform(option);
51
52
  return standardize(out);
52
53
  };
53
- const pretype = () => type;
54
+ const pretype = (_) => expandFn(type, { type });
54
55
  //#endregion
55
56
  export { pretype, type };
package/lib/types.d.ts CHANGED
@@ -117,4 +117,12 @@ export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
117
117
  export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY]['types'], undefined>['output'];
118
118
  export type ProduceObject<T extends ObjectT = ObjectT> = T;
119
119
  export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
120
+ type ReduceTupleSafePre<T extends ReadonlyArray<ObjectT>> = T extends readonly [
121
+ infer First extends ObjectT,
122
+ ...infer Rest extends ReadonlyArray<ObjectT>
123
+ ] ? readonly [SafePre<First>, ...ReduceTupleSafePre<Rest>] : [];
124
+ type _SafePre<T extends ObjectT> = PrimitiveObjectT extends T ? PrimitiveObjectT : PrimitiveT extends T ? PrimitiveT : T extends Types ? T : T extends PartialCustom<infer TPartial> ? Partial<SafePre<TPartial>> : T extends ArrayCustom<infer A> ? SafePre<A>[] : T extends Optional<infer TOptional> ? SafePre<TOptional> | undefined : T extends SoRaCustom<infer TSoRa> ? SoRa<SafePre<TSoRa>> : T extends SoaCustom<infer TSoA> ? SoA<SafePre<TSoA>> : T extends Custom ? T : T extends AnyArray<ObjectT> ? ReduceTupleSafePre<T> : PrimitiveObjectMapS extends T ? PrimitiveObjectMapS : ObjectMapS extends T ? ObjectMapS : T extends ObjectMapS ? {
125
+ [K in keyof T]: SafePre<T[K]>;
126
+ } : T;
127
+ export type SafePre<T extends ObjectT> = Extract<_SafePre<T>, ObjectT>;
120
128
  export * from './standard.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",
@@ -27,6 +27,11 @@
27
27
  "require": "./lib/helpers/index.cjs",
28
28
  "types": "./lib/helpers/index.d.ts"
29
29
  },
30
+ "./constants": {
31
+ "import": "./lib/constants.js",
32
+ "require": "./lib/constants.cjs",
33
+ "types": "./lib/constants.d.ts"
34
+ },
30
35
  "./package.json": "./package.json",
31
36
  "./tsconfig.json": "./tsconfig.json",
32
37
  "./types": {