@bgord/tools 1.2.13 → 1.2.15
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/age-years.vo.js +2 -0
- package/dist/api-key.vo.js +2 -0
- package/dist/basename.vo.js +2 -0
- package/dist/day-iso-id.vo.js +2 -0
- package/dist/directory-path-absolute.vo.js +2 -0
- package/dist/directory-path-relative.vo.js +3 -1
- package/dist/distance-value.vo.js +2 -0
- package/dist/division-factor.vo.js +2 -0
- package/dist/dll.service.js +2 -6
- package/dist/duration-ms.vo.js +1 -0
- package/dist/email.vo.js +1 -0
- package/dist/etags.vo.js +0 -2
- package/dist/extension.vo.js +2 -0
- package/dist/file-path-absolute-schema.vo.js +2 -0
- package/dist/file-path-relative-schema.vo.js +2 -0
- package/dist/filename-affix.vo.js +2 -0
- package/dist/height-milimiters.vo.js +2 -0
- package/dist/hour-schema.vo.js +3 -1
- package/dist/iban-schema.vo.js +2 -0
- package/dist/image.vo.js +4 -0
- package/dist/integer-non-negative.vo.js +2 -0
- package/dist/integer-positive.vo.js +2 -0
- package/dist/integer.vo.js +1 -0
- package/dist/linear-regression.service.js +2 -0
- package/dist/mime-value.vo.js +2 -0
- package/dist/min-max-scaler.service.js +1 -1
- package/dist/minute-schema.vo.js +2 -0
- package/dist/minute.vo.d.ts +1 -1
- package/dist/minute.vo.js +3 -3
- package/dist/money-amount.vo.js +2 -0
- package/dist/month-iso-id.vo.js +2 -0
- package/dist/multiplication-factor.vo.js +2 -0
- package/dist/object-key.vo.js +2 -0
- package/dist/package-version-schema.vo.js +2 -0
- package/dist/package-version.vo.js +1 -5
- package/dist/pagination-page.vo.js +1 -1
- package/dist/percentage.service.js +0 -2
- package/dist/quarter-iso-id.vo.js +2 -0
- package/dist/random.service.js +1 -3
- package/dist/reordering.service.js +2 -0
- package/dist/rounding-decimal.strategy.js +2 -0
- package/dist/size-bytes.vo.js +2 -0
- package/dist/time-zone-offset-value.vo.js +6 -4
- package/dist/timestamp-value.vo.js +2 -0
- package/dist/timezone.vo.js +2 -0
- package/dist/url-with-slash.vo.js +3 -1
- package/dist/url-without-slash.vo.js +3 -1
- package/dist/week-iso-id.vo.js +2 -0
- package/dist/weekday.vo.d.ts +3 -1
- package/dist/weekday.vo.js +4 -3
- package/dist/weight-grams.vo.js +2 -0
- package/dist/weight.vo.d.ts +0 -2
- package/dist/weight.vo.js +1 -7
- package/dist/year-iso-id.vo.js +2 -0
- package/dist/year.vo.js +5 -1
- package/package.json +8 -7
- package/src/age-years.vo.ts +2 -0
- package/src/api-key.vo.ts +2 -0
- package/src/basename.vo.ts +2 -0
- package/src/day-iso-id.vo.ts +2 -0
- package/src/directory-path-absolute.vo.ts +2 -0
- package/src/directory-path-relative.vo.ts +3 -1
- package/src/distance-value.vo.ts +2 -0
- package/src/division-factor.vo.ts +2 -0
- package/src/dll.service.ts +4 -8
- package/src/duration-ms.vo.ts +2 -0
- package/src/email.vo.ts +2 -0
- package/src/etags.vo.ts +0 -2
- package/src/extension.vo.ts +2 -0
- package/src/file-path-absolute-schema.vo.ts +2 -0
- package/src/file-path-relative-schema.vo.ts +2 -0
- package/src/filename-affix.vo.ts +2 -0
- package/src/height-milimiters.vo.ts +2 -0
- package/src/hour-schema.vo.ts +3 -1
- package/src/iban-schema.vo.ts +2 -0
- package/src/image.vo.ts +4 -0
- package/src/integer-non-negative.vo.ts +2 -0
- package/src/integer-positive.vo.ts +2 -0
- package/src/integer.vo.ts +2 -0
- package/src/linear-regression.service.ts +2 -0
- package/src/mime-value.vo.ts +2 -0
- package/src/min-max-scaler.service.ts +1 -1
- package/src/minute-schema.vo.ts +2 -0
- package/src/minute.vo.ts +4 -4
- package/src/money-amount.vo.ts +2 -0
- package/src/month-iso-id.vo.ts +2 -0
- package/src/multiplication-factor.vo.ts +2 -0
- package/src/object-key.vo.ts +2 -0
- package/src/package-version-schema.vo.ts +2 -0
- package/src/package-version.vo.ts +1 -4
- package/src/pagination-page.vo.ts +1 -1
- package/src/percentage.service.ts +0 -1
- package/src/quarter-iso-id.vo.ts +2 -0
- package/src/random.service.ts +1 -2
- package/src/reordering.service.ts +2 -0
- package/src/rounding-decimal.strategy.ts +2 -0
- package/src/size-bytes.vo.ts +2 -0
- package/src/time-zone-offset-value.vo.ts +6 -4
- package/src/timestamp-value.vo.ts +2 -0
- package/src/timezone.vo.ts +2 -0
- package/src/url-with-slash.vo.ts +3 -1
- package/src/url-without-slash.vo.ts +3 -1
- package/src/week-iso-id.vo.ts +2 -0
- package/src/weekday.vo.ts +4 -2
- package/src/weight-grams.vo.ts +2 -0
- package/src/weight.vo.ts +1 -9
- package/src/year-iso-id.vo.ts +2 -0
- package/src/year.vo.ts +3 -1
package/dist/year-iso-id.vo.js
CHANGED
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id.bad.chars" };
|
|
3
3
|
// Four digits
|
|
4
4
|
const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const YearIsoId = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.string(YearIsoIdError.Type)
|
|
7
9
|
.regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars)
|
|
8
10
|
.brand("YearIsoId");
|
package/dist/year.vo.js
CHANGED
|
@@ -27,7 +27,11 @@ export class Year extends DateRange {
|
|
|
27
27
|
}
|
|
28
28
|
isLeapYear() {
|
|
29
29
|
const year = getYear(this.getStart().ms);
|
|
30
|
-
|
|
30
|
+
if (year % 400 === 0)
|
|
31
|
+
return true;
|
|
32
|
+
if (year % 100 === 0)
|
|
33
|
+
return false;
|
|
34
|
+
return year % 4 === 0;
|
|
31
35
|
}
|
|
32
36
|
previous() {
|
|
33
37
|
return this.shift(Integer.parse(-1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/tools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -21,26 +21,27 @@
|
|
|
21
21
|
"preinstall": "bunx only-allow bun"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@biomejs/biome": "2.3.
|
|
25
|
-
"@commitlint/cli": "20.
|
|
26
|
-
"@commitlint/config-conventional": "20.
|
|
24
|
+
"@biomejs/biome": "2.3.11",
|
|
25
|
+
"@commitlint/cli": "20.3.0",
|
|
26
|
+
"@commitlint/config-conventional": "20.3.0",
|
|
27
|
+
"@stryker-mutator/core": "9.4.0",
|
|
27
28
|
"@types/bun": "1.3.5",
|
|
28
29
|
"@types/mime-types": "3.0.1",
|
|
29
30
|
"cspell": "9.4.0",
|
|
30
|
-
"knip": "5.
|
|
31
|
+
"knip": "5.79.0",
|
|
31
32
|
"lefthook": "2.0.13",
|
|
32
33
|
"lockfile-lint": "4.14.1",
|
|
33
34
|
"only-allow": "1.2.2",
|
|
34
35
|
"shellcheck": "4.1.0",
|
|
35
36
|
"typescript": "5.9.3",
|
|
36
|
-
"zod": "4.3.
|
|
37
|
+
"zod": "4.3.5"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"date-fns": "4.1.0",
|
|
40
41
|
"mime-types": "3.0.2"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"zod": "4.3.
|
|
44
|
+
"zod": "4.3.5"
|
|
44
45
|
},
|
|
45
46
|
"sideEffects": false
|
|
46
47
|
}
|
package/src/age-years.vo.ts
CHANGED
|
@@ -4,7 +4,9 @@ export const AgeYearsError = { Type: "age.years.type", Invalid: "age.years.inval
|
|
|
4
4
|
|
|
5
5
|
export const AgeYearsConstraints = { min: 1, max: 130 };
|
|
6
6
|
|
|
7
|
+
// Stryker disable all
|
|
7
8
|
export const AgeYears = z
|
|
9
|
+
// Stryker restore all
|
|
8
10
|
.number(AgeYearsError.Type)
|
|
9
11
|
.int(AgeYearsError.Type)
|
|
10
12
|
.min(1, AgeYearsError.Invalid)
|
package/src/api-key.vo.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const ApiKeyError = { Type: "api.key.type", Length: "api.key.length", Bad
|
|
|
5
5
|
// 64 letters and digits allowed
|
|
6
6
|
const API_KEY_CHARS = /^[a-zA-Z0-9]{64}$/;
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const ApiKey = z
|
|
10
|
+
// Stryker disable all
|
|
9
11
|
.string(ApiKeyError.Type)
|
|
10
12
|
.length(64, ApiKeyError.Length)
|
|
11
13
|
.regex(API_KEY_CHARS, ApiKeyError.BadChars)
|
package/src/basename.vo.ts
CHANGED
|
@@ -15,7 +15,9 @@ const BASENAME_CHARS = /^[a-zA-Z0-9._-]+$/;
|
|
|
15
15
|
|
|
16
16
|
const DOT_SEGMENTS = [".", ".."];
|
|
17
17
|
|
|
18
|
+
// Stryker disable all
|
|
18
19
|
export const Basename = z
|
|
20
|
+
// Stryker restore all
|
|
19
21
|
.string(BasenameError.Type)
|
|
20
22
|
.min(1, BasenameError.Empty)
|
|
21
23
|
.max(128, BasenameError.TooLong)
|
package/src/day-iso-id.vo.ts
CHANGED
|
@@ -10,7 +10,9 @@ export const DayIsoIdError = {
|
|
|
10
10
|
// Four digits, hyphen, two digits, hyphen, two digits
|
|
11
11
|
export const DAY_ISO_ID_CHARS = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
|
|
12
12
|
|
|
13
|
+
// Stryker disable all
|
|
13
14
|
export const DayIsoId = z
|
|
15
|
+
// Stryker restore all
|
|
14
16
|
.string(DayIsoIdError.Type)
|
|
15
17
|
.regex(DAY_ISO_ID_CHARS, DayIsoIdError.BadChars)
|
|
16
18
|
.refine((value) => isValid(parseISO(value)), DayIsoIdError.InvalidDate)
|
|
@@ -14,7 +14,9 @@ export const DIRECTORY_PATH_ABSOLUTE_CHARS = /^[a-zA-Z0-9._-]+$/;
|
|
|
14
14
|
|
|
15
15
|
const DOT_SEGMENTS = [".", ".."];
|
|
16
16
|
|
|
17
|
+
// Stryker disable all
|
|
17
18
|
export const DirectoryPathAbsoluteSchema = z
|
|
19
|
+
// Stryker restore all
|
|
18
20
|
.string(DirectoryPathAbsoluteError.Type)
|
|
19
21
|
.min(1, DirectoryPathAbsoluteError.Empty)
|
|
20
22
|
.max(512, DirectoryPathAbsoluteError.TooLong)
|
|
@@ -6,7 +6,7 @@ export const DirectoryPathRelativeError = {
|
|
|
6
6
|
LeadingSlash: "directory.path.relative.leading.slash",
|
|
7
7
|
TooLong: "directory.path.absolue.too.long",
|
|
8
8
|
TrailingSlash: "directory.path.absolue.trailing.slash",
|
|
9
|
-
Type: "directory.path.relative.
|
|
9
|
+
Type: "directory.path.relative.type",
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// Letters, digits, dots, underscores, and hyphens
|
|
@@ -14,7 +14,9 @@ export const DIRECTORY_PATH_RELATIVE_CHARS = /^[A-Za-z0-9._-]+$/;
|
|
|
14
14
|
|
|
15
15
|
const DOT_SEGMENTS = [".", ".."];
|
|
16
16
|
|
|
17
|
+
// Stryker disable all
|
|
17
18
|
export const DirectoryPathRelativeSchema = z
|
|
19
|
+
// Stryker restore all
|
|
18
20
|
.string(DirectoryPathRelativeError.Type)
|
|
19
21
|
.min(1, DirectoryPathRelativeError.Empty)
|
|
20
22
|
.max(512, DirectoryPathRelativeError.TooLong)
|
package/src/distance-value.vo.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const DistanceValueError = { Type: "distance.value.type", Invalid: "distance.value.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const DistanceValue = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(DistanceValueError.Type)
|
|
7
9
|
.int(DistanceValueError.Type)
|
|
8
10
|
.min(0, DistanceValueError.Invalid)
|
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const DivisionFactorError = { Type: "division.factor.type", Invalid: "division.factor.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const DivisionFactor = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(DivisionFactorError.Type)
|
|
7
9
|
.gt(0, DivisionFactorError.Invalid)
|
|
8
10
|
.brand("DivisionFactor");
|
package/src/dll.service.ts
CHANGED
|
@@ -108,15 +108,13 @@ export class DoublyLinkedList<T> {
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const nextNode = target.next
|
|
111
|
+
const nextNode = target.next!;
|
|
112
112
|
this.size += 1;
|
|
113
113
|
|
|
114
114
|
node.prev = target;
|
|
115
115
|
node.next = nextNode;
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
nextNode.prev = node;
|
|
119
|
-
}
|
|
117
|
+
nextNode.prev = node;
|
|
120
118
|
|
|
121
119
|
target.next = node;
|
|
122
120
|
}
|
|
@@ -127,15 +125,13 @@ export class DoublyLinkedList<T> {
|
|
|
127
125
|
return;
|
|
128
126
|
}
|
|
129
127
|
|
|
130
|
-
const prevNode = target.prev
|
|
128
|
+
const prevNode = target.prev!;
|
|
131
129
|
this.size += 1;
|
|
132
130
|
|
|
133
131
|
node.next = target;
|
|
134
132
|
node.prev = prevNode;
|
|
135
133
|
|
|
136
|
-
|
|
137
|
-
prevNode.next = node;
|
|
138
|
-
}
|
|
134
|
+
prevNode.next = node;
|
|
139
135
|
|
|
140
136
|
target.prev = node;
|
|
141
137
|
}
|
package/src/duration-ms.vo.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const DurationMsError = { Invalid: "duration.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const DurationMs = z.number(DurationMsError.Invalid).int(DurationMsError.Invalid).brand("DurationMs");
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
|
|
7
9
|
export type DurationMsType = z.infer<typeof DurationMs>;
|
package/src/email.vo.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const EmailError = { Invalid: "email.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const Email = z.email({ error: EmailError.Invalid }).brand("Email");
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
|
|
7
9
|
export type EmailType = z.infer<typeof Email>;
|
package/src/etags.vo.ts
CHANGED
package/src/extension.vo.ts
CHANGED
|
@@ -10,7 +10,9 @@ export const FilePathAbsoluteSchemaError = {
|
|
|
10
10
|
Empty: "file.path.absolute.empty",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// Stryker disable all
|
|
13
14
|
export const FilePathAbsoluteSchema = z
|
|
15
|
+
// Stryker restore all
|
|
14
16
|
.string(FilePathAbsoluteSchemaError.Type)
|
|
15
17
|
.min(1, FilePathAbsoluteSchemaError.Empty)
|
|
16
18
|
.refine((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash)
|
|
@@ -10,7 +10,9 @@ export const FilePathRelativeSchemaError = {
|
|
|
10
10
|
Empty: "file.path.relative.empty",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// Stryker disable all
|
|
13
14
|
export const FilePathRelativeSchema = z
|
|
15
|
+
// Stryker restore all
|
|
14
16
|
.string(FilePathRelativeSchemaError.Type)
|
|
15
17
|
.min(1, FilePathRelativeSchemaError.Empty)
|
|
16
18
|
.refine((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash)
|
package/src/filename-affix.vo.ts
CHANGED
|
@@ -15,7 +15,9 @@ export const FilenameAffixError = {
|
|
|
15
15
|
// Letters, digits, underscores, and hyphens allowed
|
|
16
16
|
const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
17
17
|
|
|
18
|
+
// Stryker disable all
|
|
18
19
|
export const FilenameAffix = z
|
|
20
|
+
// Stryker restore all
|
|
19
21
|
.string(FilenameAffixError.Type)
|
|
20
22
|
.min(1, FilenameAffixError.Empty)
|
|
21
23
|
.max(32, FilenameAffixError.TooLong)
|
|
@@ -5,7 +5,9 @@ export const HeightMillimetersError = {
|
|
|
5
5
|
Invalid: "height.millimeters.invalid",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const HeightMillimeters = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.number(HeightMillimetersError.Type)
|
|
10
12
|
.int(HeightMillimetersError.Type)
|
|
11
13
|
.min(0, HeightMillimetersError.Invalid)
|
package/src/hour-schema.vo.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
2
|
|
|
3
|
-
export const HourSchemaError = { Type: "hour.schema.
|
|
3
|
+
export const HourSchemaError = { Type: "hour.schema.type", Invalid: "hour.schema.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const HourSchema = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(HourSchemaError.Type)
|
|
7
9
|
.int(HourSchemaError.Type)
|
|
8
10
|
.gte(0, HourSchemaError.Invalid)
|
package/src/iban-schema.vo.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const IbanSchemaError = { Type: "iban.schema.type", Invalid: "iban.schema
|
|
|
5
5
|
// Two letters for country code, two digits, 11–30 uppercase letters or digits
|
|
6
6
|
const IBAN_CHARS_WHITELIST = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const IbanSchema = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.string(IbanSchemaError.Type)
|
|
10
12
|
.toUpperCase()
|
|
11
13
|
.transform((value) => value.replaceAll(" ", ""))
|
package/src/image.vo.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const ImageHeightError = { Type: "image.height.type", Length: "image.heig
|
|
|
5
5
|
|
|
6
6
|
const IMAGE_DIMENSIONS_CONSTRAINTS = { min: 1, max: 10_000 };
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const ImageWidth = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.number(ImageWidthError.Type)
|
|
10
12
|
.int(ImageWidthError.Type)
|
|
11
13
|
.min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageWidthError.Length)
|
|
@@ -14,7 +16,9 @@ export const ImageWidth = z
|
|
|
14
16
|
|
|
15
17
|
export type ImageWidthType = z.infer<typeof ImageWidth>;
|
|
16
18
|
|
|
19
|
+
// Stryker disable all
|
|
17
20
|
export const ImageHeight = z
|
|
21
|
+
// Stryker restore all
|
|
18
22
|
.number(ImageHeightError.Type)
|
|
19
23
|
.int(ImageHeightError.Type)
|
|
20
24
|
.min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageHeightError.Length)
|
|
@@ -5,7 +5,9 @@ export const IntegerNonNegativeError = {
|
|
|
5
5
|
Invalid: "integer.non.negative.invalid",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const IntegerNonNegative = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.number(IntegerNonNegativeError.Type)
|
|
10
12
|
.int(IntegerNonNegativeError.Type)
|
|
11
13
|
.min(0, IntegerNonNegativeError.Invalid)
|
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const IntegerPositive = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(IntegerPositiveError.Type)
|
|
7
9
|
.int(IntegerPositiveError.Type)
|
|
8
10
|
.min(1, IntegerPositiveError.Invalid)
|
package/src/integer.vo.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const IntegerError = { Type: "integer.type" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const Integer = z.number(IntegerError.Type).int(IntegerError.Type).brand("Integer");
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
|
|
7
9
|
export type IntegerType = z.infer<typeof Integer>;
|
|
@@ -45,8 +45,10 @@ export class LinearRegression {
|
|
|
45
45
|
|
|
46
46
|
if (Math.abs(sumX) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXTooBig);
|
|
47
47
|
if (Math.abs(sumY) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumYTooBig);
|
|
48
|
+
// Stryker disable all
|
|
48
49
|
if (Math.abs(sumXY) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXTimesYTooBig);
|
|
49
50
|
if (Math.abs(sumXX) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXSquaredTooBig);
|
|
51
|
+
// Stryker restore all
|
|
50
52
|
|
|
51
53
|
const bDenominator = sumXX - sumX ** 2 / count;
|
|
52
54
|
|
package/src/mime-value.vo.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const MimeValueError = { Type: "mime.value.type", Invalid: "mime.value.in
|
|
|
5
5
|
// One to twenty four lowercase letters, asterisk or hyphen, forward slash, one to twenty four lowercase letters, asterisk or hyphen
|
|
6
6
|
const MIME_VALUE_CHARS_WHITELIST = /^[a-z*-]{1,24}\/[a-z*-]{1,24}$/;
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const MimeValue = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.string(MimeValueError.Type)
|
|
10
12
|
.regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid)
|
|
11
13
|
.transform((value) => ({ type: value.split("/")[0], subtype: value.split("/")[1] }))
|
|
@@ -61,7 +61,7 @@ export class MinMaxScaler {
|
|
|
61
61
|
if (value < min || value > max) throw new Error(MinMaxScalerError.ValueOutOfRange);
|
|
62
62
|
|
|
63
63
|
if (min === max) {
|
|
64
|
-
return { original: value, scaled: (lower + upper) / 2, isMin:
|
|
64
|
+
return { original: value, scaled: (lower + upper) / 2, isMin: true, isMax: true };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const result = ((value - min) / (max - min)) * (upper - lower) + lower;
|
package/src/minute-schema.vo.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const MinuteSchemaError = { Type: "minute.schema.error", Invalid: "minute.schema.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const MinuteSchema = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(MinuteSchemaError.Type)
|
|
7
9
|
.int(MinuteSchemaError.Type)
|
|
8
10
|
.gte(0, MinuteSchemaError.Invalid)
|
package/src/minute.vo.ts
CHANGED
|
@@ -37,14 +37,14 @@ export class Minute {
|
|
|
37
37
|
return this.value === another.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
isAfter(another: Minute): boolean {
|
|
41
|
-
return this.value > another.value;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
40
|
isBefore(another: Minute): boolean {
|
|
45
41
|
return this.value < another.value;
|
|
46
42
|
}
|
|
47
43
|
|
|
44
|
+
isAfter(another: Minute): boolean {
|
|
45
|
+
return this.value > another.value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
48
|
static list(): readonly Minute[] {
|
|
49
49
|
return Array.from({ length: 60 }, (_, index) => Minute.fromValue(index));
|
|
50
50
|
}
|
package/src/money-amount.vo.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const MoneyAmountError = { Type: "money.amount.type", Invalid: "money.amount.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const MoneyAmount = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(MoneyAmountError.Type)
|
|
7
9
|
.int(MoneyAmountError.Type)
|
|
8
10
|
.min(0, MoneyAmountError.Invalid)
|
package/src/month-iso-id.vo.ts
CHANGED
|
@@ -9,7 +9,9 @@ export const MonthIsoIdError = {
|
|
|
9
9
|
// Four digits, hyphen, two digits
|
|
10
10
|
const MONTH_ISO_ID_CHARS_WHITELIST = /^\d{4}-\d{2}$/;
|
|
11
11
|
|
|
12
|
+
// Stryker disable all
|
|
12
13
|
export const MonthIsoId = z
|
|
14
|
+
// Stryker restore all
|
|
13
15
|
.string(MonthIsoIdError.Type)
|
|
14
16
|
.regex(MONTH_ISO_ID_CHARS_WHITELIST, MonthIsoIdError.BadChars)
|
|
15
17
|
.refine((value) => {
|
|
@@ -5,7 +5,9 @@ export const MultiplicationFactorError = {
|
|
|
5
5
|
Invalid: "multiplication.factor.invalid",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const MultiplicationFactor = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.number(MultiplicationFactorError.Type)
|
|
10
12
|
.min(0, MultiplicationFactorError.Invalid)
|
|
11
13
|
.brand("MultiplicationFactor");
|
package/src/object-key.vo.ts
CHANGED
|
@@ -14,7 +14,9 @@ const OBJECT_KEY_SEGMENT_CHARS_WHITELIST = /^[a-z0-9._-]+$/;
|
|
|
14
14
|
|
|
15
15
|
const DOT_SEGMENTS = [".", ".."];
|
|
16
16
|
|
|
17
|
+
// Stryker disable all
|
|
17
18
|
export const ObjectKey = z
|
|
19
|
+
// Stryker restore all
|
|
18
20
|
.string(ObjectKeyError.Type)
|
|
19
21
|
.min(1, ObjectKeyError.Empty)
|
|
20
22
|
.max(256, ObjectKeyError.TooLong)
|
|
@@ -8,7 +8,9 @@ export const PackageVersionSchemaError = {
|
|
|
8
8
|
// v, 1-4 digits, dot, 1-4 digits, dot, 1-4 digits - () for capturing groups
|
|
9
9
|
const PACKAGE_VERSIONS_CHARS_WHITELIST = /^v([0-9]{1,4})\.([0-9]{1,4})\.([0-9]{1,4})$/;
|
|
10
10
|
|
|
11
|
+
// Stryker disable all
|
|
11
12
|
export const PackageVersionSchema = z
|
|
13
|
+
// Stryker restore all
|
|
12
14
|
.string(PackageVersionSchemaError.Type)
|
|
13
15
|
.regex(PACKAGE_VERSIONS_CHARS_WHITELIST, PackageVersionSchemaError.BadChars)
|
|
14
16
|
.transform((value) => {
|
|
@@ -30,10 +30,7 @@ export class PackageVersion {
|
|
|
30
30
|
if (this.minor > another.minor) return true;
|
|
31
31
|
if (this.minor < another.minor) return false;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
if (this.patch < another.patch) return false;
|
|
35
|
-
|
|
36
|
-
return true;
|
|
33
|
+
return this.patch >= another.patch;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
toString(): string {
|
|
@@ -10,7 +10,6 @@ export class Percentage {
|
|
|
10
10
|
rounding: RoundingStrategy = new RoundingToNearestStrategy(),
|
|
11
11
|
): number {
|
|
12
12
|
if (denominator === 0) throw new Error(PercentageError.InvalidDenominator);
|
|
13
|
-
if (numerator === 0) return 0;
|
|
14
13
|
return rounding.round((numerator / denominator) * 100);
|
|
15
14
|
}
|
|
16
15
|
}
|
package/src/quarter-iso-id.vo.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const QuarterIsoIdError = {
|
|
|
5
5
|
BadChars: "quarter.iso.id.bad.chars",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// Stryker disable all
|
|
8
9
|
export const QuarterIsoId = z
|
|
10
|
+
// Stryker restore all
|
|
9
11
|
.string(QuarterIsoIdError.Type)
|
|
10
12
|
.regex(/^\d{4}-Q[1-4]$/, QuarterIsoIdError.BadChars)
|
|
11
13
|
.brand("QuarterIsoId");
|
package/src/random.service.ts
CHANGED
|
@@ -12,8 +12,7 @@ export class Random {
|
|
|
12
12
|
const min = config ? config.min : Random.DEFAULT_MIN;
|
|
13
13
|
const max = config ? config.max : Random.DEFAULT_MAX;
|
|
14
14
|
|
|
15
|
-
if (min
|
|
16
|
-
if (min > max) throw new Error(RandomError.MinMax);
|
|
15
|
+
if (min >= max) throw new Error(RandomError.MinMax);
|
|
17
16
|
|
|
18
17
|
return new RoundingDownStrategy().round(Math.random() * (max - min + 1)) + min;
|
|
19
18
|
}
|
|
@@ -3,7 +3,9 @@ import type { RoundingStrategy } from "./rounding.strategy";
|
|
|
3
3
|
|
|
4
4
|
export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
|
|
5
5
|
|
|
6
|
+
// Stryker disable all
|
|
6
7
|
export const RoundingDecimal = z
|
|
8
|
+
// Stryker restore all
|
|
7
9
|
.number(RoundingDecimalError.Type)
|
|
8
10
|
.int(RoundingDecimalError.Invalid)
|
|
9
11
|
.min(1, RoundingDecimalError.Invalid)
|
package/src/size-bytes.vo.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const SizeBytesError = { Invalid: "size.bytes.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const SizeBytes = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(SizeBytesError.Invalid)
|
|
7
9
|
.int(SizeBytesError.Invalid)
|
|
8
10
|
.gte(0, SizeBytesError.Invalid)
|
|
@@ -6,13 +6,15 @@ export const TimeZoneOffsetValueError = {
|
|
|
6
6
|
Max: "time.zone.offset.value.max",
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
// Stryker disable all
|
|
9
10
|
export const TimeZoneOffsetValue = z.coerce
|
|
10
|
-
|
|
11
|
-
.
|
|
11
|
+
// Stryker restore all
|
|
12
|
+
.number(TimeZoneOffsetValueError.Type)
|
|
13
|
+
.int(TimeZoneOffsetValueError.Type)
|
|
12
14
|
// UTC+14 (Kiribati)
|
|
13
|
-
.min(-840,
|
|
15
|
+
.min(-840, TimeZoneOffsetValueError.Min)
|
|
14
16
|
// UTC-12 (Baker Island)
|
|
15
|
-
.max(720,
|
|
17
|
+
.max(720, TimeZoneOffsetValueError.Max)
|
|
16
18
|
.default(0) // Default to UTC if missing or invalid
|
|
17
19
|
.brand("TimeZoneOffsetValue");
|
|
18
20
|
|
|
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const TimestampValueError = { Invalid: "timestamp.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const TimestampValue = z
|
|
7
|
+
// Stryker restore all
|
|
6
8
|
.number(TimestampValueError.Invalid)
|
|
7
9
|
.int(TimestampValueError.Invalid)
|
|
8
10
|
.gte(0, TimestampValueError.Invalid)
|
package/src/timezone.vo.ts
CHANGED
package/src/url-with-slash.vo.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const UrlWithSlash = z
|
|
6
|
-
|
|
7
|
+
// Stryker disable all
|
|
8
|
+
.url(UrlWithSlashError.Invalid)
|
|
7
9
|
.refine((value) => value.endsWith("/"), UrlWithSlashError.Invalid)
|
|
8
10
|
.brand("UrlWithSlash");
|
|
9
11
|
|
|
@@ -2,8 +2,10 @@ import { z } from "zod/v4";
|
|
|
2
2
|
|
|
3
3
|
export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
|
|
4
4
|
|
|
5
|
+
// Stryker disable all
|
|
5
6
|
export const UrlWithoutSlash = z
|
|
6
|
-
|
|
7
|
+
// Stryker restore all
|
|
8
|
+
.url(UrlWithoutSlashError.Invalid)
|
|
7
9
|
.refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
|
|
8
10
|
.brand("UrlWithoutSlash");
|
|
9
11
|
|