@bemedev/typings 0.5.4 → 0.5.5

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
@@ -52,6 +52,7 @@ expectTypeOf(result).toEqualTypeOf<{
52
52
  - `primitiveObject`: Primitive object schema
53
53
  - `record`: Record types
54
54
  - `soa`: Single or Array types
55
+ - `sora`: Single or Array types, with recursive support, (soa with recursion)
55
56
  - `sv`: State Value
56
57
  - `tuple`: Tuple types
57
58
  - `union`: Union types
package/lib/constants.cjs CHANGED
@@ -23,7 +23,9 @@ const CUSTOM = "$$app-ts => custom$$";
23
23
  const PARTIAL = "$$app-ts => partial$$";
24
24
  const ARRAY = "$$app-ts => array$$";
25
25
  const SOA = "$$app-ts => soa$$";
26
+ const SORA = "$$app-ts => sora$$";
26
27
  const LITTERALS = "$$app-ts => litterals$$";
28
+ const STANDARD_KEY = "~standard";
27
29
  //#endregion
28
30
  exports.ARRAY = ARRAY;
29
31
  exports.CUSTOM = CUSTOM;
@@ -33,4 +35,6 @@ exports.PARTIAL = PARTIAL;
33
35
  exports.PRIMITIVES = PRIMITIVES;
34
36
  exports.PRIMITIVE_OBJECTS = PRIMITIVE_OBJECTS;
35
37
  exports.SOA = SOA;
38
+ exports.SORA = SORA;
39
+ exports.STANDARD_KEY = STANDARD_KEY;
36
40
  exports.UNION = UNION;
@@ -6,4 +6,6 @@ export declare const CUSTOM = "$$app-ts => custom$$";
6
6
  export declare const PARTIAL = "$$app-ts => partial$$";
7
7
  export declare const ARRAY = "$$app-ts => array$$";
8
8
  export declare const SOA = "$$app-ts => soa$$";
9
+ export declare const SORA = "$$app-ts => sora$$";
9
10
  export declare const LITTERALS = "$$app-ts => litterals$$";
11
+ export declare const STANDARD_KEY = "~standard";
package/lib/constants.js CHANGED
@@ -22,6 +22,8 @@ const CUSTOM = "$$app-ts => custom$$";
22
22
  const PARTIAL = "$$app-ts => partial$$";
23
23
  const ARRAY = "$$app-ts => array$$";
24
24
  const SOA = "$$app-ts => soa$$";
25
+ const SORA = "$$app-ts => sora$$";
25
26
  const LITTERALS = "$$app-ts => litterals$$";
27
+ const STANDARD_KEY = "~standard";
26
28
  //#endregion
27
- export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION };
29
+ export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION };
@@ -13,6 +13,7 @@ const require_helpers_readonly = require("./readonly.cjs");
13
13
  const require_helpers_object = require("./object.cjs");
14
14
  const require_helpers_record = require("./record.cjs");
15
15
  const require_helpers_soa = require("./soa.cjs");
16
+ const require_helpers_sora = require("./sora.cjs");
16
17
  const require_helpers_sv = require("./sv.cjs");
17
18
  const require_helpers_tuple = require("./tuple.cjs");
18
19
  exports.any = require_helpers_any.any;
@@ -28,6 +29,7 @@ exports.primitiveObject = require_helpers_primitiveObject.primitiveObject;
28
29
  exports.readonly = require_helpers_readonly.readonly;
29
30
  exports.record = require_helpers_record.record;
30
31
  exports.soa = require_helpers_soa.soa;
32
+ exports.sora = require_helpers_sora.sora;
31
33
  exports.sv = require_helpers_sv.sv;
32
34
  exports.tuple = require_helpers_tuple.tuple;
33
35
  exports.union = require_helpers_union.union;
@@ -1,16 +1,17 @@
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 "./sora";
14
+ export * from "./sv";
15
+ export * from "./tuple";
16
+ export * from "./union";
17
+ export * from "./object";
@@ -12,6 +12,7 @@ import { readonly } from "./readonly.js";
12
12
  import { object } from "./object.js";
13
13
  import { record } from "./record.js";
14
14
  import { soa } from "./soa.js";
15
+ import { sora } from "./sora.js";
15
16
  import { sv } from "./sv.js";
16
17
  import { tuple } from "./tuple.js";
17
- export { any, array, custom, intersection, litterals, object, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union };
18
+ export { any, array, custom, intersection, litterals, object, optional, partial, primitive, primitiveObject, readonly, record, soa, sora, sv, tuple, union };
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_standard = require("../standard.cjs");
3
+ //#region src/helpers/sora.ts
4
+ const sora = (value) => {
5
+ return require_standard.standardize2(value);
6
+ };
7
+ //#endregion
8
+ exports.sora = sora;
@@ -0,0 +1,2 @@
1
+ import type { NotReadonly, ObjectT, SoRaCustom } from "../types";
2
+ export declare const sora: <const T extends ObjectT>(value?: T) => ObjectT extends NotReadonly<T> ? "any" : SoRaCustom<NotReadonly<T>>;
@@ -0,0 +1,7 @@
1
+ import { standardize2 } from "../standard.js";
2
+ //#region src/helpers/sora.ts
3
+ const sora = (value) => {
4
+ return standardize2(value);
5
+ };
6
+ //#endregion
7
+ export { sora };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_constants = require("../constants.cjs");
2
3
  const require_standard = require("../standard.cjs");
3
4
  const require_utils_expandFn = require("../utils/expandFn.cjs");
4
- const require_constants = require("../constants.cjs");
5
5
  //#region src/helpers/union.ts
6
6
  const _union = (...values) => {
7
7
  return require_standard.standardize2({ [require_constants.UNION]: values });
@@ -1,6 +1,6 @@
1
+ import { UNION } from "../constants.js";
1
2
  import { standardize2 } from "../standard.js";
2
3
  import { expandFn } from "../utils/expandFn.js";
3
- import { UNION } from "../constants.js";
4
4
  //#region src/helpers/union.ts
5
5
  const _union = (...values) => {
6
6
  return standardize2({ [UNION]: values });
package/lib/index.cjs CHANGED
@@ -9,5 +9,7 @@ exports.PARTIAL = require_constants.PARTIAL;
9
9
  exports.PRIMITIVES = require_constants.PRIMITIVES;
10
10
  exports.PRIMITIVE_OBJECTS = require_constants.PRIMITIVE_OBJECTS;
11
11
  exports.SOA = require_constants.SOA;
12
+ exports.SORA = require_constants.SORA;
13
+ exports.STANDARD_KEY = require_constants.STANDARD_KEY;
12
14
  exports.UNION = require_constants.UNION;
13
15
  exports.type = require_type.type;
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION } from "./constants.js";
1
+ import { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION } from "./constants.js";
2
2
  import { type } from "./type.js";
3
- export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION, type };
3
+ export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, type };
package/lib/standard.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_constants = require("./constants.cjs");
2
3
  //#region src/standard.ts
3
4
  const _standardize = (value) => {
4
5
  return {
5
6
  value,
6
- "~standard": {
7
+ [require_constants.STANDARD_KEY]: {
7
8
  version: 1,
8
9
  vendor: "@bemedev/typings",
9
10
  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>;
package/lib/standard.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { STANDARD_KEY } from "./constants.js";
1
2
  //#region src/standard.ts
2
3
  const _standardize = (value) => {
3
4
  return {
4
5
  value,
5
- "~standard": {
6
+ [STANDARD_KEY]: {
6
7
  version: 1,
7
8
  vendor: "@bemedev/typings",
8
9
  types: {
@@ -1,7 +1,9 @@
1
+ import type { STANDARD_KEY } from "./constants";
2
+ export type StandardKey = typeof STANDARD_KEY;
1
3
  /** The Standard Schema interface. */
2
4
  export interface StandardSchemaV1<Input = unknown, Output = Input> {
3
5
  /** The Standard Schema properties. */
4
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
6
+ readonly [STANDARD_KEY]: StandardSchemaV1.Props<Input, Output>;
5
7
  }
6
8
  export declare namespace StandardSchemaV1 {
7
9
  /** The Standard Schema properties interface. */
@@ -53,7 +55,7 @@ export declare namespace StandardSchemaV1 {
53
55
  readonly output: Output;
54
56
  }
55
57
  /** Infers the input type of a Standard Schema. */
56
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
58
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema[StandardKey]["types"]>["input"];
57
59
  /** Infers the output type of a Standard Schema. */
58
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
60
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema[StandardKey]["types"]>["output"];
59
61
  }
package/lib/type.cjs CHANGED
@@ -14,6 +14,7 @@ const require_helpers_readonly = require("./helpers/readonly.cjs");
14
14
  const require_helpers_object = require("./helpers/object.cjs");
15
15
  const require_helpers_record = require("./helpers/record.cjs");
16
16
  const require_helpers_soa = require("./helpers/soa.cjs");
17
+ const require_helpers_sora = require("./helpers/sora.cjs");
17
18
  const require_helpers_sv = require("./helpers/sv.cjs");
18
19
  const require_helpers_tuple = require("./helpers/tuple.cjs");
19
20
  require("./helpers/index.cjs");
@@ -40,7 +41,8 @@ const type = (option) => {
40
41
  primitiveObject: require_helpers_primitiveObject.primitiveObject,
41
42
  primitive: require_helpers_primitive.primitive,
42
43
  readonly: require_helpers_readonly.readonly,
43
- object: require_helpers_object.object
44
+ object: require_helpers_object.object,
45
+ sora: require_helpers_sora.sora
44
46
  }));
45
47
  else out = _transform(option);
46
48
  return require_standard.standardize(out);
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, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union } from './helpers';
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, sora } from "./helpers";
3
3
  type Helpers = {
4
4
  any: typeof any;
5
5
  custom: typeof custom;
@@ -17,6 +17,7 @@ type Helpers = {
17
17
  primitive: typeof primitive;
18
18
  readonly: typeof readonly;
19
19
  object: typeof object;
20
+ sora: typeof sora;
20
21
  };
21
22
  export type Transform_F = <T extends ObjectT = ObjectT>(option?: ((helpers: Helpers) => T) | T) => inferSh<T>;
22
23
  export declare const type: Transform_F;
package/lib/type.js CHANGED
@@ -13,6 +13,7 @@ import { readonly } from "./helpers/readonly.js";
13
13
  import { object } from "./helpers/object.js";
14
14
  import { record } from "./helpers/record.js";
15
15
  import { soa } from "./helpers/soa.js";
16
+ import { sora } from "./helpers/sora.js";
16
17
  import { sv } from "./helpers/sv.js";
17
18
  import { tuple } from "./helpers/tuple.js";
18
19
  import "./helpers/index.js";
@@ -39,7 +40,8 @@ const type = (option) => {
39
40
  primitiveObject,
40
41
  primitive,
41
42
  readonly,
42
- object
43
+ object,
44
+ sora
43
45
  }));
44
46
  else out = _transform(option);
45
47
  return standardize(out);
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, UNION } from './constants';
2
- import type { StandardSchemaV1 } from './standard.types';
1
+ import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, UNION } from "./constants";
2
+ import type { StandardKey, 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
36
  export type SoaCustom<T extends ObjectT = ObjectT> = {
37
37
  [SOA]: T;
38
38
  };
39
+ export type SoRaCustom<T extends ObjectT = ObjectT> = {
40
+ [SORA]: T;
41
+ };
39
42
  export type UnionCustom<T extends ObjectT[] = ObjectT[]> = {
40
43
  [UNION]: T;
41
44
  };
@@ -80,8 +83,8 @@ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
80
83
  type ReduceTupleU<T extends AnyArray> = T extends [
81
84
  infer First,
82
85
  ...infer Rest extends AnyArray
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 : {
86
+ ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T["length"] extends 0 ? [] : number extends T["length"] ? T : Undefiny<T[number]>[];
87
+ 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 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 ? Partial<__TransformPrimitiveObject<NOmit<T, typeof PARTIAL>>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
85
88
  [K in keyof T]: __TransformPrimitiveObject<T[K]>;
86
89
  };
87
90
  type HasUndefined<T> = unknown extends T ? false : OptionalHelperClass extends T ? true : false;
@@ -101,7 +104,7 @@ export type Sh<T = any> = StandardHelper<T>;
101
104
  export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
102
105
  export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
103
106
  export type inferSh<T extends ObjectT = ObjectT> = Sh<inferO<T>>;
104
- export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T['~standard']['types'], undefined>['output'];
107
+ export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[StandardKey]["types"], undefined>["output"];
105
108
  export type ProduceObject<T extends ObjectT = ObjectT> = T;
106
109
  export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
107
110
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",
@@ -100,20 +100,20 @@
100
100
  }
101
101
  ],
102
102
  "devDependencies": {
103
- "@bemedev/dev-utils": "^0.6.4",
103
+ "@bemedev/dev-utils": "^0.6.6",
104
104
  "@bemedev/fsf": "^1.0.1",
105
105
  "@size-limit/file": "^12.1.0",
106
106
  "@types/node": "^25.6.0",
107
107
  "@vitest/coverage-v8": "^4.1.5",
108
108
  "@vitest/ui": "4.1.5",
109
109
  "glob": "^13.0.6",
110
- "globals": "^17.5.0",
110
+ "globals": "^17.6.0",
111
111
  "husky": "^9.1.7",
112
112
  "onchange": "^7.1.0",
113
- "oxfmt": "^0.46.0",
114
- "oxlint": "^1.61.0",
113
+ "oxfmt": "^0.47.0",
114
+ "oxlint": "^1.62.0",
115
115
  "pretty-quick": "^4.2.2",
116
- "rolldown": "1.0.0-rc.17",
116
+ "rolldown": "1.0.0-rc.18",
117
117
  "size-limit": "^12.1.0",
118
118
  "tslib": "^2.8.1",
119
119
  "typescript": "^6.0.3",