@bgord/tools 1.2.13 → 1.2.14

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 (108) hide show
  1. package/dist/age-years.vo.js +2 -0
  2. package/dist/api-key.vo.js +2 -0
  3. package/dist/basename.vo.js +2 -0
  4. package/dist/day-iso-id.vo.js +2 -0
  5. package/dist/directory-path-absolute.vo.js +2 -0
  6. package/dist/directory-path-relative.vo.js +3 -1
  7. package/dist/distance-value.vo.js +2 -0
  8. package/dist/division-factor.vo.js +2 -0
  9. package/dist/dll.service.js +2 -6
  10. package/dist/duration-ms.vo.js +1 -0
  11. package/dist/email.vo.js +1 -0
  12. package/dist/etags.vo.js +0 -2
  13. package/dist/extension.vo.js +2 -0
  14. package/dist/file-path-absolute-schema.vo.js +2 -0
  15. package/dist/file-path-relative-schema.vo.js +2 -0
  16. package/dist/filename-affix.vo.js +2 -0
  17. package/dist/height-milimiters.vo.js +2 -0
  18. package/dist/hour-schema.vo.js +3 -1
  19. package/dist/iban-schema.vo.js +2 -0
  20. package/dist/image.vo.js +4 -0
  21. package/dist/integer-non-negative.vo.js +2 -0
  22. package/dist/integer-positive.vo.js +2 -0
  23. package/dist/integer.vo.js +1 -0
  24. package/dist/linear-regression.service.js +2 -0
  25. package/dist/mime-value.vo.js +2 -0
  26. package/dist/min-max-scaler.service.js +1 -1
  27. package/dist/minute-schema.vo.js +2 -0
  28. package/dist/minute.vo.d.ts +1 -1
  29. package/dist/minute.vo.js +3 -3
  30. package/dist/money-amount.vo.js +2 -0
  31. package/dist/month-iso-id.vo.js +2 -0
  32. package/dist/multiplication-factor.vo.js +2 -0
  33. package/dist/object-key.vo.js +2 -0
  34. package/dist/package-version-schema.vo.js +2 -0
  35. package/dist/package-version.vo.js +1 -5
  36. package/dist/pagination-page.vo.js +1 -1
  37. package/dist/percentage.service.js +0 -2
  38. package/dist/quarter-iso-id.vo.js +2 -0
  39. package/dist/random.service.js +1 -3
  40. package/dist/reordering.service.js +2 -0
  41. package/dist/rounding-decimal.strategy.js +2 -0
  42. package/dist/size-bytes.vo.js +2 -0
  43. package/dist/time-zone-offset-value.vo.js +6 -4
  44. package/dist/timestamp-value.vo.js +2 -0
  45. package/dist/timezone.vo.js +2 -0
  46. package/dist/url-with-slash.vo.js +3 -1
  47. package/dist/url-without-slash.vo.js +3 -1
  48. package/dist/week-iso-id.vo.js +2 -0
  49. package/dist/weekday.vo.d.ts +3 -1
  50. package/dist/weekday.vo.js +4 -3
  51. package/dist/weight-grams.vo.js +2 -0
  52. package/dist/weight.vo.d.ts +0 -2
  53. package/dist/weight.vo.js +1 -7
  54. package/dist/year-iso-id.vo.js +2 -0
  55. package/dist/year.vo.js +5 -1
  56. package/package.json +2 -1
  57. package/src/age-years.vo.ts +2 -0
  58. package/src/api-key.vo.ts +2 -0
  59. package/src/basename.vo.ts +2 -0
  60. package/src/day-iso-id.vo.ts +2 -0
  61. package/src/directory-path-absolute.vo.ts +2 -0
  62. package/src/directory-path-relative.vo.ts +3 -1
  63. package/src/distance-value.vo.ts +2 -0
  64. package/src/division-factor.vo.ts +2 -0
  65. package/src/dll.service.ts +4 -8
  66. package/src/duration-ms.vo.ts +2 -0
  67. package/src/email.vo.ts +2 -0
  68. package/src/etags.vo.ts +0 -2
  69. package/src/extension.vo.ts +2 -0
  70. package/src/file-path-absolute-schema.vo.ts +2 -0
  71. package/src/file-path-relative-schema.vo.ts +2 -0
  72. package/src/filename-affix.vo.ts +2 -0
  73. package/src/height-milimiters.vo.ts +2 -0
  74. package/src/hour-schema.vo.ts +3 -1
  75. package/src/iban-schema.vo.ts +2 -0
  76. package/src/image.vo.ts +4 -0
  77. package/src/integer-non-negative.vo.ts +2 -0
  78. package/src/integer-positive.vo.ts +2 -0
  79. package/src/integer.vo.ts +2 -0
  80. package/src/linear-regression.service.ts +2 -0
  81. package/src/mime-value.vo.ts +2 -0
  82. package/src/min-max-scaler.service.ts +1 -1
  83. package/src/minute-schema.vo.ts +2 -0
  84. package/src/minute.vo.ts +4 -4
  85. package/src/money-amount.vo.ts +2 -0
  86. package/src/month-iso-id.vo.ts +2 -0
  87. package/src/multiplication-factor.vo.ts +2 -0
  88. package/src/object-key.vo.ts +2 -0
  89. package/src/package-version-schema.vo.ts +2 -0
  90. package/src/package-version.vo.ts +1 -4
  91. package/src/pagination-page.vo.ts +1 -1
  92. package/src/percentage.service.ts +0 -1
  93. package/src/quarter-iso-id.vo.ts +2 -0
  94. package/src/random.service.ts +1 -2
  95. package/src/reordering.service.ts +2 -0
  96. package/src/rounding-decimal.strategy.ts +2 -0
  97. package/src/size-bytes.vo.ts +2 -0
  98. package/src/time-zone-offset-value.vo.ts +6 -4
  99. package/src/timestamp-value.vo.ts +2 -0
  100. package/src/timezone.vo.ts +2 -0
  101. package/src/url-with-slash.vo.ts +3 -1
  102. package/src/url-without-slash.vo.ts +3 -1
  103. package/src/week-iso-id.vo.ts +2 -0
  104. package/src/weekday.vo.ts +4 -2
  105. package/src/weight-grams.vo.ts +2 -0
  106. package/src/weight.vo.ts +1 -9
  107. package/src/year-iso-id.vo.ts +2 -0
  108. package/src/year.vo.ts +3 -1
@@ -1,7 +1,9 @@
1
1
  import { z } from "zod/v4";
2
2
  export const AgeYearsError = { Type: "age.years.type", Invalid: "age.years.invalid" };
3
3
  export const AgeYearsConstraints = { min: 1, max: 130 };
4
+ // Stryker disable all
4
5
  export const AgeYears = z
6
+ // Stryker restore all
5
7
  .number(AgeYearsError.Type)
6
8
  .int(AgeYearsError.Type)
7
9
  .min(1, AgeYearsError.Invalid)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
  export const ApiKeyError = { Type: "api.key.type", Length: "api.key.length", BadChars: "api.key.bad.chars" };
3
3
  // 64 letters and digits allowed
4
4
  const API_KEY_CHARS = /^[a-zA-Z0-9]{64}$/;
5
+ // Stryker disable all
5
6
  export const ApiKey = z
7
+ // Stryker disable all
6
8
  .string(ApiKeyError.Type)
7
9
  .length(64, ApiKeyError.Length)
8
10
  .regex(API_KEY_CHARS, ApiKeyError.BadChars)
@@ -11,7 +11,9 @@ export const BasenameError = {
11
11
  // Letters, digits, dots, underscores, and hyphens allowed
12
12
  const BASENAME_CHARS = /^[a-zA-Z0-9._-]+$/;
13
13
  const DOT_SEGMENTS = [".", ".."];
14
+ // Stryker disable all
14
15
  export const Basename = z
16
+ // Stryker restore all
15
17
  .string(BasenameError.Type)
16
18
  .min(1, BasenameError.Empty)
17
19
  .max(128, BasenameError.TooLong)
@@ -7,7 +7,9 @@ export const DayIsoIdError = {
7
7
  };
8
8
  // Four digits, hyphen, two digits, hyphen, two digits
9
9
  export const DAY_ISO_ID_CHARS = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
10
+ // Stryker disable all
10
11
  export const DayIsoId = z
12
+ // Stryker restore all
11
13
  .string(DayIsoIdError.Type)
12
14
  .regex(DAY_ISO_ID_CHARS, DayIsoIdError.BadChars)
13
15
  .refine((value) => isValid(parseISO(value)), DayIsoIdError.InvalidDate)
@@ -10,7 +10,9 @@ export const DirectoryPathAbsoluteError = {
10
10
  // Letters, digits, dots, underscores, and hyphens
11
11
  export const DIRECTORY_PATH_ABSOLUTE_CHARS = /^[a-zA-Z0-9._-]+$/;
12
12
  const DOT_SEGMENTS = [".", ".."];
13
+ // Stryker disable all
13
14
  export const DirectoryPathAbsoluteSchema = z
15
+ // Stryker restore all
14
16
  .string(DirectoryPathAbsoluteError.Type)
15
17
  .min(1, DirectoryPathAbsoluteError.Empty)
16
18
  .max(512, DirectoryPathAbsoluteError.TooLong)
@@ -5,12 +5,14 @@ export const DirectoryPathRelativeError = {
5
5
  LeadingSlash: "directory.path.relative.leading.slash",
6
6
  TooLong: "directory.path.absolue.too.long",
7
7
  TrailingSlash: "directory.path.absolue.trailing.slash",
8
- Type: "directory.path.relative.not.type",
8
+ Type: "directory.path.relative.type",
9
9
  };
10
10
  // Letters, digits, dots, underscores, and hyphens
11
11
  export const DIRECTORY_PATH_RELATIVE_CHARS = /^[A-Za-z0-9._-]+$/;
12
12
  const DOT_SEGMENTS = [".", ".."];
13
+ // Stryker disable all
13
14
  export const DirectoryPathRelativeSchema = z
15
+ // Stryker restore all
14
16
  .string(DirectoryPathRelativeError.Type)
15
17
  .min(1, DirectoryPathRelativeError.Empty)
16
18
  .max(512, DirectoryPathRelativeError.TooLong)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const DistanceValueError = { Type: "distance.value.type", Invalid: "distance.value.invalid" };
3
+ // Stryker disable all
3
4
  export const DistanceValue = z
5
+ // Stryker restore all
4
6
  .number(DistanceValueError.Type)
5
7
  .int(DistanceValueError.Type)
6
8
  .min(0, DistanceValueError.Invalid)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const DivisionFactorError = { Type: "division.factor.type", Invalid: "division.factor.invalid" };
3
+ // Stryker disable all
3
4
  export const DivisionFactor = z
5
+ // Stryker restore all
4
6
  .number(DivisionFactorError.Type)
5
7
  .gt(0, DivisionFactorError.Invalid)
6
8
  .brand("DivisionFactor");
@@ -96,9 +96,7 @@ export class DoublyLinkedList {
96
96
  this.size += 1;
97
97
  node.prev = target;
98
98
  node.next = nextNode;
99
- if (nextNode) {
100
- nextNode.prev = node;
101
- }
99
+ nextNode.prev = node;
102
100
  target.next = node;
103
101
  }
104
102
  insertBefore(node, target) {
@@ -110,9 +108,7 @@ export class DoublyLinkedList {
110
108
  this.size += 1;
111
109
  node.next = target;
112
110
  node.prev = prevNode;
113
- if (prevNode) {
114
- prevNode.next = node;
115
- }
111
+ prevNode.next = node;
116
112
  target.prev = node;
117
113
  }
118
114
  find(callback) {
@@ -1,3 +1,4 @@
1
1
  import { z } from "zod/v4";
2
2
  export const DurationMsError = { Invalid: "duration.invalid" };
3
+ // Stryker disable all
3
4
  export const DurationMs = z.number(DurationMsError.Invalid).int(DurationMsError.Invalid).brand("DurationMs");
package/dist/email.vo.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import { z } from "zod/v4";
2
2
  export const EmailError = { Invalid: "email.invalid" };
3
+ // Stryker disable all
3
4
  export const Email = z.email({ error: EmailError.Invalid }).brand("Email");
package/dist/etags.vo.js CHANGED
@@ -9,8 +9,6 @@ export class ETag {
9
9
  this.value = revision.toString();
10
10
  }
11
11
  static fromHeader(value) {
12
- if (value?.startsWith("W/"))
13
- return null;
14
12
  const candidate = Number(value);
15
13
  if (Number.isNaN(candidate))
16
14
  return null;
@@ -8,7 +8,9 @@ export const ExtensionError = {
8
8
  // Lowercase letters and digits allowed
9
9
  const EXTENSION_WHITELIST = /^[a-z0-9]+$/;
10
10
  const LEADING_DOT_FILE = /^\./;
11
+ // Stryker disable all
11
12
  export const Extension = z
13
+ // Stryker restore all
12
14
  .string(ExtensionError.Type)
13
15
  .toLowerCase()
14
16
  .min(2, ExtensionError.Empty)
@@ -8,7 +8,9 @@ export const FilePathAbsoluteSchemaError = {
8
8
  BackslashForbidden: "file.path.absolute.backslash.forbidden",
9
9
  Empty: "file.path.absolute.empty",
10
10
  };
11
+ // Stryker disable all
11
12
  export const FilePathAbsoluteSchema = z
13
+ // Stryker restore all
12
14
  .string(FilePathAbsoluteSchemaError.Type)
13
15
  .min(1, FilePathAbsoluteSchemaError.Empty)
14
16
  .refine((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash)
@@ -8,7 +8,9 @@ export const FilePathRelativeSchemaError = {
8
8
  RequiresDirectory: "file.path.relative.requires.directory",
9
9
  Empty: "file.path.relative.empty",
10
10
  };
11
+ // Stryker disable all
11
12
  export const FilePathRelativeSchema = z
13
+ // Stryker restore all
12
14
  .string(FilePathRelativeSchemaError.Type)
13
15
  .min(1, FilePathRelativeSchemaError.Empty)
14
16
  .refine((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash)
@@ -12,7 +12,9 @@ export const FilenameAffixError = {
12
12
  };
13
13
  // Letters, digits, underscores, and hyphens allowed
14
14
  const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
15
+ // Stryker disable all
15
16
  export const FilenameAffix = z
17
+ // Stryker restore all
16
18
  .string(FilenameAffixError.Type)
17
19
  .min(1, FilenameAffixError.Empty)
18
20
  .max(32, FilenameAffixError.TooLong)
@@ -3,7 +3,9 @@ export const HeightMillimetersError = {
3
3
  Type: "height.millimeters.type",
4
4
  Invalid: "height.millimeters.invalid",
5
5
  };
6
+ // Stryker disable all
6
7
  export const HeightMillimeters = z
8
+ // Stryker restore all
7
9
  .number(HeightMillimetersError.Type)
8
10
  .int(HeightMillimetersError.Type)
9
11
  .min(0, HeightMillimetersError.Invalid)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
- export const HourSchemaError = { Type: "hour.schema.error", Invalid: "hour.schema.invalid" };
2
+ export const HourSchemaError = { Type: "hour.schema.type", Invalid: "hour.schema.invalid" };
3
+ // Stryker disable all
3
4
  export const HourSchema = z
5
+ // Stryker restore all
4
6
  .number(HourSchemaError.Type)
5
7
  .int(HourSchemaError.Type)
6
8
  .gte(0, HourSchemaError.Invalid)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
  export const IbanSchemaError = { Type: "iban.schema.type", Invalid: "iban.schema.invalid" };
3
3
  // Two letters for country code, two digits, 11–30 uppercase letters or digits
4
4
  const IBAN_CHARS_WHITELIST = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
5
+ // Stryker disable all
5
6
  export const IbanSchema = z
7
+ // Stryker restore all
6
8
  .string(IbanSchemaError.Type)
7
9
  .toUpperCase()
8
10
  .transform((value) => value.replaceAll(" ", ""))
package/dist/image.vo.js CHANGED
@@ -2,13 +2,17 @@ import { z } from "zod/v4";
2
2
  export const ImageWidthError = { Type: "image.width.type", Length: "image.width.length" };
3
3
  export const ImageHeightError = { Type: "image.height.type", Length: "image.height.length" };
4
4
  const IMAGE_DIMENSIONS_CONSTRAINTS = { min: 1, max: 10_000 };
5
+ // Stryker disable all
5
6
  export const ImageWidth = z
7
+ // Stryker restore all
6
8
  .number(ImageWidthError.Type)
7
9
  .int(ImageWidthError.Type)
8
10
  .min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageWidthError.Length)
9
11
  .max(IMAGE_DIMENSIONS_CONSTRAINTS.max, ImageWidthError.Length)
10
12
  .brand("ImageWidth");
13
+ // Stryker disable all
11
14
  export const ImageHeight = z
15
+ // Stryker restore all
12
16
  .number(ImageHeightError.Type)
13
17
  .int(ImageHeightError.Type)
14
18
  .min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageHeightError.Length)
@@ -3,7 +3,9 @@ export const IntegerNonNegativeError = {
3
3
  Type: "integer.non.negative.type",
4
4
  Invalid: "integer.non.negative.invalid",
5
5
  };
6
+ // Stryker disable all
6
7
  export const IntegerNonNegative = z
8
+ // Stryker restore all
7
9
  .number(IntegerNonNegativeError.Type)
8
10
  .int(IntegerNonNegativeError.Type)
9
11
  .min(0, IntegerNonNegativeError.Invalid)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
3
+ // Stryker disable all
3
4
  export const IntegerPositive = z
5
+ // Stryker restore all
4
6
  .number(IntegerPositiveError.Type)
5
7
  .int(IntegerPositiveError.Type)
6
8
  .min(1, IntegerPositiveError.Invalid)
@@ -1,3 +1,4 @@
1
1
  import { z } from "zod/v4";
2
2
  export const IntegerError = { Type: "integer.type" };
3
+ // Stryker disable all
3
4
  export const Integer = z.number(IntegerError.Type).int(IntegerError.Type).brand("Integer");
@@ -34,10 +34,12 @@ export class LinearRegression {
34
34
  throw new Error(LinearRegressionError.SumXTooBig);
35
35
  if (Math.abs(sumY) >= Number.MAX_SAFE_INTEGER)
36
36
  throw new Error(LinearRegressionError.SumYTooBig);
37
+ // Stryker disable all
37
38
  if (Math.abs(sumXY) >= Number.MAX_SAFE_INTEGER)
38
39
  throw new Error(LinearRegressionError.SumXTimesYTooBig);
39
40
  if (Math.abs(sumXX) >= Number.MAX_SAFE_INTEGER)
40
41
  throw new Error(LinearRegressionError.SumXSquaredTooBig);
42
+ // Stryker restore all
41
43
  const bDenominator = sumXX - sumX ** 2 / count;
42
44
  if (bDenominator === 0)
43
45
  throw new Error(LinearRegressionError.ModelCreation);
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
  export const MimeValueError = { Type: "mime.value.type", Invalid: "mime.value.invalid" };
3
3
  // One to twenty four lowercase letters, asterisk or hyphen, forward slash, one to twenty four lowercase letters, asterisk or hyphen
4
4
  const MIME_VALUE_CHARS_WHITELIST = /^[a-z*-]{1,24}\/[a-z*-]{1,24}$/;
5
+ // Stryker disable all
5
6
  export const MimeValue = z
7
+ // Stryker restore all
6
8
  .string(MimeValueError.Type)
7
9
  .regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid)
8
10
  .transform((value) => ({ type: value.split("/")[0], subtype: value.split("/")[1] }))
@@ -31,7 +31,7 @@ export class MinMaxScaler {
31
31
  if (value < min || value > max)
32
32
  throw new Error(MinMaxScalerError.ValueOutOfRange);
33
33
  if (min === max) {
34
- return { original: value, scaled: (lower + upper) / 2, isMin: value === min, isMax: value === max };
34
+ return { original: value, scaled: (lower + upper) / 2, isMin: true, isMax: true };
35
35
  }
36
36
  const result = ((value - min) / (max - min)) * (upper - lower) + lower;
37
37
  return {
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const MinuteSchemaError = { Type: "minute.schema.error", Invalid: "minute.schema.invalid" };
3
+ // Stryker disable all
3
4
  export const MinuteSchema = z
5
+ // Stryker restore all
4
6
  .number(MinuteSchemaError.Type)
5
7
  .int(MinuteSchemaError.Type)
6
8
  .gte(0, MinuteSchemaError.Invalid)
@@ -12,8 +12,8 @@ export declare class Minute {
12
12
  static max(): Minute;
13
13
  get(): MinuteSchemaType;
14
14
  equals(another: Minute): boolean;
15
- isAfter(another: Minute): boolean;
16
15
  isBefore(another: Minute): boolean;
16
+ isAfter(another: Minute): boolean;
17
17
  static list(): readonly Minute[];
18
18
  toString(): string;
19
19
  toJSON(): number;
package/dist/minute.vo.js CHANGED
@@ -29,12 +29,12 @@ export class Minute {
29
29
  equals(another) {
30
30
  return this.value === another.value;
31
31
  }
32
- isAfter(another) {
33
- return this.value > another.value;
34
- }
35
32
  isBefore(another) {
36
33
  return this.value < another.value;
37
34
  }
35
+ isAfter(another) {
36
+ return this.value > another.value;
37
+ }
38
38
  static list() {
39
39
  return Array.from({ length: 60 }, (_, index) => Minute.fromValue(index));
40
40
  }
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const MoneyAmountError = { Type: "money.amount.type", Invalid: "money.amount.invalid" };
3
+ // Stryker disable all
3
4
  export const MoneyAmount = z
5
+ // Stryker restore all
4
6
  .number(MoneyAmountError.Type)
5
7
  .int(MoneyAmountError.Type)
6
8
  .min(0, MoneyAmountError.Invalid)
@@ -6,7 +6,9 @@ export const MonthIsoIdError = {
6
6
  };
7
7
  // Four digits, hyphen, two digits
8
8
  const MONTH_ISO_ID_CHARS_WHITELIST = /^\d{4}-\d{2}$/;
9
+ // Stryker disable all
9
10
  export const MonthIsoId = z
11
+ // Stryker restore all
10
12
  .string(MonthIsoIdError.Type)
11
13
  .regex(MONTH_ISO_ID_CHARS_WHITELIST, MonthIsoIdError.BadChars)
12
14
  .refine((value) => {
@@ -3,7 +3,9 @@ export const MultiplicationFactorError = {
3
3
  Type: "multiplication.factor.type",
4
4
  Invalid: "multiplication.factor.invalid",
5
5
  };
6
+ // Stryker disable all
6
7
  export const MultiplicationFactor = z
8
+ // Stryker restore all
7
9
  .number(MultiplicationFactorError.Type)
8
10
  .min(0, MultiplicationFactorError.Invalid)
9
11
  .brand("MultiplicationFactor");
@@ -10,7 +10,9 @@ export const ObjectKeyError = {
10
10
  // Lowercase letters, digits, dots, underscores, and hyphens
11
11
  const OBJECT_KEY_SEGMENT_CHARS_WHITELIST = /^[a-z0-9._-]+$/;
12
12
  const DOT_SEGMENTS = [".", ".."];
13
+ // Stryker disable all
13
14
  export const ObjectKey = z
15
+ // Stryker restore all
14
16
  .string(ObjectKeyError.Type)
15
17
  .min(1, ObjectKeyError.Empty)
16
18
  .max(256, ObjectKeyError.TooLong)
@@ -5,7 +5,9 @@ export const PackageVersionSchemaError = {
5
5
  };
6
6
  // v, 1-4 digits, dot, 1-4 digits, dot, 1-4 digits - () for capturing groups
7
7
  const PACKAGE_VERSIONS_CHARS_WHITELIST = /^v([0-9]{1,4})\.([0-9]{1,4})\.([0-9]{1,4})$/;
8
+ // Stryker disable all
8
9
  export const PackageVersionSchema = z
10
+ // Stryker restore all
9
11
  .string(PackageVersionSchemaError.Type)
10
12
  .regex(PACKAGE_VERSIONS_CHARS_WHITELIST, PackageVersionSchemaError.BadChars)
11
13
  .transform((value) => {
@@ -28,11 +28,7 @@ export class PackageVersion {
28
28
  return true;
29
29
  if (this.minor < another.minor)
30
30
  return false;
31
- if (this.patch > another.patch)
32
- return true;
33
- if (this.patch < another.patch)
34
- return false;
35
- return true;
31
+ return this.patch >= another.patch;
36
32
  }
37
33
  toString() {
38
34
  return `${this.major}.${this.minor}.${this.patch}`;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- export const PaginationPageError = { Type: "pagination.page.Type" };
2
+ export const PaginationPageError = { Type: "pagination.page.type" };
3
3
  export const Page = z.coerce
4
4
  .number(PaginationPageError.Type)
5
5
  .int(PaginationPageError.Type)
@@ -4,8 +4,6 @@ export class Percentage {
4
4
  static of(numerator, denominator, rounding = new RoundingToNearestStrategy()) {
5
5
  if (denominator === 0)
6
6
  throw new Error(PercentageError.InvalidDenominator);
7
- if (numerator === 0)
8
- return 0;
9
7
  return rounding.round((numerator / denominator) * 100);
10
8
  }
11
9
  }
@@ -3,7 +3,9 @@ export const QuarterIsoIdError = {
3
3
  Type: "quarter.iso.id.type",
4
4
  BadChars: "quarter.iso.id.bad.chars",
5
5
  };
6
+ // Stryker disable all
6
7
  export const QuarterIsoId = z
8
+ // Stryker restore all
7
9
  .string(QuarterIsoIdError.Type)
8
10
  .regex(/^\d{4}-Q[1-4]$/, QuarterIsoIdError.BadChars)
9
11
  .brand("QuarterIsoId");
@@ -6,9 +6,7 @@ export class Random {
6
6
  static generate(config) {
7
7
  const min = config ? config.min : Random.DEFAULT_MIN;
8
8
  const max = config ? config.max : Random.DEFAULT_MAX;
9
- if (min === max)
10
- throw new Error(RandomError.MinMax);
11
- if (min > max)
9
+ if (min >= max)
12
10
  throw new Error(RandomError.MinMax);
13
11
  return new RoundingDownStrategy().round(Math.random() * (max - min + 1)) + min;
14
12
  }
@@ -1,3 +1,4 @@
1
+ // Stryker disable all
1
2
  import { z } from "zod/v4";
2
3
  import { DoublyLinkedList, Node } from "./dll.service";
3
4
  import { ReorderingItemPositionValue, } from "./reordering-item-position-value.vo";
@@ -131,3 +132,4 @@ export class ReorderingIntegrator {
131
132
  return (a, b) => a.position - b.position;
132
133
  }
133
134
  }
135
+ // Stryker restore all
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
3
+ // Stryker disable all
3
4
  export const RoundingDecimal = z
5
+ // Stryker restore all
4
6
  .number(RoundingDecimalError.Type)
5
7
  .int(RoundingDecimalError.Invalid)
6
8
  .min(1, RoundingDecimalError.Invalid)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const SizeBytesError = { Invalid: "size.bytes.invalid" };
3
+ // Stryker disable all
3
4
  export const SizeBytes = z
5
+ // Stryker restore all
4
6
  .number(SizeBytesError.Invalid)
5
7
  .int(SizeBytesError.Invalid)
6
8
  .gte(0, SizeBytesError.Invalid)
@@ -4,12 +4,14 @@ export const TimeZoneOffsetValueError = {
4
4
  Min: "time.zone.offset.value.min",
5
5
  Max: "time.zone.offset.value.max",
6
6
  };
7
+ // Stryker disable all
7
8
  export const TimeZoneOffsetValue = z.coerce
8
- .number({ error: TimeZoneOffsetValueError.Type })
9
- .int({ error: TimeZoneOffsetValueError.Type })
9
+ // Stryker restore all
10
+ .number(TimeZoneOffsetValueError.Type)
11
+ .int(TimeZoneOffsetValueError.Type)
10
12
  // UTC+14 (Kiribati)
11
- .min(-840, { error: TimeZoneOffsetValueError.Min })
13
+ .min(-840, TimeZoneOffsetValueError.Min)
12
14
  // UTC-12 (Baker Island)
13
- .max(720, { error: TimeZoneOffsetValueError.Max })
15
+ .max(720, TimeZoneOffsetValueError.Max)
14
16
  .default(0) // Default to UTC if missing or invalid
15
17
  .brand("TimeZoneOffsetValue");
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const TimestampValueError = { Invalid: "timestamp.invalid" };
3
+ // Stryker disable all
3
4
  export const TimestampValue = z
5
+ // Stryker restore all
4
6
  .number(TimestampValueError.Invalid)
5
7
  .int(TimestampValueError.Invalid)
6
8
  .gte(0, TimestampValueError.Invalid)
@@ -5,7 +5,9 @@ export const TimezoneError = {
5
5
  TooLong: "timezone.too.long",
6
6
  Invalid: "timezone.invalid",
7
7
  };
8
+ // Stryker disable all
8
9
  export const Timezone = z
10
+ // Stryker restore all
9
11
  .string(TimezoneError.Type)
10
12
  .min(1, TimezoneError.Empty)
11
13
  .max(128, TimezoneError.TooLong)
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
3
+ // Stryker disable all
3
4
  export const UrlWithSlash = z
4
- .url({ error: UrlWithSlashError.Invalid })
5
+ // Stryker disable all
6
+ .url(UrlWithSlashError.Invalid)
5
7
  .refine((value) => value.endsWith("/"), UrlWithSlashError.Invalid)
6
8
  .brand("UrlWithSlash");
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
3
+ // Stryker disable all
3
4
  export const UrlWithoutSlash = z
4
- .url({ error: UrlWithoutSlashError.Invalid })
5
+ // Stryker restore all
6
+ .url(UrlWithoutSlashError.Invalid)
5
7
  .refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
6
8
  .brand("UrlWithoutSlash");
@@ -7,7 +7,9 @@ export const WeekIsoIdError = {
7
7
  };
8
8
  // Four digits, hypen, W, followed by two digits
9
9
  const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
10
+ // Stryker disable all
10
11
  export const WeekIsoId = z
12
+ // Stryker restore all
11
13
  .string(WeekIsoIdError.Type)
12
14
  .regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars)
13
15
  .refine((value) => {
@@ -7,7 +7,9 @@ export declare enum WeekdayFormatterEnum {
7
7
  ISO_NUMBER = "ISO_NUMBER",// Monday=1 ... Sunday=7
8
8
  ZERO_BASED_NUMBER = "ZERO_BASED_NUMBER"
9
9
  }
10
- export declare const WeekdayValueError: "invalid.weekday";
10
+ export declare const WeekdayValueError: {
11
+ readonly Invalid: "weekday.invalid";
12
+ };
11
13
  export declare const WeekdayFormatters: Record<WeekdayFormatterEnum, WeekdayFormatter>;
12
14
  export declare class Weekday {
13
15
  private readonly value;
@@ -6,7 +6,7 @@ export var WeekdayFormatterEnum;
6
6
  WeekdayFormatterEnum["ISO_NUMBER"] = "ISO_NUMBER";
7
7
  WeekdayFormatterEnum["ZERO_BASED_NUMBER"] = "ZERO_BASED_NUMBER";
8
8
  })(WeekdayFormatterEnum || (WeekdayFormatterEnum = {}));
9
- export const WeekdayValueError = "invalid.weekday";
9
+ export const WeekdayValueError = { Invalid: "weekday.invalid" };
10
10
  const FULL_NAMES = [
11
11
  "Sunday",
12
12
  "Monday",
@@ -36,8 +36,9 @@ export class Weekday {
36
36
  static FRIDAY = new Weekday(5);
37
37
  static SATURDAY = new Weekday(6);
38
38
  constructor(candidate, formatter) {
39
- if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6)
40
- throw new Error(WeekdayValueError);
39
+ if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6) {
40
+ throw new Error(WeekdayValueError.Invalid);
41
+ }
41
42
  this.value = candidate;
42
43
  this.formatter = formatter ?? WeekdayFormatters.FULL;
43
44
  }
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
3
+ // Stryker disable all
3
4
  export const WeightGrams = z
5
+ // Stryker restore all
4
6
  .number(WeightGramsError.Type)
5
7
  .int(WeightGramsError.Type)
6
8
  .gte(0, WeightGramsError.Invalid)
@@ -18,9 +18,7 @@ export declare class Weight {
18
18
  divide(divisor: DivisionFactorType): Weight;
19
19
  equals(other: Weight): boolean;
20
20
  greaterThan(other: Weight): boolean;
21
- greaterThanOrEqual(other: Weight): boolean;
22
21
  lessThan(other: Weight): boolean;
23
- lessThanOrEqual(other: Weight): boolean;
24
22
  isZero(): boolean;
25
23
  toString(): string;
26
24
  toJSON(): number;
package/dist/weight.vo.js CHANGED
@@ -33,7 +33,7 @@ export class Weight {
33
33
  }
34
34
  subtract(other) {
35
35
  const result = this.grams - other.grams;
36
- return new Weight(WeightGrams.parse(result < 0 ? 0 : result));
36
+ return new Weight(WeightGrams.parse(Math.max(0, result)), this.rounding);
37
37
  }
38
38
  multiply(factor) {
39
39
  const grams = this.rounding.round(this.grams * factor);
@@ -49,15 +49,9 @@ export class Weight {
49
49
  greaterThan(other) {
50
50
  return this.grams > other.grams;
51
51
  }
52
- greaterThanOrEqual(other) {
53
- return this.grams >= other.grams;
54
- }
55
52
  lessThan(other) {
56
53
  return this.grams < other.grams;
57
54
  }
58
- lessThanOrEqual(other) {
59
- return this.grams <= other.grams;
60
- }
61
55
  isZero() {
62
56
  return this.grams === 0;
63
57
  }