@bgord/tools 1.1.4 → 1.1.5
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/filename-affix.vo.d.ts +13 -0
- package/dist/filename-affix.vo.js +20 -0
- package/dist/filename.vo.d.ts +6 -2
- package/dist/filename.vo.js +23 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/src/filename-affix.vo.ts +25 -0
- package/src/filename.vo.ts +29 -8
- package/src/index.ts +1 -1
- package/dist/filename-suffix.vo.d.ts +0 -9
- package/dist/filename-suffix.vo.js +0 -15
- package/src/filename-suffix.vo.ts +0 -20
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export declare enum FilenameAffixStrategy {
|
|
3
|
+
prefix = "prefix",
|
|
4
|
+
suffix = "suffix"
|
|
5
|
+
}
|
|
6
|
+
export declare const FilenameAffixError: {
|
|
7
|
+
readonly Type: "affix.type";
|
|
8
|
+
readonly Empty: "affix.empty";
|
|
9
|
+
readonly TooLong: "affix.too.long";
|
|
10
|
+
readonly BadChars: "affix.bad.chars";
|
|
11
|
+
};
|
|
12
|
+
export declare const FilenameAffix: z.core.$ZodBranded<z.ZodString, "FilenameAffix">;
|
|
13
|
+
export type FilenameAffixType = z.infer<typeof FilenameAffix>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export var FilenameAffixStrategy;
|
|
3
|
+
(function (FilenameAffixStrategy) {
|
|
4
|
+
FilenameAffixStrategy["prefix"] = "prefix";
|
|
5
|
+
FilenameAffixStrategy["suffix"] = "suffix";
|
|
6
|
+
})(FilenameAffixStrategy || (FilenameAffixStrategy = {}));
|
|
7
|
+
export const FilenameAffixError = {
|
|
8
|
+
Type: "affix.type",
|
|
9
|
+
Empty: "affix.empty",
|
|
10
|
+
TooLong: "affix.too.long",
|
|
11
|
+
BadChars: "affix.bad.chars",
|
|
12
|
+
};
|
|
13
|
+
// Letters, digits, underscores, and hyphens allowed
|
|
14
|
+
const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
15
|
+
export const FilenameAffix = z
|
|
16
|
+
.string(FilenameAffixError.Type)
|
|
17
|
+
.min(1, FilenameAffixError.Empty)
|
|
18
|
+
.max(32, FilenameAffixError.TooLong)
|
|
19
|
+
.regex(FILENAME_AFFIX_WHITELIST, FilenameAffixError.BadChars)
|
|
20
|
+
.brand("FilenameAffix");
|
package/dist/filename.vo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BasenameType } from "./basename.vo";
|
|
2
2
|
import { type ExtensionType } from "./extension.vo";
|
|
3
|
-
import { type
|
|
3
|
+
import { FilenameAffixStrategy, type FilenameAffixType } from "./filename-affix.vo";
|
|
4
4
|
export declare class Filename {
|
|
5
5
|
private readonly basename;
|
|
6
6
|
private readonly extension;
|
|
@@ -13,8 +13,12 @@ export declare class Filename {
|
|
|
13
13
|
getExtension(): ExtensionType;
|
|
14
14
|
withExtension(extension: ExtensionType): Filename;
|
|
15
15
|
withBasename(basename: BasenameType): Filename;
|
|
16
|
+
withAffix(candidate: string, strategy: FilenameAffixStrategy): Filename;
|
|
17
|
+
withAffixSafe(affix: FilenameAffixType, strategy: FilenameAffixStrategy): Filename;
|
|
16
18
|
withSuffix(candidate: string): Filename;
|
|
17
|
-
withSuffixSafe(
|
|
19
|
+
withSuffixSafe(affix: FilenameAffixType): Filename;
|
|
20
|
+
withPrefix(candidate: string): Filename;
|
|
21
|
+
withPrefixSafe(affix: FilenameAffixType): Filename;
|
|
18
22
|
toString(): string;
|
|
19
23
|
toJSON(): string;
|
|
20
24
|
}
|
package/dist/filename.vo.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Basename } from "./basename.vo";
|
|
2
2
|
import { Extension } from "./extension.vo";
|
|
3
|
+
import { FilenameAffix, FilenameAffixStrategy } from "./filename-affix.vo";
|
|
3
4
|
import { FilenameFromString } from "./filename-from-string.vo";
|
|
4
|
-
import { FilenameSuffix } from "./filename-suffix.vo";
|
|
5
5
|
export class Filename {
|
|
6
6
|
basename;
|
|
7
7
|
extension;
|
|
@@ -34,14 +34,30 @@ export class Filename {
|
|
|
34
34
|
withBasename(basename) {
|
|
35
35
|
return new Filename(basename, this.extension);
|
|
36
36
|
}
|
|
37
|
+
withAffix(candidate, strategy) {
|
|
38
|
+
const affix = FilenameAffix.parse(candidate);
|
|
39
|
+
if (strategy === FilenameAffixStrategy.prefix) {
|
|
40
|
+
return new Filename(Basename.parse(`${affix}${this.basename}`), this.extension);
|
|
41
|
+
}
|
|
42
|
+
return new Filename(Basename.parse(`${this.basename}${affix}`), this.extension);
|
|
43
|
+
}
|
|
44
|
+
withAffixSafe(affix, strategy) {
|
|
45
|
+
if (strategy === FilenameAffixStrategy.prefix) {
|
|
46
|
+
return new Filename(Basename.parse(`${affix}${this.basename}`), this.extension);
|
|
47
|
+
}
|
|
48
|
+
return new Filename(Basename.parse(`${this.basename}${affix}`), this.extension);
|
|
49
|
+
}
|
|
37
50
|
withSuffix(candidate) {
|
|
38
|
-
|
|
39
|
-
const basename = Basename.parse(`${this.basename}${suffix}`);
|
|
40
|
-
return new Filename(basename, this.extension);
|
|
51
|
+
return this.withAffix(candidate, FilenameAffixStrategy.suffix);
|
|
41
52
|
}
|
|
42
|
-
withSuffixSafe(
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
withSuffixSafe(affix) {
|
|
54
|
+
return this.withAffix(affix, FilenameAffixStrategy.suffix);
|
|
55
|
+
}
|
|
56
|
+
withPrefix(candidate) {
|
|
57
|
+
return this.withAffix(candidate, FilenameAffixStrategy.prefix);
|
|
58
|
+
}
|
|
59
|
+
withPrefixSafe(affix) {
|
|
60
|
+
return this.withAffix(affix, FilenameAffixStrategy.prefix);
|
|
45
61
|
}
|
|
46
62
|
toString() {
|
|
47
63
|
return this.get();
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export * from "./file-path.vo";
|
|
|
24
24
|
export * from "./file-path-absolute-schema.vo";
|
|
25
25
|
export * from "./file-path-relative-schema.vo";
|
|
26
26
|
export * from "./filename.vo";
|
|
27
|
+
export * from "./filename-affix.vo";
|
|
27
28
|
export * from "./filename-from-string.vo";
|
|
28
|
-
export * from "./filename-suffix.vo";
|
|
29
29
|
export * from "./height.vo";
|
|
30
30
|
export * from "./height-milimiters.vo";
|
|
31
31
|
export * from "./hour.vo";
|
package/dist/index.js
CHANGED
|
@@ -24,8 +24,8 @@ export * from "./file-path.vo";
|
|
|
24
24
|
export * from "./file-path-absolute-schema.vo";
|
|
25
25
|
export * from "./file-path-relative-schema.vo";
|
|
26
26
|
export * from "./filename.vo";
|
|
27
|
+
export * from "./filename-affix.vo";
|
|
27
28
|
export * from "./filename-from-string.vo";
|
|
28
|
-
export * from "./filename-suffix.vo";
|
|
29
29
|
export * from "./height.vo";
|
|
30
30
|
export * from "./height-milimiters.vo";
|
|
31
31
|
export * from "./hour.vo";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/clock-format.service.ts","../src/clock.vo.ts","../src/date-calculator.service.ts","../src/date-formatter.service.ts","../src/date-range.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/division-factor.vo.ts","../src/dll.service.ts","../src/duration-ms.vo.ts","../src/duration.service.ts","../src/email-mask.service.ts","../src/etags.vo.ts","../src/extension.vo.ts","../src/feature-flag-value.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-
|
|
1
|
+
{"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/clock-format.service.ts","../src/clock.vo.ts","../src/date-calculator.service.ts","../src/date-formatter.service.ts","../src/date-range.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/division-factor.vo.ts","../src/dll.service.ts","../src/duration-ms.vo.ts","../src/duration.service.ts","../src/email-mask.service.ts","../src/etags.vo.ts","../src/extension.vo.ts","../src/feature-flag-value.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-affix.vo.ts","../src/filename-from-string.vo.ts","../src/filename.vo.ts","../src/height-milimiters.vo.ts","../src/height.vo.ts","../src/hour-format.service.ts","../src/hour-schema.vo.ts","../src/hour.vo.ts","../src/iban-mask.service.ts","../src/iban-schema.vo.ts","../src/iban.vo.ts","../src/image.vo.ts","../src/index.ts","../src/language.vo.ts","../src/linear-regression.service.ts","../src/mean.service.ts","../src/mime-types.vo.ts","../src/mime-value.vo.ts","../src/mime.vo.ts","../src/min-max-scaler.service.ts","../src/minute-schema.vo.ts","../src/minute.vo.ts","../src/money-amount.vo.ts","../src/money.vo.ts","../src/month-iso-id.vo.ts","../src/month.vo.ts","../src/multiplication-factor.vo.ts","../src/noop.service.ts","../src/notification-template.vo.ts","../src/object-key.vo.ts","../src/outlier-detector.service.ts","../src/package-version-schema.vo.ts","../src/package-version.vo.ts","../src/pagination-page.vo.ts","../src/pagination-skip.vo.ts","../src/pagination-take.vo.ts","../src/pagination.service.ts","../src/percentage.service.ts","../src/population-standard-deviation.service.ts","../src/quarter-iso-id.vo.ts","../src/quarter.vo.ts","../src/random.service.ts","../src/rate-limiter.service.ts","../src/relative-date.vo.ts","../src/reordering-item-position-value.vo.ts","../src/reordering.service.ts","../src/revision-value.vo.ts","../src/revision.vo.ts","../src/rounding.adapter.ts","../src/rounding.port.ts","../src/size-bytes.vo.ts","../src/size.vo.ts","../src/stopwatch.service.ts","../src/sum.service.ts","../src/thousands-separator.service.ts","../src/time-zone-offset-value.vo.ts","../src/timestamp-value.vo.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/weekday.vo.ts","../src/weight-grams.vo.ts","../src/weight.vo.ts","../src/year-iso-id.vo.ts","../src/year.vo.ts","../src/z-score.service.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -49,8 +49,8 @@ src/
|
|
|
49
49
|
├── file-path-absolute-schema.vo.ts
|
|
50
50
|
├── file-path-relative-schema.vo.ts
|
|
51
51
|
├── file-path.vo.ts
|
|
52
|
+
├── filename-affix.vo.ts
|
|
52
53
|
├── filename-from-string.vo.ts
|
|
53
|
-
├── filename-suffix.vo.ts
|
|
54
54
|
├── filename.vo.ts
|
|
55
55
|
├── height-milimiters.vo.ts
|
|
56
56
|
├── height.vo.ts
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
export enum FilenameAffixStrategy {
|
|
4
|
+
prefix = "prefix",
|
|
5
|
+
suffix = "suffix",
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const FilenameAffixError = {
|
|
9
|
+
Type: "affix.type",
|
|
10
|
+
Empty: "affix.empty",
|
|
11
|
+
TooLong: "affix.too.long",
|
|
12
|
+
BadChars: "affix.bad.chars",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
// Letters, digits, underscores, and hyphens allowed
|
|
16
|
+
const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
17
|
+
|
|
18
|
+
export const FilenameAffix = z
|
|
19
|
+
.string(FilenameAffixError.Type)
|
|
20
|
+
.min(1, FilenameAffixError.Empty)
|
|
21
|
+
.max(32, FilenameAffixError.TooLong)
|
|
22
|
+
.regex(FILENAME_AFFIX_WHITELIST, FilenameAffixError.BadChars)
|
|
23
|
+
.brand("FilenameAffix");
|
|
24
|
+
|
|
25
|
+
export type FilenameAffixType = z.infer<typeof FilenameAffix>;
|
package/src/filename.vo.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Basename, type BasenameType } from "./basename.vo";
|
|
2
2
|
import { Extension, type ExtensionType } from "./extension.vo";
|
|
3
|
+
import { FilenameAffix, FilenameAffixStrategy, type FilenameAffixType } from "./filename-affix.vo";
|
|
3
4
|
import { FilenameFromString } from "./filename-from-string.vo";
|
|
4
|
-
import { FilenameSuffix, type FilenameSuffixType } from "./filename-suffix.vo";
|
|
5
5
|
|
|
6
6
|
export class Filename {
|
|
7
7
|
private constructor(
|
|
@@ -43,17 +43,38 @@ export class Filename {
|
|
|
43
43
|
return new Filename(basename, this.extension);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const basename = Basename.parse(`${this.basename}${suffix}`);
|
|
46
|
+
withAffix(candidate: string, strategy: FilenameAffixStrategy): Filename {
|
|
47
|
+
const affix = FilenameAffix.parse(candidate);
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
if (strategy === FilenameAffixStrategy.prefix) {
|
|
50
|
+
return new Filename(Basename.parse(`${affix}${this.basename}`), this.extension);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return new Filename(Basename.parse(`${this.basename}${affix}`), this.extension);
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
withAffixSafe(affix: FilenameAffixType, strategy: FilenameAffixStrategy): Filename {
|
|
57
|
+
if (strategy === FilenameAffixStrategy.prefix) {
|
|
58
|
+
return new Filename(Basename.parse(`${affix}${this.basename}`), this.extension);
|
|
59
|
+
}
|
|
55
60
|
|
|
56
|
-
return new Filename(basename, this.extension);
|
|
61
|
+
return new Filename(Basename.parse(`${this.basename}${affix}`), this.extension);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
withSuffix(candidate: string) {
|
|
65
|
+
return this.withAffix(candidate, FilenameAffixStrategy.suffix);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
withSuffixSafe(affix: FilenameAffixType): Filename {
|
|
69
|
+
return this.withAffix(affix, FilenameAffixStrategy.suffix);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
withPrefix(candidate: string) {
|
|
73
|
+
return this.withAffix(candidate, FilenameAffixStrategy.prefix);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
withPrefixSafe(affix: FilenameAffixType): Filename {
|
|
77
|
+
return this.withAffix(affix, FilenameAffixStrategy.prefix);
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
toString(): string {
|
package/src/index.ts
CHANGED
|
@@ -24,8 +24,8 @@ export * from "./file-path.vo";
|
|
|
24
24
|
export * from "./file-path-absolute-schema.vo";
|
|
25
25
|
export * from "./file-path-relative-schema.vo";
|
|
26
26
|
export * from "./filename.vo";
|
|
27
|
+
export * from "./filename-affix.vo";
|
|
27
28
|
export * from "./filename-from-string.vo";
|
|
28
|
-
export * from "./filename-suffix.vo";
|
|
29
29
|
export * from "./height.vo";
|
|
30
30
|
export * from "./height-milimiters.vo";
|
|
31
31
|
export * from "./hour.vo";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
export declare const FilenameSuffixError: {
|
|
3
|
-
readonly Type: "suffix.type";
|
|
4
|
-
readonly Empty: "suffix.empty";
|
|
5
|
-
readonly TooLong: "suffix.too.long";
|
|
6
|
-
readonly BadChars: "suffix.bad.chars";
|
|
7
|
-
};
|
|
8
|
-
export declare const FilenameSuffix: z.core.$ZodBranded<z.ZodString, "FilenameSuffix">;
|
|
9
|
-
export type FilenameSuffixType = z.infer<typeof FilenameSuffix>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
export const FilenameSuffixError = {
|
|
3
|
-
Type: "suffix.type",
|
|
4
|
-
Empty: "suffix.empty",
|
|
5
|
-
TooLong: "suffix.too.long",
|
|
6
|
-
BadChars: "suffix.bad.chars",
|
|
7
|
-
};
|
|
8
|
-
// Letters, digits, underscores, and hyphens allowed
|
|
9
|
-
const FILENAME_SUFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
10
|
-
export const FilenameSuffix = z
|
|
11
|
-
.string(FilenameSuffixError.Type)
|
|
12
|
-
.min(1, FilenameSuffixError.Empty)
|
|
13
|
-
.max(32, FilenameSuffixError.TooLong)
|
|
14
|
-
.regex(FILENAME_SUFFIX_WHITELIST, FilenameSuffixError.BadChars)
|
|
15
|
-
.brand("FilenameSuffix");
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
|
|
3
|
-
export const FilenameSuffixError = {
|
|
4
|
-
Type: "suffix.type",
|
|
5
|
-
Empty: "suffix.empty",
|
|
6
|
-
TooLong: "suffix.too.long",
|
|
7
|
-
BadChars: "suffix.bad.chars",
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
// Letters, digits, underscores, and hyphens allowed
|
|
11
|
-
const FILENAME_SUFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
12
|
-
|
|
13
|
-
export const FilenameSuffix = z
|
|
14
|
-
.string(FilenameSuffixError.Type)
|
|
15
|
-
.min(1, FilenameSuffixError.Empty)
|
|
16
|
-
.max(32, FilenameSuffixError.TooLong)
|
|
17
|
-
.regex(FILENAME_SUFFIX_WHITELIST, FilenameSuffixError.BadChars)
|
|
18
|
-
.brand("FilenameSuffix");
|
|
19
|
-
|
|
20
|
-
export type FilenameSuffixType = z.infer<typeof FilenameSuffix>;
|