@bemedev/typings 1.1.6 → 1.2.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.
Files changed (50) hide show
  1. package/lib/constants.cjs +7 -2
  2. package/lib/constants.d.ts +2 -1
  3. package/lib/constants.js +7 -3
  4. package/lib/helpers/any.cjs +3 -1
  5. package/lib/helpers/any.js +1 -0
  6. package/lib/helpers/array.cjs +3 -1
  7. package/lib/helpers/array.js +1 -0
  8. package/lib/helpers/custom.cjs +3 -1
  9. package/lib/helpers/custom.js +1 -0
  10. package/lib/helpers/litterals.cjs +1 -0
  11. package/lib/helpers/litterals.js +1 -0
  12. package/lib/helpers/object.cjs +3 -1
  13. package/lib/helpers/object.js +1 -0
  14. package/lib/helpers/omit.cjs +3 -1
  15. package/lib/helpers/omit.js +1 -0
  16. package/lib/helpers/optional.d.ts +2 -1
  17. package/lib/helpers/primitive.cjs +1 -0
  18. package/lib/helpers/primitive.d.ts +2 -2
  19. package/lib/helpers/primitive.js +1 -0
  20. package/lib/helpers/primitiveObject.cjs +1 -0
  21. package/lib/helpers/primitiveObject.js +1 -0
  22. package/lib/helpers/record.cjs +1 -0
  23. package/lib/helpers/record.js +1 -0
  24. package/lib/helpers/sv.cjs +3 -1
  25. package/lib/helpers/sv.js +1 -0
  26. package/lib/helpers/tuple.cjs +1 -0
  27. package/lib/helpers/tuple.js +1 -0
  28. package/lib/index.cjs +2 -0
  29. package/lib/index.js +2 -1
  30. package/lib/standard.d.ts +1 -1
  31. package/lib/type.cjs +1 -0
  32. package/lib/type.js +1 -0
  33. package/lib/types/arrays.types.d.ts +22 -0
  34. package/lib/types/customs.types.d.ts +28 -0
  35. package/lib/types/index.cjs +3 -0
  36. package/lib/types/index.d.ts +8 -0
  37. package/lib/types/index.js +2 -0
  38. package/lib/types/standard.types.d.ts +26 -0
  39. package/lib/types/transform.types.d.ts +22 -0
  40. package/lib/types/types.types.d.ts +8 -0
  41. package/lib/types/typings.types.d.ts +24 -0
  42. package/lib/types/undefiny.cjs +8 -0
  43. package/lib/types/undefiny.d.ts +19 -0
  44. package/lib/types/undefiny.js +7 -0
  45. package/lib/types/utilities.types.d.ts +23 -0
  46. package/package.json +6 -5
  47. package/lib/standard.types.d.ts +0 -3
  48. package/lib/types.cjs +0 -0
  49. package/lib/types.d.ts +0 -140
  50. package/lib/types.js +0 -1
package/lib/constants.cjs CHANGED
@@ -1,12 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/constants.ts
3
- const PRIMITIVES = [
3
+ const JSON_PRIMITIVES = [
4
4
  "string",
5
5
  "number",
6
6
  "boolean",
7
+ "undefined",
8
+ "json"
9
+ ];
10
+ const PRIMITIVES = [
11
+ ...JSON_PRIMITIVES,
7
12
  "bigint",
8
13
  "symbol",
9
- "undefined",
10
14
  "null",
11
15
  "never",
12
16
  "primitive"
@@ -30,6 +34,7 @@ const vendor = "@bemedev/typings";
30
34
  //#endregion
31
35
  exports.ARRAY = ARRAY;
32
36
  exports.CUSTOM = CUSTOM;
37
+ exports.JSON_PRIMITIVES = JSON_PRIMITIVES;
33
38
  exports.LITTERALS = LITTERALS;
34
39
  exports.OPTIONAL = OPTIONAL;
35
40
  exports.PARTIAL = PARTIAL;
@@ -1,4 +1,5 @@
1
- export declare const PRIMITIVES: readonly ["string", "number", "boolean", "bigint", "symbol", "undefined", "null", "never", "primitive"];
1
+ export declare const JSON_PRIMITIVES: readonly ["string", "number", "boolean", "undefined", "json"];
2
+ export declare const PRIMITIVES: readonly ["string", "number", "boolean", "undefined", "json", "bigint", "symbol", "null", "never", "primitive"];
2
3
  export declare const PRIMITIVE_OBJECTS: readonly ["date", "any", "object", "unknown"];
3
4
  export declare const OPTIONAL = "$$app-ts => optional$$";
4
5
  export declare const UNION = "$$app-ts => union$$";
package/lib/constants.js CHANGED
@@ -1,11 +1,15 @@
1
1
  //#region src/constants.ts
2
- const PRIMITIVES = [
2
+ const JSON_PRIMITIVES = [
3
3
  "string",
4
4
  "number",
5
5
  "boolean",
6
+ "undefined",
7
+ "json"
8
+ ];
9
+ const PRIMITIVES = [
10
+ ...JSON_PRIMITIVES,
6
11
  "bigint",
7
12
  "symbol",
8
- "undefined",
9
13
  "null",
10
14
  "never",
11
15
  "primitive"
@@ -27,4 +31,4 @@ const LITTERALS = "$$app-ts => litterals$$";
27
31
  const STANDARD_KEY = "~standard";
28
32
  const vendor = "@bemedev/typings";
29
33
  //#endregion
30
- export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, vendor };
34
+ export { ARRAY, CUSTOM, JSON_PRIMITIVES, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, vendor };
@@ -1,7 +1,9 @@
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");
4
+ require("../utils/index.cjs");
3
5
  //#region src/helpers/any.ts
4
- const any = require("../utils/expandFn.cjs").expandFn2((value) => {
6
+ const any = require_utils_expandFn.expandFn2((value) => {
5
7
  return require_standard.standardize2(value);
6
8
  }, "any");
7
9
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { expandFn2 } from "../utils/expandFn.js";
3
+ import "../utils/index.js";
3
4
  //#region src/helpers/any.ts
4
5
  const any = expandFn2((value) => {
5
6
  return standardize2(value);
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
+ const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
4
6
  //#region src/helpers/array.ts
5
- const array = require("../utils/expandFn.cjs").expandFn2((value) => {
7
+ const array = require_utils_expandFn.expandFn2((value) => {
6
8
  return require_standard.standardize2([value]);
7
9
  }, require_utils__const._const());
8
10
  //#endregion
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/array.ts
5
6
  const array = expandFn2((value) => {
6
7
  return standardize2([value]);
@@ -1,5 +1,7 @@
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");
4
+ require("../utils/index.cjs");
3
5
  //#region src/helpers/custom.ts
4
6
  /**
5
7
  * Create a custom value that can be used in the state value or as a literal.
@@ -16,7 +18,7 @@ const require_standard = require("../standard.cjs");
16
18
  *
17
19
  * @see {@link Custom} for more information about custom values.
18
20
  */
19
- const custom = require("../utils/expandFn.cjs").expandFn2((value) => {
21
+ const custom = require_utils_expandFn.expandFn2((value) => {
20
22
  return require_standard.standardize2(value);
21
23
  }, "any");
22
24
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { expandFn2 } from "../utils/expandFn.js";
3
+ import "../utils/index.js";
3
4
  //#region src/helpers/custom.ts
4
5
  /**
5
6
  * Create a custom value that can be used in the state value or as a literal.
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
4
  const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
5
6
  const require_helpers_union = require("./union.cjs");
6
7
  //#region src/helpers/litterals.ts
7
8
  const litterals = require_utils_expandFn.expandFn2((...values) => {
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  import { union } from "./union.js";
5
6
  //#region src/helpers/litterals.ts
6
7
  const litterals = expandFn2((...values) => {
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
+ const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
4
6
  //#region src/helpers/object.ts
5
- const object = require("../utils/expandFn.cjs").expandFn2((value) => {
7
+ const object = require_utils_expandFn.expandFn2((value) => {
6
8
  return require_standard.standardize2(value);
7
9
  }, require_utils__const._const());
8
10
  //#endregion
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/object.ts
5
6
  const object = expandFn2((value) => {
6
7
  return standardize2(value);
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
+ const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
4
6
  //#region src/helpers/omit.ts
5
- const omit = require("../utils/expandFn.cjs").expandFn2((value, _) => {
7
+ const omit = require_utils_expandFn.expandFn2((value, _) => {
6
8
  return require_standard.standardize2(value);
7
9
  }, require_utils__const._const(), { strict: (value, _) => {
8
10
  return require_standard.standardize2(value);
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/omit.ts
5
6
  const omit = expandFn2((value, _) => {
6
7
  return standardize2(value);
@@ -1,2 +1,3 @@
1
- import type { CanOptional, NotReadonly, Optional } from '../types';
1
+ import type { __ObjectT, AnyArray, ArrayCustom, NotReadonly, Optional } from '../types';
2
+ export type CanOptional = __ObjectT | ArrayCustom | AnyArray<__ObjectT>;
2
3
  export declare const optional: <const T extends CanOptional>(value?: T) => Optional<NotReadonly<T>>;
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
4
  const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
5
6
  //#region src/helpers/primitive.ts
6
7
  const primitive = require_utils_expandFn.expandFn2((value) => require_standard.standardize2(value), require_utils__const._const(), {
7
8
  boolean: require_utils_expandFn.expandFn2((value) => {
@@ -23,6 +23,6 @@ export declare const primitive: import("..").FnBasic<(<const T extends Primitive
23
23
  readonly never: Custom<never>;
24
24
  readonly undefined: Custom<undefined>;
25
25
  } & {
26
- const: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "null" | "never" | "primitive";
27
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "null" | "never" | "primitive";
26
+ const: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "json" | "null" | "never" | "primitive";
27
+ type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "json" | "null" | "never" | "primitive";
28
28
  }>;
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/primitive.ts
5
6
  const primitive = expandFn2((value) => standardize2(value), _const(), {
6
7
  boolean: expandFn2((value) => {
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
4
  const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
5
6
  //#region src/helpers/primitiveObject.ts
6
7
  const primitiveObject = require_utils_expandFn.expandFn2((value) => {
7
8
  return require_standard.standardize2(value);
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/primitiveObject.ts
5
6
  const primitiveObject = expandFn2((value) => {
6
7
  return standardize2(value);
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils_expandFn = require("../utils/expandFn.cjs");
4
+ require("../utils/index.cjs");
4
5
  const require_helpers_object = require("./object.cjs");
5
6
  //#region src/helpers/record.ts
6
7
  const record = require_utils_expandFn.expandFn2((value, ...keys) => {
@@ -1,5 +1,6 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { expandFn2 } from "../utils/expandFn.js";
3
+ import "../utils/index.js";
3
4
  import { object } from "./object.js";
4
5
  //#region src/helpers/record.ts
5
6
  const record = expandFn2((value, ...keys) => {
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils__const = require("../utils/_const.cjs");
4
+ const require_utils_expandFn = require("../utils/expandFn.cjs");
5
+ require("../utils/index.cjs");
4
6
  //#region src/helpers/sv.ts
5
- const sv = require("../utils/expandFn.cjs").expandFn2((value) => {
7
+ const sv = require_utils_expandFn.expandFn2((value) => {
6
8
  return require_standard.standardize2(value);
7
9
  }, require_utils__const._const());
8
10
  //#endregion
package/lib/helpers/sv.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { _const } from "../utils/_const.js";
3
3
  import { expandFn2 } from "../utils/expandFn.js";
4
+ import "../utils/index.js";
4
5
  //#region src/helpers/sv.ts
5
6
  const sv = expandFn2((value) => {
6
7
  return standardize2(value);
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("../standard.cjs");
3
3
  const require_utils_expandFn = require("../utils/expandFn.cjs");
4
+ require("../utils/index.cjs");
4
5
  const require_helpers_array = require("./array.cjs");
5
6
  //#region src/helpers/tuple.ts
6
7
  const tuple = require_utils_expandFn.expandFn2((...values) => {
@@ -1,5 +1,6 @@
1
1
  import { standardize2 } from "../standard.js";
2
2
  import { expandFn2 } from "../utils/expandFn.js";
3
+ import "../utils/index.js";
3
4
  import { array } from "./array.js";
4
5
  //#region src/helpers/tuple.ts
5
6
  const tuple = expandFn2((...values) => {
package/lib/index.cjs CHANGED
@@ -1,4 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_type = require("./type.cjs");
3
+ const require_types_undefiny = require("./types/undefiny.cjs");
4
+ exports.OptionalHelperClass = require_types_undefiny.OptionalHelperClass;
3
5
  exports.pretype = require_type.pretype;
4
6
  exports.type = require_type.type;
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { pretype, type } from "./type.js";
2
- export { pretype, type };
2
+ import { OptionalHelperClass } from "./types/undefiny.js";
3
+ export { OptionalHelperClass, pretype, type };
package/lib/standard.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StandardSchemaV1 } from './standard.types';
1
+ import type { StandardSchemaV1 } from './types';
2
2
  type Standardize_F = <T>(value: T) => {
3
3
  __type: T;
4
4
  type: T;
package/lib/type.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_standard = require("./standard.cjs");
3
3
  const require_utils_expandFn = require("./utils/expandFn.cjs");
4
+ require("./utils/index.cjs");
4
5
  const require_helpers_any = require("./helpers/any.cjs");
5
6
  const require_helpers_array = require("./helpers/array.cjs");
6
7
  const require_helpers_custom = require("./helpers/custom.cjs");
package/lib/type.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { standardize } from "./standard.js";
2
2
  import { expandFn } from "./utils/expandFn.js";
3
+ import "./utils/index.js";
3
4
  import { any } from "./helpers/any.js";
4
5
  import { array } from "./helpers/array.js";
5
6
  import { custom } from "./helpers/custom.js";
@@ -0,0 +1,22 @@
1
+ import type { TransformT } from './transform.types';
2
+ import type { ObjectT } from './typings.types';
3
+ import type { Fn, TrueObject } from './utilities.types';
4
+ export type AnyArray<T = unknown> = ReadonlyArray<T> | T[];
5
+ type ReduceTuple<T extends AnyArray> = T extends [
6
+ infer First,
7
+ ...infer Rest extends AnyArray
8
+ ] ? [NotReadonly<First>, ...ReduceTuple<Rest>] : T extends AnyArray<infer A> ? NotReadonly<A>[] : [];
9
+ export type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
10
+ infer First,
11
+ ...infer Rest extends AnyArray<ObjectT>
12
+ ] ? [TransformT<First>, ...ReduceTuple2<Rest>] : [];
13
+ export type NotReadonly<T> = T extends AnyArray ? ReduceTuple<T> : T extends object ? {
14
+ -readonly [P in keyof T]: T[P] extends Fn ? T[P] : T[P] extends TrueObject ? NotReadonly<T[P]> : T[P];
15
+ } : T;
16
+ export type SingleOrArray<T> = T | T[] | ReadonlyArray<T>;
17
+ export type SoA<T> = SingleOrArray<T>;
18
+ type RecursiveArrayOf<T> = Array<_SingleOrRecursiveArrayOf<T>> | ReadonlyArray<_SingleOrRecursiveArrayOf<T>>;
19
+ type _SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
20
+ export type SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
21
+ export type SoRa<T> = SingleOrRecursiveArrayOf<T>;
22
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { CUSTOM, SOA, SORA, UNION, PARTIAL, OPTIONAL, ARRAY } from '../constants';
2
+ import type { AnyArray } from './arrays.types';
3
+ import type { __ObjectT, ObjectMapS, ObjectT } from './typings.types';
4
+ export type Custom<T = any> = {
5
+ [CUSTOM]: T;
6
+ };
7
+ export type SoaCustom<T extends ObjectT = ObjectT> = {
8
+ [SOA]: T;
9
+ };
10
+ export type SoRaCustom<T extends ObjectT = ObjectT> = {
11
+ [SORA]: T;
12
+ };
13
+ export type UnionCustom<T extends ObjectT[] = ObjectT[]> = {
14
+ [UNION]: T;
15
+ };
16
+ export interface PartialCustom<T extends ObjectT = ObjectT> {
17
+ [PARTIAL]: T;
18
+ }
19
+ export type ArrayCustom<T extends ObjectT = any> = {
20
+ [ARRAY]: T;
21
+ };
22
+ export type Optional<T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT> = __ObjectT> = {
23
+ [OPTIONAL]: T;
24
+ };
25
+ export type IntersectionCustom<T extends ObjectMapS[]> = T extends [
26
+ infer First extends ObjectMapS,
27
+ ...infer Rest extends ObjectMapS[]
28
+ ] ? First & IntersectionCustom<Rest> : unknown;
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_types_undefiny = require("./undefiny.cjs");
3
+ exports.OptionalHelperClass = require_types_undefiny.OptionalHelperClass;
@@ -0,0 +1,8 @@
1
+ export * from './arrays.types';
2
+ export * from './customs.types';
3
+ export * from './standard.types';
4
+ export * from './transform.types';
5
+ export * from './types.types';
6
+ export * from './typings.types';
7
+ export * from './undefiny';
8
+ export * from './utilities.types';
@@ -0,0 +1,2 @@
1
+ import { OptionalHelperClass } from "./undefiny.js";
2
+ export { OptionalHelperClass };
@@ -0,0 +1,26 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import type { TransformT } from './transform.types';
3
+ import type { ObjectT, POS } from './typings.types';
4
+ import type { Optional } from './customs.types';
5
+ import type { Simplify } from './utilities.types';
6
+ import type { STANDARD_KEY } from '../constants';
7
+ export type * from '@standard-schema/spec';
8
+ export type StandardKey = keyof StandardSchemaV1;
9
+ export type StandardHelper<T1 = any, T2 = any> = {
10
+ __type: T1;
11
+ type: T2;
12
+ } & StandardSchemaV1<T2, T2>;
13
+ type _inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : T extends Optional<infer U> ? TransformT<U> | undefined : TransformT<T>;
14
+ export type inferO<T extends POS> = Simplify<_inferO<T>>;
15
+ type _Sh<T1 = any, T2 = any> = StandardHelper<T1, T2>;
16
+ export type Sh<T extends ObjectT = ObjectT> = StandardHelper<T, inferO<T>>;
17
+ export type StandardOutput<T = any> = {
18
+ [STANDARD_KEY]: {
19
+ types?: {
20
+ output: T;
21
+ };
22
+ };
23
+ };
24
+ export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
25
+ type _inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY]['types'], undefined>['output'];
26
+ export type inferT<T extends StandardOutput = StandardOutput> = _inferT<T>;
@@ -0,0 +1,22 @@
1
+ import type { UNION } from '../constants';
2
+ import type { AnyArray, ReduceTuple2, SoA, SoRa } from './arrays.types';
3
+ import type { ArrayCustom, Custom, Optional, PartialCustom, SoaCustom, SoRaCustom, UnionCustom } from './customs.types';
4
+ import type { JSON_Primitive, Primitive, PrimitiveObject } from './types.types';
5
+ import type { ObjectMapS, ObjectT, PrimitiveObjectMapS, PrimitiveObjectT, PrimitiveT, Types } from './typings.types';
6
+ import type { OptionalHelperClass, Undefiny } from './undefiny';
7
+ import type { EmptyObject, Equals } from './utilities.types';
8
+ 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;
9
+ 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 : T extends 'json' ? JSON_Primitive : Primitive;
10
+ export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends 'date' ? Date : T extends 'any' ? any : T extends 'unknown' ? unknown : object;
11
+ export type TransformT<T> = Equals<EmptyObject, T> extends true ? EmptyObject : Equals<ObjectMapS, T> extends true ? object : PrimitiveObjectT extends T ? PrimitiveObject : T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends UnionCustom ? __TransformUnion<T> : T extends SoRaCustom<infer TSoA> ? SoRa<TransformT<TSoA>> : T extends SoaCustom<infer TSoA> ? SoA<TransformT<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom<infer TPartial> ? Partial<TransformT<TPartial>> : T extends Optional<infer TOptional> ? TransformT<TOptional> | OptionalHelperClass : Undefiny<{
12
+ [K in keyof T]: TransformT<T[K]>;
13
+ }>;
14
+ type ReduceTupleSafePre<T extends ReadonlyArray<ObjectT>> = T extends readonly [
15
+ infer First extends ObjectT,
16
+ ...infer Rest extends ReadonlyArray<ObjectT>
17
+ ] ? readonly [SafePre<First>, ...ReduceTupleSafePre<Rest>] : [];
18
+ 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 : {
19
+ [K in keyof T]: T[K] extends infer Tk extends ObjectT ? _SafePre<Tk> : T[K];
20
+ };
21
+ export type SafePre<T extends ObjectT> = Extract<_SafePre<T>, ObjectT>;
22
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { SoRa } from './arrays.types';
2
+ import type { Keys } from './utilities.types';
3
+ export type JSON_Primitive = string | number | boolean | undefined;
4
+ export type Primitive = string | number | boolean | bigint | null | undefined | symbol | never;
5
+ export type PrimitiveObject = SoRa<JSON_Primitive | PrimitiveObjectMap>;
6
+ export interface PrimitiveObjectMap {
7
+ [key: Keys]: PrimitiveObject;
8
+ }
@@ -0,0 +1,24 @@
1
+ import type { JSON_PRIMITIVES, PRIMITIVE_OBJECTS, PRIMITIVES } from '../constants';
2
+ import type { SoRa } from './arrays.types';
3
+ import type { ArrayCustom, Custom, Optional, PartialCustom, UnionCustom } from './customs.types';
4
+ import type { Keys } from './utilities.types';
5
+ export type JSON_PrimitiveT = (typeof JSON_PRIMITIVES)[number];
6
+ export type PrimitiveT = (typeof PRIMITIVES)[number];
7
+ export type Types = PrimitiveT | (typeof PRIMITIVE_OBJECTS)[number];
8
+ export type PrimitiveObjectT = SoRa<JSON_PrimitiveT | PrimitiveObjectMapS | ArrayCustom<JSON_PrimitiveT | PrimitiveObjectMapS> | Optional<JSON_PrimitiveT | PrimitiveObjectMapS> | UnionCustom<(PrimitiveObjectMapS | JSON_PrimitiveT)[]> | PartialCustom<PrimitiveObjectMapS>>;
9
+ export interface PrimitiveObjectMapS {
10
+ [key: Keys]: PrimitiveObjectT;
11
+ }
12
+ export type __ObjectT = Types | ObjectMapS | Custom | PartialCustom | PrimitiveObjectT;
13
+ type _ObjectT = __ObjectT | Optional | ArrayCustom;
14
+ export type ObjectMapS = {
15
+ [key: Keys]: SoRa<_ObjectT>;
16
+ };
17
+ /**
18
+ * A type that represents a primitive object, which can be a primitive value or an object
19
+ *
20
+ * @remark
21
+ */
22
+ export type ObjectT = SoRa<_ObjectT>;
23
+ export type POS = ObjectT;
24
+ export {};
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/types/undefiny.ts
3
+ var OptionalHelperClass = class {
4
+ __NO_TYPE__ = "@bemedev/addons/NO_TYPE";
5
+ constructor() {}
6
+ };
7
+ //#endregion
8
+ exports.OptionalHelperClass = OptionalHelperClass;
@@ -0,0 +1,19 @@
1
+ import type { AnyArray } from './arrays.types';
2
+ import type { EmptyObject, Equals, TrueObject } from './utilities.types';
3
+ export declare class OptionalHelperClass {
4
+ readonly __NO_TYPE__ = "@bemedev/addons/NO_TYPE";
5
+ private constructor();
6
+ }
7
+ type HasUndefined<T> = unknown extends T ? false : Equals<EmptyObject, T> extends true ? false : OptionalHelperClass extends T ? true : false;
8
+ type _UndefinyObject<T extends object> = {
9
+ [K in keyof T as HasUndefined<T[K]> extends true ? never : K]: Undefiny<T[K]>;
10
+ } & {
11
+ [K in keyof T as HasUndefined<T[K]> extends true ? K : never]?: Undefiny<T[K]>;
12
+ };
13
+ type ReduceTupleU<T extends AnyArray> = T extends [
14
+ infer First,
15
+ ...infer Rest extends AnyArray
16
+ ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
17
+ type UndefinyObject<T extends object> = _UndefinyObject<T>;
18
+ export type Undefiny<T, U = Exclude<T, OptionalHelperClass>> = U extends AnyArray ? ReduceTupleU<U> : U extends TrueObject ? UndefinyObject<U> : U;
19
+ export {};
@@ -0,0 +1,7 @@
1
+ //#region src/types/undefiny.ts
2
+ var OptionalHelperClass = class {
3
+ __NO_TYPE__ = "@bemedev/addons/NO_TYPE";
4
+ constructor() {}
5
+ };
6
+ //#endregion
7
+ export { OptionalHelperClass };
@@ -0,0 +1,23 @@
1
+ import type { Primitive } from './types.types';
2
+ export type Keys = keyof any;
3
+ export type Ru = Record<Keys, unknown>;
4
+ export type Equals<T, U> = T extends U ? U extends T ? true : false : false;
5
+ export type TrueObject = Ru & {
6
+ [Symbol.iterator]?: never;
7
+ };
8
+ export type Fn<Args extends any[] = any[], R = any> = (...args: Args) => R;
9
+ export type NOmit<T, K extends keyof T> = Omit<T, K>;
10
+ export type StateValue = string | StateValueMap;
11
+ interface StateValueMap {
12
+ [key: string]: StateValue;
13
+ }
14
+ export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
15
+ export type EmptyObject = Record<string, never>;
16
+ type ReduceArraySimple<T extends any[]> = T extends [
17
+ infer First,
18
+ ...infer Rest extends any[]
19
+ ] ? [Simplify<First>, ...ReduceArraySimple<Rest>] : number extends T['length'] ? Simplify<T[number]>[] : T;
20
+ export type Simplify<T> = unknown extends T ? T : T extends Primitive ? T : T extends any[] ? ReduceArraySimple<T> : T extends TrueObject ? {
21
+ [K in keyof T]: Simplify<T[K]>;
22
+ } : T & {};
23
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",
@@ -35,10 +35,12 @@
35
35
  "./package.json": "./package.json",
36
36
  "./tsconfig.json": "./tsconfig.json",
37
37
  "./types": {
38
- "types": "./lib/types.d.ts"
38
+ "types": "./lib/types/index.d.ts",
39
+ "import": "./lib/types/index.js",
40
+ "require": "./lib/types/index.cjs"
39
41
  },
40
42
  "./standard": {
41
- "types": "./lib/standard.types.d.ts"
43
+ "types": "./lib/types/standard.types.d.ts"
42
44
  }
43
45
  },
44
46
  "maintainers": [
@@ -68,11 +70,10 @@
68
70
  "node": ">=24"
69
71
  },
70
72
  "scripts": {
71
- "prune": "pnpm store prune",
72
73
  "build": "pnpm rm:lib && pnpm run rolldown",
73
74
  "_ci": "pnpm clean --lockfile && pnpm run config:off && pnpm run lint && pnpm run test",
74
75
  "ci": "CI_START=$(date +%s) && pnpm run _ci && pnpm run p-q && echo \"\n✅ CI takes $(($(date +%s) - CI_START))s\n\"",
75
- "ci:admin": "CI_START=$(date +%s) && pnpm run prune && pnpm run rm && pnpm run upgrade:fast && pnpm run _ci && echo \"\n✅ Admin CI takes $(($(date +%s) - CI_START))s\n\"",
76
+ "ci:admin": "CI_START=$(date +%s) && pnpm run rm && pnpm run upgrade:fast && pnpm run _ci && echo \"\n✅ Admin CI takes $(($(date +%s) - CI_START))s\n\"",
76
77
  "clean": "pnpm run rm && pnpm run config",
77
78
  "config": "pnpm install",
78
79
  "config:off": "pnpm run config --offline",
@@ -1,3 +0,0 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- export type * from '@standard-schema/spec';
3
- export type StandardKey = keyof StandardSchemaV1;
package/lib/types.cjs DELETED
File without changes
package/lib/types.d.ts DELETED
@@ -1,140 +0,0 @@
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
- export type Ru = Record<Keys, unknown>;
4
- type Equals<T, U> = T extends U ? (U extends T ? true : false) : false;
5
- export type TrueObject = Ru & {
6
- [Symbol.iterator]?: never;
7
- };
8
- export type Fn<Args extends any[] = any[], R = any> = (...args: Args) => R;
9
- type ReduceTuple<T extends AnyArray> = T extends [
10
- infer First,
11
- ...infer Rest extends AnyArray
12
- ] ? [NotReadonly<First>, ...ReduceTuple<Rest>] : T extends AnyArray<infer A> ? NotReadonly<A>[] : [];
13
- export type NotReadonly<T> = T extends AnyArray ? ReduceTuple<T> : T extends object ? {
14
- -readonly [P in keyof T]: T[P] extends Fn ? T[P] : T[P] extends TrueObject ? NotReadonly<T[P]> : T[P];
15
- } : T;
16
- export type AnyArray<T = unknown> = ReadonlyArray<T> | T[];
17
- export type Keys = keyof any;
18
- export type NOmit<T, K extends keyof T> = Omit<T, K>;
19
- export type SingleOrArray<T> = T | T[] | ReadonlyArray<T>;
20
- export type SoA<T> = SingleOrArray<T>;
21
- export type StateValue = string | StateValueMap;
22
- interface StateValueMap {
23
- [key: string]: StateValue;
24
- }
25
- type RecursiveArrayOf<T> = Array<_SingleOrRecursiveArrayOf<T>> | ReadonlyArray<_SingleOrRecursiveArrayOf<T>>;
26
- type _SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
27
- export type SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
28
- export type SoRa<T> = SingleOrRecursiveArrayOf<T>;
29
- export type Primitive = string | number | boolean | bigint | null | undefined | symbol | never;
30
- export type PrimitiveT = (typeof PRIMITIVES)[number];
31
- 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;
32
- export type Types = PrimitiveT | (typeof PRIMITIVE_OBJECTS)[number];
33
- export type TransformTypes<T extends Types> = T extends PrimitiveT ? TransformPrimitiveS<T> : T extends 'date' ? Date : T extends 'any' ? any : T extends 'unknown' ? unknown : object;
34
- export type Custom<T = any> = {
35
- [CUSTOM]: T;
36
- };
37
- export type SoaCustom<T extends ObjectT = ObjectT> = {
38
- [SOA]: T;
39
- };
40
- export type SoRaCustom<T extends ObjectT = ObjectT> = {
41
- [SORA]: T;
42
- };
43
- export type UnionCustom<T extends ObjectT[] = ObjectT[]> = {
44
- [UNION]: T;
45
- };
46
- export interface PartialCustom<T extends ObjectT = ObjectT> {
47
- [PARTIAL]: T;
48
- }
49
- export type __ObjectT = Types | ObjectMapS | Custom | PartialCustom | PrimitiveObjectT;
50
- export type CanOptional = __ObjectT | ArrayCustom | AnyArray<__ObjectT>;
51
- export type Optional<T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT> = __ObjectT> = {
52
- [OPTIONAL]: T;
53
- };
54
- export type ArrayCustom<T extends ObjectT = any> = {
55
- [ARRAY]: T;
56
- };
57
- export type ObjectMapS = {
58
- [key: Keys]: SoRa<_ObjectT>;
59
- };
60
- declare class OptionalHelperClass {
61
- readonly __NO_TYPE__ = "@bemedev/addons/NO_TYPE";
62
- private constructor();
63
- }
64
- export type IntersectionCustom<T extends ObjectMapS[]> = T extends [
65
- infer First extends ObjectMapS,
66
- ...infer Rest extends ObjectMapS[]
67
- ] ? First & IntersectionCustom<Rest> : unknown;
68
- type _ObjectT = __ObjectT | Optional | ArrayCustom;
69
- export type PrimitiveObjectT = SoRa<PrimitiveT | PrimitiveObjectMapS | ArrayCustom<PrimitiveT | PrimitiveObjectMapS> | Optional<PrimitiveT | PrimitiveObjectMapS> | UnionCustom<(PrimitiveObjectMapS | PrimitiveT)[]> | PartialCustom<PrimitiveObjectMapS>>;
70
- export interface PrimitiveObjectMapS {
71
- [key: Keys]: PrimitiveObjectT;
72
- }
73
- /**
74
- * A type that represents a primitive object, which can be a primitive value or an object
75
- *
76
- * @remark
77
- */
78
- export type ObjectT = SoRa<_ObjectT>;
79
- export type POS = ObjectT;
80
- type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
81
- infer First,
82
- ...infer Rest extends AnyArray<ObjectT>
83
- ] ? [TransformT<First>, ...ReduceTuple2<Rest>] : [];
84
- type ReduceTupleU<T extends AnyArray> = T extends [
85
- infer First,
86
- ...infer Rest extends AnyArray
87
- ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
88
- export type EmptyObject = Record<string, never>;
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 HasUndefined<T> = unknown extends T ? false : Equals<EmptyObject, T> extends true ? false : OptionalHelperClass extends T ? true : false;
91
- type _UndefinyObject<T extends object> = {
92
- [K in keyof T as HasUndefined<T[K]> extends true ? never : K]: Undefiny<T[K]>;
93
- } & {
94
- [K in keyof T as HasUndefined<T[K]> extends true ? K : never]?: Undefiny<T[K]>;
95
- };
96
- type UndefinyObject<T extends object> = _UndefinyObject<T>;
97
- type Undefiny<T, U = Exclude<T, OptionalHelperClass>> = U extends AnyArray ? ReduceTupleU<U> : U extends TrueObject ? UndefinyObject<U> : U;
98
- type TransformT<T> = Equals<EmptyObject, T> extends true ? EmptyObject : Equals<ObjectMapS, T> extends true ? object : PrimitiveObjectT extends T ? PrimitiveObject : T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends UnionCustom ? __TransformUnion<T> : T extends SoRaCustom<infer TSoA> ? SoRa<TransformT<TSoA>> : T extends SoaCustom<infer TSoA> ? SoA<TransformT<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom<infer TPartial> ? Partial<TransformT<TPartial>> : T extends Optional<infer TOptional> ? TransformT<TOptional> | OptionalHelperClass : Undefiny<{
99
- [K in keyof T]: TransformT<T[K]>;
100
- }>;
101
- export type StandardHelper<T1 = any, T2 = any> = {
102
- __type: T1;
103
- type: T2;
104
- } & StandardSchemaV1<T2, T2>;
105
- type _Sh<T1 = any, T2 = any> = StandardHelper<T1, T2>;
106
- export type Sh<T extends ObjectT = ObjectT> = StandardHelper<T, inferO<T>>;
107
- export type StandardOutput<T = any> = {
108
- [STANDARD_KEY]: {
109
- types?: {
110
- output: T;
111
- };
112
- };
113
- };
114
- export type PrimitiveObject = SoRa<Primitive | PrimitiveObjectMap>;
115
- export interface PrimitiveObjectMap {
116
- [key: Keys]: PrimitiveObject;
117
- }
118
- type _inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : T extends Optional<infer U> ? TransformT<U> | undefined : TransformT<T>;
119
- type ReduceArraySimple<T extends any[]> = T extends [
120
- infer First,
121
- ...infer Rest extends any[]
122
- ] ? [Simplify<First>, ...ReduceArraySimple<Rest>] : number extends T['length'] ? Simplify<T[number]>[] : T;
123
- export type Simplify<T> = unknown extends T ? T : T extends Primitive ? T : T extends any[] ? ReduceArraySimple<T> : T extends TrueObject ? {
124
- [K in keyof T]: Simplify<T[K]>;
125
- } : T & {};
126
- export type inferO<T extends POS> = Simplify<_inferO<T>>;
127
- export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
128
- type _inferT<T extends StandardOutput = StandardOutput> = Exclude<T[typeof STANDARD_KEY]['types'], undefined>['output'];
129
- export type inferT<T extends StandardOutput = StandardOutput> = _inferT<T>;
130
- export type ProduceObject<T extends ObjectT = ObjectT> = T;
131
- export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
132
- type ReduceTupleSafePre<T extends ReadonlyArray<ObjectT>> = T extends readonly [
133
- infer First extends ObjectT,
134
- ...infer Rest extends ReadonlyArray<ObjectT>
135
- ] ? readonly [SafePre<First>, ...ReduceTupleSafePre<Rest>] : [];
136
- 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 : {
137
- [K in keyof T]: T[K] extends infer Tk extends ObjectT ? _SafePre<Tk> : T[K];
138
- };
139
- export type SafePre<T extends ObjectT> = Extract<_SafePre<T>, ObjectT>;
140
- export * from './standard.types';
package/lib/types.js DELETED
@@ -1 +0,0 @@
1
- export {};