@bemedev/typings 0.5.6 → 1.0.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.
- package/README.md +1 -0
- package/lib/constants.cjs +2 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/helpers/array.cjs +3 -4
- package/lib/helpers/array.js +1 -1
- package/lib/helpers/custom.cjs +1 -3
- package/lib/helpers/custom.d.ts +1 -1
- package/lib/helpers/custom.js +0 -2
- package/lib/helpers/index.cjs +2 -0
- package/lib/helpers/index.d.ts +19 -18
- package/lib/helpers/index.js +2 -1
- package/lib/helpers/litterals.cjs +2 -2
- package/lib/helpers/litterals.js +1 -1
- package/lib/helpers/object.cjs +3 -4
- package/lib/helpers/object.d.ts +1 -1
- package/lib/helpers/object.js +1 -1
- package/lib/helpers/omit.cjs +3 -4
- package/lib/helpers/omit.d.ts +1 -1
- package/lib/helpers/omit.js +1 -1
- package/lib/helpers/primitive.cjs +2 -2
- package/lib/helpers/primitive.js +1 -1
- package/lib/helpers/primitiveObject.cjs +3 -3
- package/lib/helpers/primitiveObject.js +1 -1
- package/lib/helpers/sv.cjs +3 -4
- package/lib/helpers/sv.js +1 -1
- package/lib/helpers/use.cjs +5 -0
- package/lib/helpers/use.d.ts +2 -0
- package/lib/helpers/use.js +4 -0
- package/lib/index.cjs +1 -0
- package/lib/index.js +2 -2
- package/lib/standard.cjs +1 -1
- package/lib/standard.d.ts +1 -1
- package/lib/standard.js +2 -2
- package/lib/standard.types.d.ts +3 -61
- package/lib/type.cjs +3 -1
- package/lib/type.d.ts +3 -2
- package/lib/type.js +3 -1
- package/lib/types.d.ts +2 -2
- package/lib/utils/_const.cjs +5 -0
- package/lib/utils/_const.d.ts +2 -0
- package/lib/utils/_const.js +4 -0
- package/lib/utils/index.cjs +4 -4
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.js +3 -4
- package/lib/utils/isSh.cjs +10 -0
- package/lib/utils/isSh.d.ts +2 -0
- package/lib/utils/isSh.js +9 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ expectTypeOf(result).toEqualTypeOf<{
|
|
|
51
51
|
- `omit`: Omit specific keys from an object
|
|
52
52
|
- `optional`: Optional types
|
|
53
53
|
- `partial`: Partial types
|
|
54
|
+
- `primitive`: Primitive type definitions
|
|
54
55
|
- `primitiveObject`: Primitive object schema
|
|
55
56
|
- `readonly`: Readonly object types
|
|
56
57
|
- `record`: Record types
|
package/lib/constants.cjs
CHANGED
|
@@ -26,6 +26,7 @@ const SOA = "$$app-ts => soa$$";
|
|
|
26
26
|
const SORA = "$$app-ts => sora$$";
|
|
27
27
|
const LITTERALS = "$$app-ts => litterals$$";
|
|
28
28
|
const STANDARD_KEY = "~standard";
|
|
29
|
+
const vendor = "@bemedev/typings";
|
|
29
30
|
//#endregion
|
|
30
31
|
exports.ARRAY = ARRAY;
|
|
31
32
|
exports.CUSTOM = CUSTOM;
|
|
@@ -38,3 +39,4 @@ exports.SOA = SOA;
|
|
|
38
39
|
exports.SORA = SORA;
|
|
39
40
|
exports.STANDARD_KEY = STANDARD_KEY;
|
|
40
41
|
exports.UNION = UNION;
|
|
42
|
+
exports.vendor = vendor;
|
package/lib/constants.d.ts
CHANGED
package/lib/constants.js
CHANGED
|
@@ -25,5 +25,6 @@ const SOA = "$$app-ts => soa$$";
|
|
|
25
25
|
const SORA = "$$app-ts => sora$$";
|
|
26
26
|
const LITTERALS = "$$app-ts => litterals$$";
|
|
27
27
|
const STANDARD_KEY = "~standard";
|
|
28
|
+
const vendor = "@bemedev/typings";
|
|
28
29
|
//#endregion
|
|
29
|
-
export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION };
|
|
30
|
+
export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, vendor };
|
package/lib/helpers/array.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
5
4
|
//#region src/helpers/array.ts
|
|
6
|
-
const array =
|
|
5
|
+
const array = require("../utils/expandFn.cjs").expandFn2((value) => {
|
|
7
6
|
return require_standard.standardize2([value]);
|
|
8
|
-
},
|
|
7
|
+
}, require_utils__const._const());
|
|
9
8
|
//#endregion
|
|
10
9
|
exports.array = array;
|
package/lib/helpers/array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/array.ts
|
|
5
5
|
const array = expandFn2((value) => {
|
|
6
6
|
return standardize2([value]);
|
package/lib/helpers/custom.cjs
CHANGED
|
@@ -1,8 +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");
|
|
4
3
|
//#region src/helpers/custom.ts
|
|
5
|
-
require("../utils/index.cjs")._const("any");
|
|
6
4
|
/**
|
|
7
5
|
* Create a custom value that can be used in the state value or as a literal.
|
|
8
6
|
* @param value The value to create the custom value from.
|
|
@@ -18,7 +16,7 @@ require("../utils/index.cjs")._const("any");
|
|
|
18
16
|
*
|
|
19
17
|
* @see {@link Custom} for more information about custom values.
|
|
20
18
|
*/
|
|
21
|
-
const custom =
|
|
19
|
+
const custom = require("../utils/expandFn.cjs").expandFn2((value) => {
|
|
22
20
|
return require_standard.standardize2(value);
|
|
23
21
|
}, "any");
|
|
24
22
|
//#endregion
|
package/lib/helpers/custom.d.ts
CHANGED
package/lib/helpers/custom.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
2
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
3
|
//#region src/helpers/custom.ts
|
|
5
|
-
_const("any");
|
|
6
4
|
/**
|
|
7
5
|
* Create a custom value that can be used in the state value or as a literal.
|
|
8
6
|
* @param value The value to create the custom value from.
|
package/lib/helpers/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_helpers_any = require("./any.cjs");
|
|
|
3
3
|
const require_helpers_array = require("./array.cjs");
|
|
4
4
|
const require_helpers_custom = require("./custom.cjs");
|
|
5
5
|
const require_helpers_intersection = require("./intersection.cjs");
|
|
6
|
+
const require_helpers_use = require("./use.cjs");
|
|
6
7
|
const require_helpers_union = require("./union.cjs");
|
|
7
8
|
const require_helpers_litterals = require("./litterals.cjs");
|
|
8
9
|
const require_helpers_optional = require("./optional.cjs");
|
|
@@ -35,3 +36,4 @@ exports.sora = require_helpers_sora.sora;
|
|
|
35
36
|
exports.sv = require_helpers_sv.sv;
|
|
36
37
|
exports.tuple = require_helpers_tuple.tuple;
|
|
37
38
|
exports.union = require_helpers_union.union;
|
|
39
|
+
exports.use = require_helpers_use.use;
|
package/lib/helpers/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
1
|
+
export * from "./any";
|
|
2
|
+
export * from "./array";
|
|
3
|
+
export * from "./custom";
|
|
4
|
+
export * from "./intersection";
|
|
5
|
+
export * from "./use";
|
|
6
|
+
export * from "./litterals";
|
|
7
|
+
export * from "./optional";
|
|
8
|
+
export * from "./partial";
|
|
9
|
+
export * from "./primitive";
|
|
10
|
+
export * from "./primitiveObject";
|
|
11
|
+
export * from "./readonly";
|
|
12
|
+
export * from "./record";
|
|
13
|
+
export * from "./soa";
|
|
14
|
+
export * from "./sora";
|
|
15
|
+
export * from "./sv";
|
|
16
|
+
export * from "./tuple";
|
|
17
|
+
export * from "./union";
|
|
18
|
+
export * from "./object";
|
|
19
|
+
export * from "./omit";
|
package/lib/helpers/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { any } from "./any.js";
|
|
|
2
2
|
import { array } from "./array.js";
|
|
3
3
|
import { custom } from "./custom.js";
|
|
4
4
|
import { intersection } from "./intersection.js";
|
|
5
|
+
import { use } from "./use.js";
|
|
5
6
|
import { union } from "./union.js";
|
|
6
7
|
import { litterals } from "./litterals.js";
|
|
7
8
|
import { optional } from "./optional.js";
|
|
@@ -16,4 +17,4 @@ import { sora } from "./sora.js";
|
|
|
16
17
|
import { sv } from "./sv.js";
|
|
17
18
|
import { tuple } from "./tuple.js";
|
|
18
19
|
import { omit } from "./omit.js";
|
|
19
|
-
export { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sora, sv, tuple, union };
|
|
20
|
+
export { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sora, sv, tuple, union, use };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
3
4
|
const require_utils_expandFn = require("../utils/expandFn.cjs");
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
5
5
|
const require_helpers_union = require("./union.cjs");
|
|
6
6
|
//#region src/helpers/litterals.ts
|
|
7
7
|
const litterals = require_utils_expandFn.expandFn2((...values) => {
|
|
8
8
|
return require_standard.standardize2(values[0]);
|
|
9
|
-
},
|
|
9
|
+
}, require_utils__const._const(require_helpers_union.union("string", "number", "boolean")));
|
|
10
10
|
//#endregion
|
|
11
11
|
exports.litterals = litterals;
|
package/lib/helpers/litterals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
import { union } from "./union.js";
|
|
5
5
|
//#region src/helpers/litterals.ts
|
|
6
6
|
const litterals = expandFn2((...values) => {
|
package/lib/helpers/object.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
5
4
|
//#region src/helpers/object.ts
|
|
6
|
-
const object =
|
|
5
|
+
const object = require("../utils/expandFn.cjs").expandFn2((value) => {
|
|
7
6
|
return require_standard.standardize2(value);
|
|
8
|
-
},
|
|
7
|
+
}, require_utils__const._const());
|
|
9
8
|
//#endregion
|
|
10
9
|
exports.object = object;
|
package/lib/helpers/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NotReadonly, ObjectMapS } from
|
|
1
|
+
import type { NotReadonly, ObjectMapS } from '../types';
|
|
2
2
|
export declare const object: import("..").FnBasic<(<const T extends ObjectMapS>(value?: T) => ObjectMapS extends T ? ObjectMapS : NotReadonly<T>), object & {
|
|
3
3
|
const: ObjectMapS;
|
|
4
4
|
type: ObjectMapS;
|
package/lib/helpers/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/object.ts
|
|
5
5
|
const object = expandFn2((value) => {
|
|
6
6
|
return standardize2(value);
|
package/lib/helpers/omit.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
5
4
|
//#region src/helpers/omit.ts
|
|
6
|
-
const omit =
|
|
5
|
+
const omit = require("../utils/expandFn.cjs").expandFn2((value, _) => {
|
|
7
6
|
return require_standard.standardize2(value);
|
|
8
|
-
},
|
|
7
|
+
}, require_utils__const._const(), { strict: (value, _) => {
|
|
9
8
|
return require_standard.standardize2(value);
|
|
10
9
|
} });
|
|
11
10
|
//#endregion
|
package/lib/helpers/omit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Keys, NOmit, NotReadonly, ObjectMapS } from
|
|
1
|
+
import type { Keys, NOmit, NotReadonly, ObjectMapS } from '../types';
|
|
2
2
|
export declare const omit: import("..").FnBasic<(<const T extends ObjectMapS, K extends Keys>(value: T, _: K) => ObjectMapS extends T ? ObjectMapS : Omit<NotReadonly<T>, K>), {
|
|
3
3
|
readonly strict: <const T extends ObjectMapS, const K extends keyof T = keyof T>(value: T, _: K) => ObjectMapS extends T ? ObjectMapS : NOmit<NotReadonly<T>, K>;
|
|
4
4
|
} & {
|
package/lib/helpers/omit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/omit.ts
|
|
5
5
|
const omit = expandFn2((value, _) => {
|
|
6
6
|
return standardize2(value);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
3
4
|
const require_utils_expandFn = require("../utils/expandFn.cjs");
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
5
5
|
//#region src/helpers/primitive.ts
|
|
6
|
-
const primitive = require_utils_expandFn.expandFn2((value) => require_standard.standardize2(value),
|
|
6
|
+
const primitive = require_utils_expandFn.expandFn2((value) => require_standard.standardize2(value), require_utils__const._const(), {
|
|
7
7
|
boolean: require_utils_expandFn.expandFn2((value) => {
|
|
8
8
|
return require_standard.standardize2(value);
|
|
9
9
|
}, "boolean"),
|
package/lib/helpers/primitive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/primitive.ts
|
|
5
5
|
const primitive = expandFn2((value) => standardize2(value), _const(), {
|
|
6
6
|
boolean: expandFn2((value) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
3
4
|
const require_utils_expandFn = require("../utils/expandFn.cjs");
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
5
5
|
//#region src/helpers/primitiveObject.ts
|
|
6
6
|
const primitiveObject = require_utils_expandFn.expandFn2((value) => {
|
|
7
7
|
return require_standard.standardize2(value);
|
|
8
|
-
},
|
|
8
|
+
}, require_utils__const._const(), { map: require_utils_expandFn.expandFn2((value) => {
|
|
9
9
|
return require_standard.standardize2(value);
|
|
10
|
-
},
|
|
10
|
+
}, require_utils__const._const()) });
|
|
11
11
|
//#endregion
|
|
12
12
|
exports.primitiveObject = primitiveObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/primitiveObject.ts
|
|
5
5
|
const primitiveObject = expandFn2((value) => {
|
|
6
6
|
return standardize2(value);
|
package/lib/helpers/sv.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_standard = require("../standard.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_utils_index = require("../utils/index.cjs");
|
|
3
|
+
const require_utils__const = require("../utils/_const.cjs");
|
|
5
4
|
//#region src/helpers/sv.ts
|
|
6
|
-
const sv =
|
|
5
|
+
const sv = require("../utils/expandFn.cjs").expandFn2((value) => {
|
|
7
6
|
return require_standard.standardize2(value);
|
|
8
|
-
},
|
|
7
|
+
}, require_utils__const._const());
|
|
9
8
|
//#endregion
|
|
10
9
|
exports.sv = sv;
|
package/lib/helpers/sv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { standardize2 } from "../standard.js";
|
|
2
|
+
import { _const } from "../utils/_const.js";
|
|
2
3
|
import { expandFn2 } from "../utils/expandFn.js";
|
|
3
|
-
import { _const } from "../utils/index.js";
|
|
4
4
|
//#region src/helpers/sv.ts
|
|
5
5
|
const sv = expandFn2((value) => {
|
|
6
6
|
return standardize2(value);
|
package/lib/index.cjs
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION } from "./constants.js";
|
|
1
|
+
import { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, vendor } from "./constants.js";
|
|
2
2
|
import { pretype, type } from "./type.js";
|
|
3
|
-
export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, pretype, type };
|
|
3
|
+
export { ARRAY, CUSTOM, LITTERALS, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, SORA, STANDARD_KEY, UNION, pretype, type, vendor };
|
package/lib/standard.cjs
CHANGED
package/lib/standard.d.ts
CHANGED
package/lib/standard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STANDARD_KEY } from "./constants.js";
|
|
1
|
+
import { STANDARD_KEY, vendor } from "./constants.js";
|
|
2
2
|
//#region src/standard.ts
|
|
3
3
|
const _standardize = (__type) => {
|
|
4
4
|
return {
|
|
@@ -6,7 +6,7 @@ const _standardize = (__type) => {
|
|
|
6
6
|
type: __type,
|
|
7
7
|
[STANDARD_KEY]: {
|
|
8
8
|
version: 1,
|
|
9
|
-
vendor
|
|
9
|
+
vendor,
|
|
10
10
|
types: {
|
|
11
11
|
input: __type,
|
|
12
12
|
output: __type
|
package/lib/standard.types.d.ts
CHANGED
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
5
|
-
/** The Standard Schema properties. */
|
|
6
|
-
readonly [STANDARD_KEY]: StandardSchemaV1.Props<Input, Output>;
|
|
7
|
-
}
|
|
8
|
-
export declare namespace StandardSchemaV1 {
|
|
9
|
-
/** The Standard Schema properties interface. */
|
|
10
|
-
interface Props<Input = unknown, Output = Input> {
|
|
11
|
-
/** The version number of the standard. */
|
|
12
|
-
readonly version: 1;
|
|
13
|
-
/** The vendor name of the schema library. */
|
|
14
|
-
readonly vendor: string;
|
|
15
|
-
/** Validates unknown input values. */
|
|
16
|
-
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
17
|
-
/** Inferred types associated with the schema. */
|
|
18
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
19
|
-
}
|
|
20
|
-
/** The result interface of the validate function. */
|
|
21
|
-
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
22
|
-
/** The result interface if validation succeeds. */
|
|
23
|
-
interface SuccessResult<Output> {
|
|
24
|
-
/** The typed output value. */
|
|
25
|
-
readonly value: Output;
|
|
26
|
-
/** A falsy value for `issues` indicates success. */
|
|
27
|
-
readonly issues?: undefined;
|
|
28
|
-
}
|
|
29
|
-
interface Options {
|
|
30
|
-
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
31
|
-
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
32
|
-
}
|
|
33
|
-
/** The result interface if validation fails. */
|
|
34
|
-
interface FailureResult {
|
|
35
|
-
/** The issues of failed validation. */
|
|
36
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
37
|
-
}
|
|
38
|
-
/** The issue interface of the failure output. */
|
|
39
|
-
interface Issue {
|
|
40
|
-
/** The error message of the issue. */
|
|
41
|
-
readonly message: string;
|
|
42
|
-
/** The path of the issue, if any. */
|
|
43
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
44
|
-
}
|
|
45
|
-
/** The path segment interface of the issue. */
|
|
46
|
-
interface PathSegment {
|
|
47
|
-
/** The key representing a path segment. */
|
|
48
|
-
readonly key: PropertyKey;
|
|
49
|
-
}
|
|
50
|
-
/** The Standard Schema types interface. */
|
|
51
|
-
interface Types<Input = unknown, Output = Input> {
|
|
52
|
-
/** The input type of the schema. */
|
|
53
|
-
readonly input: Input;
|
|
54
|
-
/** The output type of the schema. */
|
|
55
|
-
readonly output: Output;
|
|
56
|
-
}
|
|
57
|
-
/** Infers the input type of a Standard Schema. */
|
|
58
|
-
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema[StandardKey]['types']>['input'];
|
|
59
|
-
/** Infers the output type of a Standard Schema. */
|
|
60
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema[StandardKey]['types']>['output'];
|
|
61
|
-
}
|
|
1
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
export type * from "@standard-schema/spec";
|
|
3
|
+
export type StandardKey = keyof StandardSchemaV1;
|
package/lib/type.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_helpers_any = require("./helpers/any.cjs");
|
|
|
4
4
|
const require_helpers_array = require("./helpers/array.cjs");
|
|
5
5
|
const require_helpers_custom = require("./helpers/custom.cjs");
|
|
6
6
|
const require_helpers_intersection = require("./helpers/intersection.cjs");
|
|
7
|
+
const require_helpers_use = require("./helpers/use.cjs");
|
|
7
8
|
const require_helpers_union = require("./helpers/union.cjs");
|
|
8
9
|
const require_helpers_litterals = require("./helpers/litterals.cjs");
|
|
9
10
|
const require_helpers_optional = require("./helpers/optional.cjs");
|
|
@@ -44,7 +45,8 @@ const type = (option) => {
|
|
|
44
45
|
primitive: require_helpers_primitive.primitive,
|
|
45
46
|
readonly: require_helpers_readonly.readonly,
|
|
46
47
|
object: require_helpers_object.object,
|
|
47
|
-
sora: require_helpers_sora.sora
|
|
48
|
+
sora: require_helpers_sora.sora,
|
|
49
|
+
use: require_helpers_use.use
|
|
48
50
|
}));
|
|
49
51
|
else out = _transform(option);
|
|
50
52
|
return require_standard.standardize(out);
|
package/lib/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { inferSh, ObjectT } from
|
|
2
|
-
import { any, array, custom, intersection, litterals, object, omit, optional, partial, primitive, primitiveObject, readonly, record, soa, sv, tuple, union, sora } from
|
|
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";
|
|
3
3
|
type Helpers = {
|
|
4
4
|
any: typeof any;
|
|
5
5
|
custom: typeof custom;
|
|
@@ -9,6 +9,7 @@ type Helpers = {
|
|
|
9
9
|
partial: typeof partial;
|
|
10
10
|
record: typeof record;
|
|
11
11
|
soa: typeof soa;
|
|
12
|
+
use: typeof use;
|
|
12
13
|
sv: typeof sv;
|
|
13
14
|
union: typeof union;
|
|
14
15
|
array: typeof array;
|
package/lib/type.js
CHANGED
|
@@ -3,6 +3,7 @@ import { any } from "./helpers/any.js";
|
|
|
3
3
|
import { array } from "./helpers/array.js";
|
|
4
4
|
import { custom } from "./helpers/custom.js";
|
|
5
5
|
import { intersection } from "./helpers/intersection.js";
|
|
6
|
+
import { use } from "./helpers/use.js";
|
|
6
7
|
import { union } from "./helpers/union.js";
|
|
7
8
|
import { litterals } from "./helpers/litterals.js";
|
|
8
9
|
import { optional } from "./helpers/optional.js";
|
|
@@ -43,7 +44,8 @@ const type = (option) => {
|
|
|
43
44
|
primitive,
|
|
44
45
|
readonly,
|
|
45
46
|
object,
|
|
46
|
-
sora
|
|
47
|
+
sora,
|
|
48
|
+
use
|
|
47
49
|
}));
|
|
48
50
|
else out = _transform(option);
|
|
49
51
|
return standardize(out);
|
package/lib/types.d.ts
CHANGED
|
@@ -105,11 +105,11 @@ export type StandardHelper<T1 = any, T2 = any> = {
|
|
|
105
105
|
type: T2;
|
|
106
106
|
} & StandardSchemaV1<T2, T2>;
|
|
107
107
|
type _Sh<T1 = any, T2 = any> = StandardHelper<T1, T2>;
|
|
108
|
-
export type Sh<T extends ObjectT> = StandardHelper<T, inferO<T>>;
|
|
108
|
+
export type Sh<T extends ObjectT = ObjectT> = StandardHelper<T, inferO<T>>;
|
|
109
109
|
export type StandardOutput<T = any> = StandardSchemaV1<any, T>;
|
|
110
110
|
export type inferO<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
|
|
111
111
|
export type inferSh<T extends ObjectT = ObjectT> = _Sh<T, inferO<T>>;
|
|
112
112
|
export type inferT<T extends StandardOutput = StandardOutput> = Exclude<T[StandardKey]["types"], undefined>["output"];
|
|
113
113
|
export type ProduceObject<T extends ObjectT = ObjectT> = T;
|
|
114
114
|
export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
|
|
115
|
-
export
|
|
115
|
+
export * from "./standard.types";
|
package/lib/utils/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils__const = require("./_const.cjs");
|
|
2
3
|
const require_utils_expandFn = require("./expandFn.cjs");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#endregion
|
|
6
|
-
exports._const = _const;
|
|
4
|
+
const require_utils_isSh = require("./isSh.cjs");
|
|
5
|
+
exports._const = require_utils__const._const;
|
|
7
6
|
exports.expandFn = require_utils_expandFn.expandFn;
|
|
8
7
|
exports.expandFn2 = require_utils_expandFn.expandFn2;
|
|
8
|
+
exports.isSh = require_utils_isSh.isSh;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
export
|
|
1
|
+
export * from "./_const";
|
|
2
|
+
export * from "./expandFn";
|
|
3
|
+
export * from "./isSh";
|
package/lib/utils/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
+
import { _const } from "./_const.js";
|
|
1
2
|
import { expandFn, expandFn2 } from "./expandFn.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#endregion
|
|
5
|
-
export { _const, expandFn, expandFn2 };
|
|
3
|
+
import { isSh } from "./isSh.js";
|
|
4
|
+
export { _const, expandFn, expandFn2, isSh };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../constants.cjs");
|
|
3
|
+
//#region src/utils/isSh.ts
|
|
4
|
+
const isSh = (value) => {
|
|
5
|
+
if (typeof value !== "object") return false;
|
|
6
|
+
if (value === null) return false;
|
|
7
|
+
return "__type" in value && "type" in value && "~standard" in value && typeof value["~standard"] === "object" && value["~standard"] !== null && "version" in value["~standard"] && typeof value["~standard"].version === "number" && "vendor" in value["~standard"] && typeof value["~standard"].vendor === "string" && "types" in value["~standard"] && typeof value["~standard"].types === "object" && value["~standard"].types !== null && "input" in value["~standard"].types && "output" in value["~standard"].types && "validate" in value["~standard"] && typeof value["~standard"].validate === "function";
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.isSh = isSh;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../constants.js";
|
|
2
|
+
//#region src/utils/isSh.ts
|
|
3
|
+
const isSh = (value) => {
|
|
4
|
+
if (typeof value !== "object") return false;
|
|
5
|
+
if (value === null) return false;
|
|
6
|
+
return "__type" in value && "type" in value && "~standard" in value && typeof value["~standard"] === "object" && value["~standard"] !== null && "version" in value["~standard"] && typeof value["~standard"].version === "number" && "vendor" in value["~standard"] && typeof value["~standard"].vendor === "string" && "types" in value["~standard"] && typeof value["~standard"].types === "object" && value["~standard"].types !== null && "input" in value["~standard"].types && "output" in value["~standard"].types && "validate" in value["~standard"] && typeof value["~standard"].validate === "function";
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { isSh };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/typings",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Typings by variables",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"./package.json": "./package.json",
|
|
31
31
|
"./tsconfig.json": "./tsconfig.json",
|
|
32
32
|
"./types": {
|
|
33
|
-
"types": "./lib/
|
|
33
|
+
"types": "./lib/types.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./standard": {
|
|
36
|
+
"types": "./lib/standard.types.d.ts"
|
|
34
37
|
}
|
|
35
38
|
},
|
|
36
39
|
"maintainers": [
|
|
@@ -122,5 +125,8 @@
|
|
|
122
125
|
"typescript": "^6.0.3",
|
|
123
126
|
"vitest": "^4.1.7"
|
|
124
127
|
},
|
|
128
|
+
"dependencies": {
|
|
129
|
+
"@standard-schema/spec": "^1.1.0"
|
|
130
|
+
},
|
|
125
131
|
"packageManager": "pnpm@11.2.2+sha512.36e6621fad506178936455e70247b8808ef4ec25797a9f437a93281a020484e2607f6a469a22e982987c3dbb8866e3071514ab10a4a1749e06edcd1ec118436f"
|
|
126
132
|
}
|