ts-fortress 2.3.0 → 2.4.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/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/predefined/index.d.mts +2 -0
- package/dist/predefined/index.d.mts.map +1 -0
- package/dist/predefined/index.mjs +2 -0
- package/dist/predefined/index.mjs.map +1 -0
- package/dist/predefined/json.d.mts +47 -0
- package/dist/predefined/json.d.mts.map +1 -0
- package/dist/predefined/json.mjs +16 -0
- package/dist/predefined/json.mjs.map +1 -0
- package/package.json +3 -3
- package/src/index.mts +1 -0
- package/src/predefined/index.mts +1 -0
- package/src/predefined/json.mts +33 -0
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './array/index.mjs';
|
|
|
2
2
|
export * from './branded/index.mjs';
|
|
3
3
|
export * from './compose/index.mjs';
|
|
4
4
|
export * from './enum/index.mjs';
|
|
5
|
+
export * from './predefined/index.mjs';
|
|
5
6
|
export * from './primitives/index.mjs';
|
|
6
7
|
export * from './record/index.mjs';
|
|
7
8
|
export * from './type.mjs';
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,7 @@ export { recursion } from './compose/recursion.mjs';
|
|
|
27
27
|
export { union } from './compose/union.mjs';
|
|
28
28
|
export { enumType } from './enum/enum.mjs';
|
|
29
29
|
export { uintRange } from './enum/uint-range.mjs';
|
|
30
|
+
export { JsonObject, JsonPrimitive, JsonValue } from './predefined/json.mjs';
|
|
30
31
|
export { bigint, bigintLiteral } from './primitives/bigint.mjs';
|
|
31
32
|
export { boolean, booleanLiteral } from './primitives/boolean.mjs';
|
|
32
33
|
export { nullType } from './primitives/null.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/predefined/index.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Type } from '../type.mjs';
|
|
2
|
+
export declare const JsonPrimitive: Readonly<{
|
|
3
|
+
typeName: string;
|
|
4
|
+
defaultValue: string | number | boolean | null;
|
|
5
|
+
is: (a: unknown) => a is string | number | boolean | null;
|
|
6
|
+
assertIs: (a: unknown) => asserts a is string | number | boolean | null;
|
|
7
|
+
cast: (a: unknown) => string | number | boolean | null;
|
|
8
|
+
fill: (a: unknown) => string | number | boolean | null;
|
|
9
|
+
validate: (a: unknown) => import("ts-data-forge").Result<string | number | boolean | null, readonly Readonly<{
|
|
10
|
+
path: readonly string[];
|
|
11
|
+
actualValue: unknown;
|
|
12
|
+
expectedType: string;
|
|
13
|
+
message: string | undefined;
|
|
14
|
+
typeName: string;
|
|
15
|
+
}>[]>;
|
|
16
|
+
optional?: true;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const JsonValue: Type<JsonValue>;
|
|
19
|
+
export declare const JsonObject: Readonly<{
|
|
20
|
+
typeName: string;
|
|
21
|
+
defaultValue: {
|
|
22
|
+
readonly [x: string]: JsonValue;
|
|
23
|
+
};
|
|
24
|
+
is: (a: unknown) => a is {
|
|
25
|
+
readonly [x: string]: JsonValue;
|
|
26
|
+
};
|
|
27
|
+
assertIs: (a: unknown) => asserts a is {
|
|
28
|
+
readonly [x: string]: JsonValue;
|
|
29
|
+
};
|
|
30
|
+
cast: (a: unknown) => {
|
|
31
|
+
readonly [x: string]: JsonValue;
|
|
32
|
+
};
|
|
33
|
+
fill: (a: unknown) => {
|
|
34
|
+
readonly [x: string]: JsonValue;
|
|
35
|
+
};
|
|
36
|
+
validate: (a: unknown) => import("ts-data-forge").Result<{
|
|
37
|
+
readonly [x: string]: JsonValue;
|
|
38
|
+
}, readonly Readonly<{
|
|
39
|
+
path: readonly string[];
|
|
40
|
+
actualValue: unknown;
|
|
41
|
+
expectedType: string;
|
|
42
|
+
message: string | undefined;
|
|
43
|
+
typeName: string;
|
|
44
|
+
}>[]>;
|
|
45
|
+
optional?: true;
|
|
46
|
+
}>;
|
|
47
|
+
//# sourceMappingURL=json.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.mts","sourceRoot":"","sources":["../../src/predefined/json.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAAmD,CAAC;AAW9E,eAAO,MAAM,SAAS,EAAE,IAAI,CAAC,SAAS,CAErC,CAAC;AAYF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'ts-data-forge';
|
|
2
|
+
import { array } from '../array/array.mjs';
|
|
3
|
+
import { recursion } from '../compose/recursion.mjs';
|
|
4
|
+
import { union } from '../compose/union.mjs';
|
|
5
|
+
import { boolean } from '../primitives/boolean.mjs';
|
|
6
|
+
import { nullType } from '../primitives/null.mjs';
|
|
7
|
+
import { number } from '../primitives/number.mjs';
|
|
8
|
+
import { string } from '../primitives/string.mjs';
|
|
9
|
+
import { keyValueRecord } from '../record/key-value-record.mjs';
|
|
10
|
+
|
|
11
|
+
const JsonPrimitive = union([nullType, number(), string(), boolean()]);
|
|
12
|
+
const JsonValue = recursion('JsonValue', () => union([JsonPrimitive, keyValueRecord(string(), JsonValue), array(JsonValue)]));
|
|
13
|
+
const JsonObject = keyValueRecord(string(), JsonValue);
|
|
14
|
+
|
|
15
|
+
export { JsonObject, JsonPrimitive, JsonValue };
|
|
16
|
+
//# sourceMappingURL=json.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.mjs","sources":["../../src/predefined/json.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;MAOa,aAAa,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC;AAWrE,MAAM,SAAS,GAAoB,SAAS,CAAC,WAAW,EAAE,MAC/D,KAAK,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAaxE,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-fortress",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@semantic-release/github": "^11.0.4",
|
|
69
69
|
"@semantic-release/npm": "^12.0.2",
|
|
70
70
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
71
|
-
"@types/node": "^24.
|
|
71
|
+
"@types/node": "^24.3.0",
|
|
72
72
|
"@vitest/coverage-v8": "^3.2.4",
|
|
73
73
|
"@vitest/ui": "^3.2.4",
|
|
74
74
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"prettier-plugin-packagejson": "^2.5.19",
|
|
92
92
|
"rollup": "^4.46.2",
|
|
93
93
|
"semantic-release": "^24.2.7",
|
|
94
|
-
"ts-repo-utils": "^6.0.
|
|
94
|
+
"ts-repo-utils": "^6.0.3",
|
|
95
95
|
"tslib": "^2.8.1",
|
|
96
96
|
"tsx": "^4.20.4",
|
|
97
97
|
"typedoc": "^0.28.10",
|
package/src/index.mts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './array/index.mjs';
|
|
|
2
2
|
export * from './branded/index.mjs';
|
|
3
3
|
export * from './compose/index.mjs';
|
|
4
4
|
export * from './enum/index.mjs';
|
|
5
|
+
export * from './predefined/index.mjs';
|
|
5
6
|
export * from './primitives/index.mjs';
|
|
6
7
|
export * from './record/index.mjs';
|
|
7
8
|
export * from './type.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './json.mjs';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { expectType } from 'ts-data-forge';
|
|
2
|
+
import { array } from '../array/index.mjs';
|
|
3
|
+
import { recursion, union } from '../compose/index.mjs';
|
|
4
|
+
import { boolean, nullType, number, string } from '../primitives/index.mjs';
|
|
5
|
+
import { keyValueRecord } from '../record/index.mjs';
|
|
6
|
+
import { type Type, type TypeOf } from '../type.mjs';
|
|
7
|
+
|
|
8
|
+
export const JsonPrimitive = union([nullType, number(), string(), boolean()]);
|
|
9
|
+
|
|
10
|
+
if (import.meta.vitest !== undefined) {
|
|
11
|
+
test('JsonPrimitive', () => {
|
|
12
|
+
expectType<TypeOf<typeof JsonPrimitive>, JsonPrimitive>('=');
|
|
13
|
+
expectType<JsonPrimitive, null | boolean | number | string>('=');
|
|
14
|
+
|
|
15
|
+
expect(JsonPrimitive.defaultValue).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const JsonValue: Type<JsonValue> = recursion('JsonValue', () =>
|
|
20
|
+
union([JsonPrimitive, keyValueRecord(string(), JsonValue), array(JsonValue)]),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (import.meta.vitest !== undefined) {
|
|
24
|
+
test('JsonValue', () => {
|
|
25
|
+
expectType<TypeOf<typeof JsonValue>, JsonValue>('=');
|
|
26
|
+
|
|
27
|
+
expect(JsonValue.defaultValue).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type JsonObject = ReadonlyRecord<string, JsonValue>;
|
|
32
|
+
|
|
33
|
+
export const JsonObject = keyValueRecord(string(), JsonValue);
|