@bgord/tools 1.3.24 → 1.4.1
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.d.ts +3 -3
- package/dist/age-years.vo.js +4 -9
- package/dist/age.vo.js +2 -1
- package/dist/api-key.vo.d.ts +3 -4
- package/dist/api-key.vo.js +5 -9
- package/dist/basename.vo.d.ts +3 -3
- package/dist/basename.vo.js +10 -15
- package/dist/day-iso-id.vo.d.ts +3 -3
- package/dist/day-iso-id.vo.js +4 -8
- package/dist/day.vo.d.ts +1 -1
- package/dist/day.vo.js +7 -6
- package/dist/directory-path-absolute.vo.d.ts +3 -3
- package/dist/directory-path-absolute.vo.js +5 -12
- package/dist/directory-path-relative.vo.d.ts +3 -3
- package/dist/directory-path-relative.vo.js +5 -12
- package/dist/distance-value.vo.d.ts +3 -3
- package/dist/distance-value.vo.js +4 -8
- package/dist/distance.vo.js +7 -6
- package/dist/division-factor.vo.d.ts +3 -3
- package/dist/division-factor.vo.js +4 -7
- package/dist/duration-ms.vo.d.ts +3 -3
- package/dist/duration-ms.vo.js +4 -3
- package/dist/duration.service.js +2 -1
- package/dist/email.vo.d.ts +3 -3
- package/dist/email.vo.js +3 -3
- package/dist/etags.vo.js +3 -2
- package/dist/extension.vo.d.ts +3 -3
- package/dist/extension.vo.js +6 -12
- package/dist/feature-flag-value.vo.d.ts +3 -3
- package/dist/feature-flag-value.vo.js +2 -2
- package/dist/file-path-absolute-schema.vo.d.ts +8 -5
- package/dist/file-path-absolute-schema.vo.js +6 -13
- package/dist/file-path-relative-schema.vo.d.ts +8 -5
- package/dist/file-path-relative-schema.vo.js +6 -13
- package/dist/file-path.vo.js +5 -4
- package/dist/filename-affix.vo.d.ts +3 -3
- package/dist/filename-affix.vo.js +4 -9
- package/dist/filename-from-string.vo.d.ts +6 -6
- package/dist/filename-from-string.vo.js +5 -8
- package/dist/filename.vo.js +8 -7
- package/dist/height-milimiters.vo.d.ts +3 -3
- package/dist/height-milimiters.vo.js +4 -8
- package/dist/height.vo.js +4 -3
- package/dist/hour-value.vo.d.ts +3 -3
- package/dist/hour-value.vo.js +4 -9
- package/dist/hour.vo.js +3 -2
- package/dist/iban-schema.vo.d.ts +3 -3
- package/dist/iban-schema.vo.js +4 -9
- package/dist/iban.vo.js +2 -1
- package/dist/image.vo.d.ts +5 -5
- package/dist/image.vo.js +7 -17
- package/dist/integer-non-negative.vo.d.ts +3 -3
- package/dist/integer-non-negative.vo.js +4 -8
- package/dist/integer-positive.vo.d.ts +3 -3
- package/dist/integer-positive.vo.js +4 -8
- package/dist/integer.vo.d.ts +3 -3
- package/dist/integer.vo.js +3 -3
- package/dist/language.vo.d.ts +3 -3
- package/dist/language.vo.js +2 -2
- package/dist/mime-value.vo.d.ts +3 -2
- package/dist/mime-value.vo.js +4 -7
- package/dist/mime.vo.js +2 -1
- package/dist/mimes.js +12 -11
- package/dist/minute-value.vo.d.ts +3 -3
- package/dist/minute-value.vo.js +4 -9
- package/dist/minute.vo.js +3 -2
- package/dist/money-amount.vo.d.ts +3 -3
- package/dist/money-amount.vo.js +4 -8
- package/dist/money.vo.js +7 -6
- package/dist/month-iso-id.vo.d.ts +3 -3
- package/dist/month-iso-id.vo.js +5 -9
- package/dist/month.vo.js +5 -4
- package/dist/multiplication-factor.vo.d.ts +3 -3
- package/dist/multiplication-factor.vo.js +4 -7
- package/dist/object-key.vo.d.ts +3 -3
- package/dist/object-key.vo.js +8 -13
- package/dist/package-version-schema.vo.d.ts +3 -3
- package/dist/package-version-schema.vo.js +4 -7
- package/dist/package-version.vo.js +3 -4
- package/dist/pagination-page.vo.d.ts +3 -3
- package/dist/pagination-page.vo.js +2 -6
- package/dist/pagination-skip.vo.d.ts +3 -3
- package/dist/pagination-skip.vo.js +2 -5
- package/dist/pagination-take.vo.d.ts +3 -3
- package/dist/pagination-take.vo.js +2 -5
- package/dist/pagination.service.js +8 -7
- package/dist/quarter-iso-id.vo.d.ts +4 -3
- package/dist/quarter-iso-id.vo.js +7 -11
- package/dist/quarter.vo.js +3 -2
- package/dist/reordering-item-position-value.vo.d.ts +3 -3
- package/dist/reordering-item-position-value.vo.js +2 -5
- package/dist/reordering.service.d.ts +9 -9
- package/dist/reordering.service.js +7 -7
- package/dist/revision-value.vo.d.ts +3 -3
- package/dist/revision-value.vo.js +2 -5
- package/dist/revision.vo.js +3 -2
- package/dist/rounding-decimal.strategy.d.ts +2 -2
- package/dist/rounding-decimal.strategy.js +5 -10
- package/dist/size-bytes.vo.d.ts +3 -3
- package/dist/size-bytes.vo.js +4 -8
- package/dist/size.vo.js +5 -4
- package/dist/time-zone-offset-value.vo.d.ts +3 -3
- package/dist/time-zone-offset-value.vo.js +8 -12
- package/dist/timestamp-value.vo.d.ts +3 -3
- package/dist/timestamp-value.vo.js +4 -8
- package/dist/timestamp.vo.js +2 -1
- package/dist/timezone.vo.d.ts +3 -3
- package/dist/timezone.vo.js +7 -10
- package/dist/url-with-slash.vo.d.ts +3 -3
- package/dist/url-with-slash.vo.js +4 -7
- package/dist/url-without-slash.vo.d.ts +3 -3
- package/dist/url-without-slash.vo.js +4 -7
- package/dist/week-iso-id.vo.d.ts +3 -3
- package/dist/week-iso-id.vo.js +5 -9
- package/dist/week.vo.js +5 -4
- package/dist/weekday-iso-id.vo.d.ts +3 -3
- package/dist/weekday-iso-id.vo.js +4 -9
- package/dist/weekday.vo.js +9 -8
- package/dist/weight-grams.vo.d.ts +3 -3
- package/dist/weight-grams.vo.js +4 -8
- package/dist/weight.vo.js +8 -7
- package/dist/year-iso-id.vo.d.ts +3 -3
- package/dist/year-iso-id.vo.js +4 -7
- package/dist/year.vo.js +6 -5
- package/package.json +9 -12
package/dist/age-years.vo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const AgeYearsError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
@@ -7,5 +7,5 @@ export declare const AgeYearsConstraints: {
|
|
|
7
7
|
min: number;
|
|
8
8
|
max: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const AgeYears:
|
|
11
|
-
export type AgeYearsType =
|
|
10
|
+
export declare const AgeYears: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.MaxValueAction<number, 130, string>, v.BrandAction<number, "AgeYears">]>;
|
|
11
|
+
export type AgeYearsType = v.InferOutput<typeof AgeYears>;
|
package/dist/age-years.vo.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const AgeYearsError = { Type: "age.years.type", Invalid: "age.years.invalid" };
|
|
3
3
|
export const AgeYearsConstraints = { min: 0, max: 130 };
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.number(AgeYearsError.Type)
|
|
8
|
-
.int(AgeYearsError.Type)
|
|
9
|
-
.min(0, AgeYearsError.Invalid)
|
|
10
|
-
.max(130, AgeYearsError.Invalid)
|
|
11
|
-
.brand("AgeYears");
|
|
4
|
+
export const AgeYears = v.pipe(v.number(AgeYearsError.Type), v.integer(AgeYearsError.Type), v.minValue(0, AgeYearsError.Invalid), v.maxValue(130, AgeYearsError.Invalid),
|
|
5
|
+
// Stryker disable next-line StringLiteral
|
|
6
|
+
v.brand("AgeYears"));
|
package/dist/age.vo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { differenceInYears } from "date-fns";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { AgeYears, AgeYearsConstraints } from "./age-years.vo";
|
|
3
4
|
import { Timestamp } from "./timestamp.vo";
|
|
4
5
|
export const AgeError = { FutureBirthdate: "age.future.birthdate" };
|
|
@@ -10,7 +11,7 @@ export class Age {
|
|
|
10
11
|
this.value = value;
|
|
11
12
|
}
|
|
12
13
|
static fromValue(candidate) {
|
|
13
|
-
return new Age(
|
|
14
|
+
return new Age(v.parse(AgeYears, candidate));
|
|
14
15
|
}
|
|
15
16
|
static fromValueSafe(candidate) {
|
|
16
17
|
return new Age(candidate);
|
package/dist/api-key.vo.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const ApiKeyError: {
|
|
3
3
|
Type: string;
|
|
4
|
-
Length: string;
|
|
5
4
|
BadChars: string;
|
|
6
5
|
};
|
|
7
|
-
export declare const ApiKey:
|
|
8
|
-
export type ApiKeyType =
|
|
6
|
+
export declare const ApiKey: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "ApiKey">]>;
|
|
7
|
+
export type ApiKeyType = v.InferOutput<typeof ApiKey>;
|
package/dist/api-key.vo.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
export const ApiKeyError = { Type: "api.key.type",
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const ApiKeyError = { Type: "api.key.type", BadChars: "api.key.bad.chars" };
|
|
3
3
|
// 64 letters and digits allowed
|
|
4
4
|
const API_KEY_CHARS = /^[a-zA-Z0-9]{64}$/;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.string(ApiKeyError.Type)
|
|
9
|
-
.length(64, ApiKeyError.Length)
|
|
10
|
-
.regex(API_KEY_CHARS, ApiKeyError.BadChars)
|
|
11
|
-
.brand("ApiKey");
|
|
5
|
+
export const ApiKey = v.pipe(v.string(ApiKeyError.Type), v.regex(API_KEY_CHARS, ApiKeyError.BadChars),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("ApiKey"));
|
package/dist/basename.vo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const BasenameError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Empty: string;
|
|
@@ -8,5 +8,5 @@ export declare const BasenameError: {
|
|
|
8
8
|
TrailingDot: string;
|
|
9
9
|
BadChars: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const Basename:
|
|
12
|
-
export type BasenameType =
|
|
11
|
+
export declare const Basename: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 128, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.RegexAction<string, string>, v.BrandAction<string, "Basename">]>;
|
|
12
|
+
export type BasenameType = v.InferOutput<typeof Basename>;
|
package/dist/basename.vo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const BasenameError = {
|
|
3
3
|
Type: "basename.type",
|
|
4
4
|
Empty: "basename.empty",
|
|
@@ -11,17 +11,12 @@ 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.refine((value) => !value.startsWith("."), BasenameError.Dotfiles)
|
|
24
|
-
// Reject trailing dot like "picture." to avoid extension collision
|
|
25
|
-
.refine((value) => !value.endsWith("."), BasenameError.TrailingDot)
|
|
26
|
-
.regex(BASENAME_CHARS, BasenameError.BadChars)
|
|
27
|
-
.brand("Basename");
|
|
14
|
+
export const Basename = v.pipe(v.string(BasenameError.Type), v.minLength(1, BasenameError.Empty), v.maxLength(128, BasenameError.TooLong),
|
|
15
|
+
// Reject "." and ".." as a filename to avoid directory traversal
|
|
16
|
+
v.check((value) => !DOT_SEGMENTS.includes(value), BasenameError.DotSegments),
|
|
17
|
+
// Reject dotfiles like ".env"
|
|
18
|
+
v.check((value) => !value.startsWith("."), BasenameError.Dotfiles),
|
|
19
|
+
// Reject trailing dot like "picture." to avoid extension collision
|
|
20
|
+
v.check((value) => !value.endsWith("."), BasenameError.TrailingDot), v.regex(BASENAME_CHARS, BasenameError.BadChars),
|
|
21
|
+
// Stryker disable next-line StringLiteral
|
|
22
|
+
v.brand("Basename"));
|
package/dist/day-iso-id.vo.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DayIsoIdError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
BadChars: string;
|
|
5
5
|
InvalidDate: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const DAY_ISO_ID_CHARS: RegExp;
|
|
8
|
-
export declare const DayIsoId:
|
|
9
|
-
export type DayIsoIdType =
|
|
8
|
+
export declare const DayIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "DayIsoId">]>;
|
|
9
|
+
export type DayIsoIdType = v.InferOutput<typeof DayIsoId>;
|
package/dist/day-iso-id.vo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isValid, parseISO } from "date-fns";
|
|
2
|
-
import * as
|
|
2
|
+
import * as v from "valibot";
|
|
3
3
|
export const DayIsoIdError = {
|
|
4
4
|
Type: "day.iso.id.type",
|
|
5
5
|
BadChars: "day.iso.id.bad.chars",
|
|
@@ -7,10 +7,6 @@ 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.string(DayIsoIdError.Type)
|
|
14
|
-
.regex(DAY_ISO_ID_CHARS, DayIsoIdError.BadChars)
|
|
15
|
-
.refine((value) => isValid(parseISO(value)), DayIsoIdError.InvalidDate)
|
|
16
|
-
.brand("DayIsoId");
|
|
10
|
+
export const DayIsoId = v.pipe(v.string(DayIsoIdError.Type), v.regex(DAY_ISO_ID_CHARS, DayIsoIdError.BadChars), v.check((value) => isValid(parseISO(value)), DayIsoIdError.InvalidDate),
|
|
11
|
+
// Stryker disable next-line StringLiteral
|
|
12
|
+
v.brand("DayIsoId"));
|
package/dist/day.vo.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare class Day extends DateRange {
|
|
|
9
9
|
static fromNow(now: Timestamp): Day;
|
|
10
10
|
static fromIsoId(isoId: DayIsoIdType): Day;
|
|
11
11
|
toIsoId(): DayIsoIdType;
|
|
12
|
-
next(): Day;
|
|
13
12
|
previous(): Day;
|
|
13
|
+
next(): Day;
|
|
14
14
|
shift(count: IntegerType): Day;
|
|
15
15
|
toString(): string;
|
|
16
16
|
}
|
package/dist/day.vo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatISO } from "date-fns";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { DateRange } from "./date-range.vo";
|
|
3
4
|
import { DayIsoId } from "./day-iso-id.vo";
|
|
4
5
|
import { Duration } from "./duration.service";
|
|
@@ -18,20 +19,20 @@ export class Day extends DateRange {
|
|
|
18
19
|
return Day.fromTimestamp(now);
|
|
19
20
|
}
|
|
20
21
|
static fromIsoId(isoId) {
|
|
21
|
-
const [year, month, day] =
|
|
22
|
+
const [year, month, day] = v.parse(DayIsoId, isoId).split("-").map(Number);
|
|
22
23
|
const startUtc = Timestamp.fromNumber(Date.UTC(year, month - 1, day));
|
|
23
24
|
const endUtc = startUtc.add(Duration.Days(1)).subtract(Duration.Ms(1));
|
|
24
25
|
return new Day(startUtc, endUtc);
|
|
25
26
|
}
|
|
26
27
|
toIsoId() {
|
|
27
28
|
const midday = this.getStart().add(Duration.Hours(12));
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
next() {
|
|
31
|
-
return this.shift(Integer.parse(1));
|
|
29
|
+
return v.parse(DayIsoId, formatISO(midday.ms, { representation: "date" }));
|
|
32
30
|
}
|
|
33
31
|
previous() {
|
|
34
|
-
return this.shift(
|
|
32
|
+
return this.shift(v.parse(Integer, -1));
|
|
33
|
+
}
|
|
34
|
+
next() {
|
|
35
|
+
return this.shift(v.parse(Integer, 1));
|
|
35
36
|
}
|
|
36
37
|
shift(count) {
|
|
37
38
|
return Day.fromTimestamp(this.getStart().add(Duration.Days(count)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DirectoryPathAbsoluteError: {
|
|
3
3
|
BadSegments: string;
|
|
4
4
|
Empty: string;
|
|
@@ -8,5 +8,5 @@ export declare const DirectoryPathAbsoluteError: {
|
|
|
8
8
|
Type: string;
|
|
9
9
|
};
|
|
10
10
|
export declare const DIRECTORY_PATH_ABSOLUTE_CHARS: RegExp;
|
|
11
|
-
export declare const DirectoryPathAbsoluteSchema:
|
|
12
|
-
export type DirectoryPathAbsoluteType =
|
|
11
|
+
export declare const DirectoryPathAbsoluteSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 512, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "DirectoryPathAbsoluteSchema">]>;
|
|
12
|
+
export type DirectoryPathAbsoluteType = v.InferOutput<typeof DirectoryPathAbsoluteSchema>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const DirectoryPathAbsoluteError = {
|
|
3
3
|
BadSegments: "directory.path.absolue.bad.segments",
|
|
4
4
|
Empty: "directory.path.absolue.empty",
|
|
@@ -10,18 +10,11 @@ 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
|
-
|
|
14
|
-
export const DirectoryPathAbsoluteSchema = z
|
|
15
|
-
// Stryker restore all
|
|
16
|
-
.string(DirectoryPathAbsoluteError.Type)
|
|
17
|
-
.min(1, DirectoryPathAbsoluteError.Empty)
|
|
18
|
-
.max(512, DirectoryPathAbsoluteError.TooLong)
|
|
19
|
-
.refine((value) => value.startsWith("/"), DirectoryPathAbsoluteError.LeadingSlash)
|
|
20
|
-
.refine((value) => (value === "/" ? true : !value.endsWith("/")), DirectoryPathAbsoluteError.TrailingSlash)
|
|
21
|
-
.refine((value) => {
|
|
13
|
+
export const DirectoryPathAbsoluteSchema = v.pipe(v.string(DirectoryPathAbsoluteError.Type), v.minLength(1, DirectoryPathAbsoluteError.Empty), v.maxLength(512, DirectoryPathAbsoluteError.TooLong), v.check((value) => value.startsWith("/"), DirectoryPathAbsoluteError.LeadingSlash), v.check((value) => (value === "/" ? true : !value.endsWith("/")), DirectoryPathAbsoluteError.TrailingSlash), v.check((value) => {
|
|
22
14
|
if (value === "/")
|
|
23
15
|
return true;
|
|
24
16
|
const segments = value.slice(1).split("/");
|
|
25
17
|
return segments.every((segment) => DIRECTORY_PATH_ABSOLUTE_CHARS.test(segment) && !DOT_SEGMENTS.includes(segment));
|
|
26
|
-
}, DirectoryPathAbsoluteError.BadSegments)
|
|
27
|
-
|
|
18
|
+
}, DirectoryPathAbsoluteError.BadSegments),
|
|
19
|
+
// Stryker disable next-line StringLiteral
|
|
20
|
+
v.brand("DirectoryPathAbsoluteSchema"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DirectoryPathRelativeError: {
|
|
3
3
|
BadSegments: string;
|
|
4
4
|
Empty: string;
|
|
@@ -8,5 +8,5 @@ export declare const DirectoryPathRelativeError: {
|
|
|
8
8
|
Type: string;
|
|
9
9
|
};
|
|
10
10
|
export declare const DIRECTORY_PATH_RELATIVE_CHARS: RegExp;
|
|
11
|
-
export declare const DirectoryPathRelativeSchema:
|
|
12
|
-
export type DirectoryPathRelativeType =
|
|
11
|
+
export declare const DirectoryPathRelativeSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 512, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "DirectoryPathRelativeSchema">]>;
|
|
12
|
+
export type DirectoryPathRelativeType = v.InferOutput<typeof DirectoryPathRelativeSchema>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const DirectoryPathRelativeError = {
|
|
3
3
|
BadSegments: "directory.path.relative.bad.segments",
|
|
4
4
|
Empty: "directory.path.relative.empty",
|
|
@@ -10,15 +10,8 @@ export const DirectoryPathRelativeError = {
|
|
|
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
|
-
|
|
14
|
-
export const DirectoryPathRelativeSchema = z
|
|
15
|
-
// Stryker restore all
|
|
16
|
-
.string(DirectoryPathRelativeError.Type)
|
|
17
|
-
.min(1, DirectoryPathRelativeError.Empty)
|
|
18
|
-
.max(512, DirectoryPathRelativeError.TooLong)
|
|
19
|
-
.refine((value) => !value.startsWith("/"), DirectoryPathRelativeError.LeadingSlash)
|
|
20
|
-
.refine((value) => !value.endsWith("/"), DirectoryPathRelativeError.TrailingSlash)
|
|
21
|
-
.refine((value) => value
|
|
13
|
+
export const DirectoryPathRelativeSchema = v.pipe(v.string(DirectoryPathRelativeError.Type), v.minLength(1, DirectoryPathRelativeError.Empty), v.maxLength(512, DirectoryPathRelativeError.TooLong), v.check((value) => !value.startsWith("/"), DirectoryPathRelativeError.LeadingSlash), v.check((value) => !value.endsWith("/"), DirectoryPathRelativeError.TrailingSlash), v.check((value) => value
|
|
22
14
|
.split("/")
|
|
23
|
-
.every((segment) => DIRECTORY_PATH_RELATIVE_CHARS.test(segment) && !DOT_SEGMENTS.includes(segment)), DirectoryPathRelativeError.BadSegments)
|
|
24
|
-
|
|
15
|
+
.every((segment) => DIRECTORY_PATH_RELATIVE_CHARS.test(segment) && !DOT_SEGMENTS.includes(segment)), DirectoryPathRelativeError.BadSegments),
|
|
16
|
+
// Stryker disable next-line StringLiteral
|
|
17
|
+
v.brand("DirectoryPathRelativeSchema"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DistanceValueError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const DistanceValue:
|
|
7
|
-
export type DistanceValueType =
|
|
6
|
+
export declare const DistanceValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "DistanceValue">]>;
|
|
7
|
+
export type DistanceValueType = v.InferOutput<typeof DistanceValue>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const DistanceValueError = { Type: "distance.value.type", Invalid: "distance.value.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.number(DistanceValueError.Type)
|
|
7
|
-
.int(DistanceValueError.Type)
|
|
8
|
-
.min(0, DistanceValueError.Invalid)
|
|
9
|
-
.brand("DistanceValue");
|
|
3
|
+
export const DistanceValue = v.pipe(v.number(DistanceValueError.Type), v.integer(DistanceValueError.Type), v.minValue(0, DistanceValueError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("DistanceValue"));
|
package/dist/distance.vo.js
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { DistanceValue } from "./distance-value.vo";
|
|
2
3
|
import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
|
|
3
4
|
export const DistanceError = { SubtractResultLessThanZero: "distance.subtract.result.less.than.zero" };
|
|
4
5
|
export class Distance {
|
|
5
6
|
value;
|
|
6
|
-
static ZERO =
|
|
7
|
+
static ZERO = v.parse(DistanceValue, 0);
|
|
7
8
|
constructor(value) {
|
|
8
9
|
this.value = value;
|
|
9
10
|
}
|
|
10
11
|
static fromMeters(candidate) {
|
|
11
|
-
return new Distance(
|
|
12
|
+
return new Distance(v.parse(DistanceValue, candidate));
|
|
12
13
|
}
|
|
13
14
|
static fromMetersSafe(candidate) {
|
|
14
15
|
return new Distance(candidate);
|
|
15
16
|
}
|
|
16
17
|
static fromKilometers(candidate, rounding = new RoundingToNearestStrategy()) {
|
|
17
|
-
return new Distance(
|
|
18
|
+
return new Distance(v.parse(DistanceValue, rounding.round(candidate * 1000)));
|
|
18
19
|
}
|
|
19
20
|
static fromMiles(candidate, rounding = new RoundingToNearestStrategy()) {
|
|
20
|
-
return new Distance(
|
|
21
|
+
return new Distance(v.parse(DistanceValue, rounding.round(candidate * 1_609.344)));
|
|
21
22
|
}
|
|
22
23
|
get() {
|
|
23
24
|
return this.value;
|
|
24
25
|
}
|
|
25
26
|
add(distance) {
|
|
26
|
-
return new Distance(
|
|
27
|
+
return new Distance(v.parse(DistanceValue, this.value + distance.get()));
|
|
27
28
|
}
|
|
28
29
|
subtract(distance) {
|
|
29
30
|
const result = this.value - distance.get();
|
|
30
31
|
if (result < Distance.ZERO)
|
|
31
32
|
throw new Error(DistanceError.SubtractResultLessThanZero);
|
|
32
|
-
return new Distance(
|
|
33
|
+
return new Distance(v.parse(DistanceValue, result));
|
|
33
34
|
}
|
|
34
35
|
equals(another) {
|
|
35
36
|
return this.value === another.get();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DivisionFactorError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const DivisionFactor:
|
|
7
|
-
export type DivisionFactorType =
|
|
6
|
+
export declare const DivisionFactor: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.GtValueAction<number, 0, string>, v.BrandAction<number, "DivisionFactor">]>;
|
|
7
|
+
export type DivisionFactorType = v.InferOutput<typeof DivisionFactor>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const DivisionFactorError = { Type: "division.factor.type", Invalid: "division.factor.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.number(DivisionFactorError.Type)
|
|
7
|
-
.gt(0, DivisionFactorError.Invalid)
|
|
8
|
-
.brand("DivisionFactor");
|
|
3
|
+
export const DivisionFactor = v.pipe(v.number(DivisionFactorError.Type), v.gtValue(0, DivisionFactorError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("DivisionFactor"));
|
package/dist/duration-ms.vo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DurationMsError: {
|
|
3
3
|
Invalid: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const DurationMs:
|
|
6
|
-
export type DurationMsType =
|
|
5
|
+
export declare const DurationMs: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.BrandAction<number, "DurationMs">]>;
|
|
6
|
+
export type DurationMsType = v.InferOutput<typeof DurationMs>;
|
package/dist/duration-ms.vo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const DurationMsError = { Invalid: "duration.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export const DurationMs = v.pipe(v.number(DurationMsError.Invalid), v.integer(DurationMsError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("DurationMs"));
|
package/dist/duration.service.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { DurationMs } from "./duration-ms.vo";
|
|
2
3
|
import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
|
|
3
4
|
import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
|
|
@@ -12,7 +13,7 @@ export class Duration {
|
|
|
12
13
|
static MS_IN_DAY = 24 * Duration.MS_IN_HOUR;
|
|
13
14
|
static MS_IN_WEEK = 7 * Duration.MS_IN_DAY;
|
|
14
15
|
constructor(candidateMs) {
|
|
15
|
-
this.internal =
|
|
16
|
+
this.internal = v.parse(DurationMs, candidateMs);
|
|
16
17
|
}
|
|
17
18
|
static Weeks(value) {
|
|
18
19
|
return new Duration(value * Duration.MS_IN_WEEK);
|
package/dist/email.vo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const EmailError: {
|
|
3
3
|
Invalid: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const Email:
|
|
6
|
-
export type EmailType =
|
|
5
|
+
export declare const Email: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.EmailAction<string, string>, v.BrandAction<string, "Email">]>;
|
|
6
|
+
export type EmailType = v.InferOutput<typeof Email>;
|
package/dist/email.vo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const EmailError = { Invalid: "email.invalid" };
|
|
3
|
-
// Stryker disable
|
|
4
|
-
export const Email =
|
|
3
|
+
// Stryker disable next-line StringLiteral
|
|
4
|
+
export const Email = v.pipe(v.string(EmailError.Invalid), v.email(EmailError.Invalid), v.brand("Email"));
|
package/dist/etags.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { RevisionValue } from "./revision-value.vo";
|
|
2
3
|
export class ETag {
|
|
3
4
|
revision;
|
|
@@ -12,7 +13,7 @@ export class ETag {
|
|
|
12
13
|
const candidate = Number(value);
|
|
13
14
|
if (Number.isNaN(candidate))
|
|
14
15
|
return null;
|
|
15
|
-
return new ETag(
|
|
16
|
+
return new ETag(v.parse(RevisionValue, candidate));
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
export const WeakETagError = { Invalid: "weak.etag.invalid" };
|
|
@@ -31,6 +32,6 @@ export class WeakETag {
|
|
|
31
32
|
const candidate = Number(value.split("W/")[1]);
|
|
32
33
|
if (Number.isNaN(candidate))
|
|
33
34
|
return null;
|
|
34
|
-
return new WeakETag(
|
|
35
|
+
return new WeakETag(v.parse(RevisionValue, candidate));
|
|
35
36
|
}
|
|
36
37
|
}
|
package/dist/extension.vo.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const ExtensionError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Empty: string;
|
|
5
5
|
TooLong: string;
|
|
6
6
|
BadChars: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const Extension:
|
|
9
|
-
export type ExtensionType =
|
|
8
|
+
export declare const Extension: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.ToLowerCaseAction, v.TransformAction<string, string>, v.MinLengthAction<string, 2, string>, v.MaxLengthAction<string, 16, string>, v.CheckAction<string, string>, v.BrandAction<string, "Extension">]>;
|
|
9
|
+
export type ExtensionType = v.InferOutput<typeof Extension>;
|
package/dist/extension.vo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const ExtensionError = {
|
|
3
3
|
Type: "extension.type",
|
|
4
4
|
Empty: "extension.empty",
|
|
@@ -8,14 +8,8 @@ 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.min(2, ExtensionError.Empty)
|
|
17
|
-
.max(16, ExtensionError.TooLong)
|
|
18
|
-
// Transform ".png" -> "png"
|
|
19
|
-
.transform((value) => value.replace(LEADING_DOT_FILE, ""))
|
|
20
|
-
.refine((value) => EXTENSION_WHITELIST.test(value), ExtensionError.BadChars)
|
|
21
|
-
.brand("Extension");
|
|
11
|
+
export const Extension = v.pipe(v.string(ExtensionError.Type), v.toLowerCase(),
|
|
12
|
+
// Transform ".png" -> "png"
|
|
13
|
+
v.transform((value) => value.replace(LEADING_DOT_FILE, "")), v.minLength(2, ExtensionError.Empty), v.maxLength(16, ExtensionError.TooLong), v.check((value) => EXTENSION_WHITELIST.test(value), ExtensionError.BadChars),
|
|
14
|
+
// Stryker disable next-line StringLiteral
|
|
15
|
+
v.brand("Extension"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const FeatureFlagValueError: {
|
|
3
3
|
Invalid: string;
|
|
4
4
|
};
|
|
@@ -6,5 +6,5 @@ export declare enum FeatureFlagEnum {
|
|
|
6
6
|
yes = "yes",
|
|
7
7
|
no = "no"
|
|
8
8
|
}
|
|
9
|
-
export declare const FeatureFlagValue:
|
|
10
|
-
export type FeatureFlagValueType =
|
|
9
|
+
export declare const FeatureFlagValue: v.PicklistSchema<FeatureFlagEnum[], string>;
|
|
10
|
+
export type FeatureFlagValueType = v.InferOutput<typeof FeatureFlagValue>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const FeatureFlagValueError = { Invalid: "feature.flag.value.invalid" };
|
|
3
3
|
export var FeatureFlagEnum;
|
|
4
4
|
(function (FeatureFlagEnum) {
|
|
5
5
|
FeatureFlagEnum["yes"] = "yes";
|
|
6
6
|
FeatureFlagEnum["no"] = "no";
|
|
7
7
|
})(FeatureFlagEnum || (FeatureFlagEnum = {}));
|
|
8
|
-
export const FeatureFlagValue =
|
|
8
|
+
export const FeatureFlagValue = v.picklist(Object.values(FeatureFlagEnum), FeatureFlagValueError.Invalid);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { Filename } from "./filename.vo";
|
|
3
3
|
export declare const FilePathAbsoluteSchemaError: {
|
|
4
4
|
Type: string;
|
|
@@ -7,8 +7,11 @@ export declare const FilePathAbsoluteSchemaError: {
|
|
|
7
7
|
BackslashForbidden: string;
|
|
8
8
|
Empty: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const FilePathAbsoluteSchema:
|
|
11
|
-
directory: string &
|
|
10
|
+
export declare const FilePathAbsoluteSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.TransformAction<string, {
|
|
11
|
+
directory: string & v.Brand<"DirectoryPathAbsoluteSchema">;
|
|
12
12
|
filename: Filename;
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
}>, v.BrandAction<{
|
|
14
|
+
directory: string & v.Brand<"DirectoryPathAbsoluteSchema">;
|
|
15
|
+
filename: Filename;
|
|
16
|
+
}, "FilePathAbsoluteSchema">]>;
|
|
17
|
+
export type FilePathAbsoluteType = v.InferOutput<typeof FilePathAbsoluteSchema>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
|
|
3
3
|
import { Filename } from "./filename.vo";
|
|
4
4
|
export const FilePathAbsoluteSchemaError = {
|
|
@@ -8,20 +8,13 @@ export const FilePathAbsoluteSchemaError = {
|
|
|
8
8
|
BackslashForbidden: "file.path.absolute.backslash.forbidden",
|
|
9
9
|
Empty: "file.path.absolute.empty",
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export const FilePathAbsoluteSchema = z
|
|
13
|
-
// Stryker restore all
|
|
14
|
-
.string(FilePathAbsoluteSchemaError.Type)
|
|
15
|
-
.min(1, FilePathAbsoluteSchemaError.Empty)
|
|
16
|
-
.refine((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash)
|
|
17
|
-
.refine((value) => !value.endsWith("/"), FilePathAbsoluteSchemaError.TrailingSlash)
|
|
18
|
-
.refine((value) => !value.includes("\\"), FilePathAbsoluteSchemaError.BackslashForbidden)
|
|
19
|
-
.transform((normalized) => {
|
|
11
|
+
export const FilePathAbsoluteSchema = v.pipe(v.string(FilePathAbsoluteSchemaError.Type), v.minLength(1, FilePathAbsoluteSchemaError.Empty), v.check((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash), v.check((value) => !value.endsWith("/"), FilePathAbsoluteSchemaError.TrailingSlash), v.check((value) => !value.includes("\\"), FilePathAbsoluteSchemaError.BackslashForbidden), v.transform((normalized) => {
|
|
20
12
|
const index = normalized.lastIndexOf("/");
|
|
21
13
|
const directoryCandidate = index === 0 ? "/" : normalized.slice(0, index);
|
|
22
14
|
const filenameCandidate = normalized.slice(index + 1);
|
|
23
|
-
const directory =
|
|
15
|
+
const directory = v.parse(DirectoryPathAbsoluteSchema, directoryCandidate);
|
|
24
16
|
const filename = Filename.fromString(filenameCandidate);
|
|
25
17
|
return { directory, filename };
|
|
26
|
-
})
|
|
27
|
-
|
|
18
|
+
}),
|
|
19
|
+
// Stryker disable next-line StringLiteral
|
|
20
|
+
v.brand("FilePathAbsoluteSchema"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { Filename } from "./filename.vo";
|
|
3
3
|
export declare const FilePathRelativeSchemaError: {
|
|
4
4
|
Type: string;
|
|
@@ -7,8 +7,11 @@ export declare const FilePathRelativeSchemaError: {
|
|
|
7
7
|
RequiresDirectory: string;
|
|
8
8
|
Empty: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const FilePathRelativeSchema:
|
|
11
|
-
directory: string &
|
|
10
|
+
export declare const FilePathRelativeSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.TransformAction<string, {
|
|
11
|
+
directory: string & v.Brand<"DirectoryPathRelativeSchema">;
|
|
12
12
|
filename: Filename;
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
}>, v.BrandAction<{
|
|
14
|
+
directory: string & v.Brand<"DirectoryPathRelativeSchema">;
|
|
15
|
+
filename: Filename;
|
|
16
|
+
}, "FilePathRelativeSchema">]>;
|
|
17
|
+
export type FilePathRelativeType = v.InferOutput<typeof FilePathRelativeSchema>;
|