@bgord/tools 0.12.15 → 0.12.16
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/file-path-absolute-schema.vo.d.ts +6 -0
- package/dist/file-path-absolute-schema.vo.js +19 -0
- package/dist/file-path-relative-schema.vo.d.ts +6 -0
- package/dist/file-path-relative-schema.vo.js +19 -0
- package/dist/file-path.vo.d.ts +2 -0
- package/dist/file-path.vo.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +2 -0
- package/src/file-path-absolute-schema.vo.ts +22 -0
- package/src/file-path-relative-schema.vo.ts +22 -0
- package/src/file-path.vo.ts +12 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { Filename } from "./filename.vo";
|
|
3
|
+
export declare const FilePathAbsoluteSchema: z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<{
|
|
4
|
+
directory: string & z.core.$brand<"absolute_directory_path">;
|
|
5
|
+
filename: Filename;
|
|
6
|
+
}, string>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
|
|
3
|
+
import { Filename } from "./filename.vo";
|
|
4
|
+
export const FilePathAbsoluteSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.refine((value) => value.startsWith("/"), "abs_file_path_must_start_with_slash")
|
|
8
|
+
.refine((value) => !value.includes("\\"), "abs_file_path_backslash_forbidden")
|
|
9
|
+
.transform((value) => value.replace(/\/{2,}/g, "/")) // collapse //
|
|
10
|
+
.transform((value) => (value !== "/" && value.endsWith("/") ? value.slice(0, -1) : value)) // keep "/" as-is
|
|
11
|
+
.refine((value) => value !== "/", "abs_file_path_missing_filename")
|
|
12
|
+
.transform((normalized) => {
|
|
13
|
+
const lastSlashIndex = normalized.lastIndexOf("/");
|
|
14
|
+
const directoryCandidate = lastSlashIndex === 0 ? "/" : normalized.slice(0, lastSlashIndex);
|
|
15
|
+
const filenameCandidate = normalized.slice(lastSlashIndex + 1);
|
|
16
|
+
const directory = DirectoryPathAbsoluteSchema.parse(directoryCandidate);
|
|
17
|
+
const filename = Filename.fromString(filenameCandidate);
|
|
18
|
+
return { directory, filename };
|
|
19
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { Filename } from "./filename.vo";
|
|
3
|
+
export declare const FilePathRelativeSchema: z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<{
|
|
4
|
+
directory: string & z.core.$brand<"relative_directory_path">;
|
|
5
|
+
filename: Filename;
|
|
6
|
+
}, string>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
|
|
3
|
+
import { Filename } from "./filename.vo";
|
|
4
|
+
export const FilePathRelativeSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.refine((value) => !value.startsWith("/"), "rel_file_path_must_not_start_with_slash")
|
|
8
|
+
.refine((value) => !value.includes("\\"), "rel_file_path_backslash_forbidden")
|
|
9
|
+
.transform((value) => value.replace(/\/{2,}/g, "/")) // collapse //
|
|
10
|
+
.transform((value) => value.replace(/^\/+|\/+$/g, "")) // trim leading/trailing slashes
|
|
11
|
+
.refine((value) => value.includes("/"), "rel_file_path_requires_directory")
|
|
12
|
+
.transform((normalized) => {
|
|
13
|
+
const lastSlashIndex = normalized.lastIndexOf("/");
|
|
14
|
+
const directoryCandidate = normalized.slice(0, lastSlashIndex);
|
|
15
|
+
const filenameCandidate = normalized.slice(lastSlashIndex + 1);
|
|
16
|
+
const directory = DirectoryPathRelativeSchema.parse(directoryCandidate);
|
|
17
|
+
const filename = Filename.fromString(filenameCandidate);
|
|
18
|
+
return { directory, filename };
|
|
19
|
+
});
|
package/dist/file-path.vo.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class FilePathRelative {
|
|
|
7
7
|
private constructor();
|
|
8
8
|
static fromParts(directoryCandidate: string, filename: Filename): FilePathRelative;
|
|
9
9
|
static fromPartsSafe(directory: DirectoryPathRelativeType, filename: Filename): FilePathRelative;
|
|
10
|
+
static fromString(pathCandidate: string): FilePathRelative;
|
|
10
11
|
get(): string;
|
|
11
12
|
getDirectory(): DirectoryPathRelativeType;
|
|
12
13
|
getFilename(): Filename;
|
|
@@ -20,6 +21,7 @@ export declare class FilePathAbsolute {
|
|
|
20
21
|
private constructor();
|
|
21
22
|
static fromParts(directoryCandidate: string, filename: Filename): FilePathAbsolute;
|
|
22
23
|
static fromPartsSafe(directory: DirectoryPathAbsoluteType, filename: Filename): FilePathAbsolute;
|
|
24
|
+
static fromString(pathCandidate: string): FilePathAbsolute;
|
|
23
25
|
get(): string;
|
|
24
26
|
getDirectory(): DirectoryPathAbsoluteType;
|
|
25
27
|
getFilename(): Filename;
|
package/dist/file-path.vo.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
|
|
2
2
|
import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
|
|
3
|
+
import { FilePathAbsoluteSchema } from "./file-path-absolute-schema.vo";
|
|
4
|
+
import { FilePathRelativeSchema } from "./file-path-relative-schema.vo";
|
|
3
5
|
export class FilePathRelative {
|
|
4
6
|
directory;
|
|
5
7
|
filename;
|
|
@@ -14,6 +16,10 @@ export class FilePathRelative {
|
|
|
14
16
|
static fromPartsSafe(directory, filename) {
|
|
15
17
|
return new FilePathRelative(directory, filename);
|
|
16
18
|
}
|
|
19
|
+
static fromString(pathCandidate) {
|
|
20
|
+
const { directory, filename } = FilePathRelativeSchema.parse(pathCandidate);
|
|
21
|
+
return new FilePathRelative(directory, filename);
|
|
22
|
+
}
|
|
17
23
|
get() {
|
|
18
24
|
return `${this.directory}/${this.filename.get()}`;
|
|
19
25
|
}
|
|
@@ -47,6 +53,10 @@ export class FilePathAbsolute {
|
|
|
47
53
|
static fromPartsSafe(directory, filename) {
|
|
48
54
|
return new FilePathAbsolute(directory, filename);
|
|
49
55
|
}
|
|
56
|
+
static fromString(pathCandidate) {
|
|
57
|
+
const { directory, filename } = FilePathAbsoluteSchema.parse(pathCandidate);
|
|
58
|
+
return new FilePathAbsolute(directory, filename);
|
|
59
|
+
}
|
|
50
60
|
get() {
|
|
51
61
|
if (this.directory === "/")
|
|
52
62
|
return `/${this.filename.get()}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from "./etags.vo";
|
|
|
16
16
|
export * from "./extension.vo";
|
|
17
17
|
export * from "./feature-flag.vo";
|
|
18
18
|
export * from "./file-path.vo";
|
|
19
|
+
export * from "./file-path-absolute-schema.vo";
|
|
20
|
+
export * from "./file-path-relative-schema.vo";
|
|
19
21
|
export * from "./filename.vo";
|
|
20
22
|
export * from "./filename-from-string.vo";
|
|
21
23
|
export * from "./filename-suffix.vo";
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export * from "./etags.vo";
|
|
|
16
16
|
export * from "./extension.vo";
|
|
17
17
|
export * from "./feature-flag.vo";
|
|
18
18
|
export * from "./file-path.vo";
|
|
19
|
+
export * from "./file-path-absolute-schema.vo";
|
|
20
|
+
export * from "./file-path-relative-schema.vo";
|
|
19
21
|
export * from "./filename.vo";
|
|
20
22
|
export * from "./filename-from-string.vo";
|
|
21
23
|
export * from "./filename-suffix.vo";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/api-key.vo.ts","../src/basename.vo.ts","../src/build-version.vo.ts","../src/clock.vo.ts","../src/date-calculator.service.ts","../src/date-formatter.service.ts","../src/date-range.vo.ts","../src/dates-of-the-week.vo.ts","../src/day-iso-id.vo.ts","../src/day.vo.ts","../src/directory-path-absolute.vo.ts","../src/directory-path-relative.vo.ts","../src/dll.service.ts","../src/email-mask.service.ts","../src/etags.vo.ts","../src/extension.vo.ts","../src/feature-flag.vo.ts","../src/file-path.vo.ts","../src/filename-from-string.vo.ts","../src/filename-suffix.vo.ts","../src/filename.vo.ts","../src/filter.vo.ts","../src/hour.vo.ts","../src/iban-mask.service.ts","../src/iban.vo.ts","../src/image.vo.ts","../src/index.ts","../src/language.vo.ts","../src/leap-year-checker.service.ts","../src/mean.service.ts","../src/mime-types.vo.ts","../src/mime.vo.ts","../src/min-max-scaler.service.ts","../src/minute.vo.ts","../src/money.vo.ts","../src/noop.service.ts","../src/notification-template.vo.ts","../src/outlier-detector.service.ts","../src/package-version.vo.ts","../src/pagination.service.ts","../src/percentage.service.ts","../src/population-standard-deviation.service.ts","../src/random.service.ts","../src/rate-limiter.service.ts","../src/relative-date.vo.ts","../src/reordering.service.ts","../src/revision.vo.ts","../src/rounding.service.ts","../src/simple-linear-regression.service.ts","../src/size.vo.ts","../src/stepper.service.ts","../src/stopwatch.service.ts","../src/streak-calculator.service.ts","../src/sum.service.ts","../src/thousands-separator.service.ts","../src/time-zone-offset-value.vo.ts","../src/time.service.ts","../src/timestamp.vo.ts","../src/timezone.vo.ts","../src/ts-utils.ts","../src/visually-unambiguous-characters-generator.service.ts","../src/week-iso-id.vo.ts","../src/week.vo.ts","../src/z-score.service.ts"],"version":"5.9.2"}
|
|
1
|
+
{"root":["../src/api-key.vo.ts","../src/basename.vo.ts","../src/build-version.vo.ts","../src/clock.vo.ts","../src/date-calculator.service.ts","../src/date-formatter.service.ts","../src/date-range.vo.ts","../src/dates-of-the-week.vo.ts","../src/day-iso-id.vo.ts","../src/day.vo.ts","../src/directory-path-absolute.vo.ts","../src/directory-path-relative.vo.ts","../src/dll.service.ts","../src/email-mask.service.ts","../src/etags.vo.ts","../src/extension.vo.ts","../src/feature-flag.vo.ts","../src/file-path-absolute-schema.vo.ts","../src/file-path-relative-schema.vo.ts","../src/file-path.vo.ts","../src/filename-from-string.vo.ts","../src/filename-suffix.vo.ts","../src/filename.vo.ts","../src/filter.vo.ts","../src/hour.vo.ts","../src/iban-mask.service.ts","../src/iban.vo.ts","../src/image.vo.ts","../src/index.ts","../src/language.vo.ts","../src/leap-year-checker.service.ts","../src/mean.service.ts","../src/mime-types.vo.ts","../src/mime.vo.ts","../src/min-max-scaler.service.ts","../src/minute.vo.ts","../src/money.vo.ts","../src/noop.service.ts","../src/notification-template.vo.ts","../src/outlier-detector.service.ts","../src/package-version.vo.ts","../src/pagination.service.ts","../src/percentage.service.ts","../src/population-standard-deviation.service.ts","../src/random.service.ts","../src/rate-limiter.service.ts","../src/relative-date.vo.ts","../src/reordering.service.ts","../src/revision.vo.ts","../src/rounding.service.ts","../src/simple-linear-regression.service.ts","../src/size.vo.ts","../src/stepper.service.ts","../src/stopwatch.service.ts","../src/streak-calculator.service.ts","../src/sum.service.ts","../src/thousands-separator.service.ts","../src/time-zone-offset-value.vo.ts","../src/time.service.ts","../src/timestamp.vo.ts","../src/timezone.vo.ts","../src/ts-utils.ts","../src/visually-unambiguous-characters-generator.service.ts","../src/week-iso-id.vo.ts","../src/week.vo.ts","../src/z-score.service.ts"],"version":"5.9.2"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
|
|
3
|
+
import { Filename } from "./filename.vo";
|
|
4
|
+
|
|
5
|
+
export const FilePathAbsoluteSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.trim()
|
|
8
|
+
.refine((value) => value.startsWith("/"), "abs_file_path_must_start_with_slash")
|
|
9
|
+
.refine((value) => !value.includes("\\"), "abs_file_path_backslash_forbidden")
|
|
10
|
+
.transform((value) => value.replace(/\/{2,}/g, "/")) // collapse //
|
|
11
|
+
.transform((value) => (value !== "/" && value.endsWith("/") ? value.slice(0, -1) : value)) // keep "/" as-is
|
|
12
|
+
.refine((value) => value !== "/", "abs_file_path_missing_filename")
|
|
13
|
+
.transform((normalized) => {
|
|
14
|
+
const lastSlashIndex = normalized.lastIndexOf("/");
|
|
15
|
+
const directoryCandidate = lastSlashIndex === 0 ? "/" : normalized.slice(0, lastSlashIndex);
|
|
16
|
+
const filenameCandidate = normalized.slice(lastSlashIndex + 1);
|
|
17
|
+
|
|
18
|
+
const directory = DirectoryPathAbsoluteSchema.parse(directoryCandidate);
|
|
19
|
+
const filename = Filename.fromString(filenameCandidate);
|
|
20
|
+
|
|
21
|
+
return { directory, filename };
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
|
|
3
|
+
import { Filename } from "./filename.vo";
|
|
4
|
+
|
|
5
|
+
export const FilePathRelativeSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.trim()
|
|
8
|
+
.refine((value) => !value.startsWith("/"), "rel_file_path_must_not_start_with_slash")
|
|
9
|
+
.refine((value) => !value.includes("\\"), "rel_file_path_backslash_forbidden")
|
|
10
|
+
.transform((value) => value.replace(/\/{2,}/g, "/")) // collapse //
|
|
11
|
+
.transform((value) => value.replace(/^\/+|\/+$/g, "")) // trim leading/trailing slashes
|
|
12
|
+
.refine((value) => value.includes("/"), "rel_file_path_requires_directory")
|
|
13
|
+
.transform((normalized) => {
|
|
14
|
+
const lastSlashIndex = normalized.lastIndexOf("/");
|
|
15
|
+
const directoryCandidate = normalized.slice(0, lastSlashIndex);
|
|
16
|
+
const filenameCandidate = normalized.slice(lastSlashIndex + 1);
|
|
17
|
+
|
|
18
|
+
const directory = DirectoryPathRelativeSchema.parse(directoryCandidate);
|
|
19
|
+
const filename = Filename.fromString(filenameCandidate);
|
|
20
|
+
|
|
21
|
+
return { directory, filename };
|
|
22
|
+
});
|
package/src/file-path.vo.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DirectoryPathAbsoluteSchema, type DirectoryPathAbsoluteType } from "./directory-path-absolute.vo";
|
|
2
2
|
import { DirectoryPathRelativeSchema, type DirectoryPathRelativeType } from "./directory-path-relative.vo";
|
|
3
|
+
import { FilePathAbsoluteSchema } from "./file-path-absolute-schema.vo";
|
|
4
|
+
import { FilePathRelativeSchema } from "./file-path-relative-schema.vo";
|
|
3
5
|
import type { Filename } from "./filename.vo";
|
|
4
6
|
|
|
5
7
|
export class FilePathRelative {
|
|
@@ -17,6 +19,11 @@ export class FilePathRelative {
|
|
|
17
19
|
return new FilePathRelative(directory, filename);
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
static fromString(pathCandidate: string): FilePathRelative {
|
|
23
|
+
const { directory, filename } = FilePathRelativeSchema.parse(pathCandidate);
|
|
24
|
+
return new FilePathRelative(directory, filename);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
get() {
|
|
21
28
|
return `${this.directory}/${this.filename.get()}`;
|
|
22
29
|
}
|
|
@@ -57,6 +64,11 @@ export class FilePathAbsolute {
|
|
|
57
64
|
return new FilePathAbsolute(directory, filename);
|
|
58
65
|
}
|
|
59
66
|
|
|
67
|
+
static fromString(pathCandidate: string): FilePathAbsolute {
|
|
68
|
+
const { directory, filename } = FilePathAbsoluteSchema.parse(pathCandidate);
|
|
69
|
+
return new FilePathAbsolute(directory, filename);
|
|
70
|
+
}
|
|
71
|
+
|
|
60
72
|
get() {
|
|
61
73
|
if (this.directory === ("/" as DirectoryPathAbsoluteType)) return `/${this.filename.get()}`;
|
|
62
74
|
return `${this.directory}/${this.filename.get()}`;
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from "./etags.vo";
|
|
|
16
16
|
export * from "./extension.vo";
|
|
17
17
|
export * from "./feature-flag.vo";
|
|
18
18
|
export * from "./file-path.vo";
|
|
19
|
+
export * from "./file-path-absolute-schema.vo";
|
|
20
|
+
export * from "./file-path-relative-schema.vo";
|
|
19
21
|
export * from "./filename.vo";
|
|
20
22
|
export * from "./filename-from-string.vo";
|
|
21
23
|
export * from "./filename-suffix.vo";
|