@bgord/tools 1.2.22 → 1.3.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/filename.vo.d.ts +0 -2
- package/dist/filename.vo.js +0 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mime-registry.service.d.ts +17 -0
- package/dist/mime-registry.service.js +23 -0
- package/dist/mime.vo.d.ts +0 -3
- package/dist/mime.vo.js +0 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -4
- package/readme.md +1 -0
package/dist/filename.vo.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type BasenameType } from "./basename.vo";
|
|
2
2
|
import { type ExtensionType } from "./extension.vo";
|
|
3
3
|
import { FilenameAffixStrategy, type FilenameAffixType } from "./filename-affix.vo";
|
|
4
|
-
import { Mime } from "./mime.vo";
|
|
5
4
|
export declare class Filename {
|
|
6
5
|
private readonly basename;
|
|
7
6
|
private readonly extension;
|
|
@@ -12,7 +11,6 @@ export declare class Filename {
|
|
|
12
11
|
get(): string;
|
|
13
12
|
getBasename(): BasenameType;
|
|
14
13
|
getExtension(): ExtensionType;
|
|
15
|
-
getMime(): Mime;
|
|
16
14
|
withExtension(extension: ExtensionType): Filename;
|
|
17
15
|
withBasename(basename: BasenameType): Filename;
|
|
18
16
|
withAffix(candidate: string, strategy: FilenameAffixStrategy): Filename;
|
package/dist/filename.vo.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Basename } from "./basename.vo";
|
|
|
2
2
|
import { Extension } from "./extension.vo";
|
|
3
3
|
import { FilenameAffix, FilenameAffixStrategy } from "./filename-affix.vo";
|
|
4
4
|
import { FilenameFromString } from "./filename-from-string.vo";
|
|
5
|
-
import { Mime } from "./mime.vo";
|
|
6
5
|
export class Filename {
|
|
7
6
|
basename;
|
|
8
7
|
extension;
|
|
@@ -29,9 +28,6 @@ export class Filename {
|
|
|
29
28
|
getExtension() {
|
|
30
29
|
return this.extension;
|
|
31
30
|
}
|
|
32
|
-
getMime() {
|
|
33
|
-
return Mime.fromExtension(this.extension);
|
|
34
|
-
}
|
|
35
31
|
withExtension(extension) {
|
|
36
32
|
return new Filename(this.basename, extension);
|
|
37
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export * from "./language.vo";
|
|
|
46
46
|
export * from "./linear-regression.service";
|
|
47
47
|
export * from "./mean.service";
|
|
48
48
|
export * from "./mime.vo";
|
|
49
|
+
export * from "./mime-registry.service";
|
|
49
50
|
export * from "./mime-types.vo";
|
|
50
51
|
export * from "./mime-value.vo";
|
|
51
52
|
export * from "./min-max-scaler.service";
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export * from "./language.vo";
|
|
|
46
46
|
export * from "./linear-regression.service";
|
|
47
47
|
export * from "./mean.service";
|
|
48
48
|
export * from "./mime.vo";
|
|
49
|
+
export * from "./mime-registry.service";
|
|
49
50
|
export * from "./mime-types.vo";
|
|
50
51
|
export * from "./mime-value.vo";
|
|
51
52
|
export * from "./min-max-scaler.service";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExtensionType } from "./extension.vo";
|
|
2
|
+
import type { Mime } from "./mime.vo";
|
|
3
|
+
export type MimeRegistryEntry = {
|
|
4
|
+
mime: Mime;
|
|
5
|
+
extensions: ExtensionType[];
|
|
6
|
+
};
|
|
7
|
+
export declare const MimeRegistryError: {
|
|
8
|
+
ExtensionNotFound: string;
|
|
9
|
+
MimeNotFound: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class MimeRegistry {
|
|
12
|
+
private readonly byExtension;
|
|
13
|
+
private readonly byMime;
|
|
14
|
+
constructor(entries: readonly MimeRegistryEntry[]);
|
|
15
|
+
fromExtension(extension: ExtensionType): Mime | undefined;
|
|
16
|
+
toExtension(mime: Mime): ExtensionType | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const MimeRegistryError = {
|
|
2
|
+
ExtensionNotFound: "mime.registry.extension.not.found",
|
|
3
|
+
MimeNotFound: "mime.registry.mime.not.found",
|
|
4
|
+
};
|
|
5
|
+
export class MimeRegistry {
|
|
6
|
+
byExtension = new Map();
|
|
7
|
+
byMime = new Map();
|
|
8
|
+
constructor(entries) {
|
|
9
|
+
for (const entry of entries) {
|
|
10
|
+
for (const extension of entry.extensions) {
|
|
11
|
+
this.byExtension.set(extension, entry.mime);
|
|
12
|
+
}
|
|
13
|
+
const canonical = entry.extensions[0];
|
|
14
|
+
this.byMime.set(entry.mime.toString(), canonical);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
fromExtension(extension) {
|
|
18
|
+
return this.byExtension.get(extension);
|
|
19
|
+
}
|
|
20
|
+
toExtension(mime) {
|
|
21
|
+
return this.byMime.get(mime.toString());
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/mime.vo.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ExtensionType } from "./extension.vo";
|
|
2
1
|
export declare const MimeError: {
|
|
3
2
|
NotAccepted: string;
|
|
4
3
|
};
|
|
@@ -7,9 +6,7 @@ export declare class Mime {
|
|
|
7
6
|
readonly subtype: string;
|
|
8
7
|
private constructor();
|
|
9
8
|
static fromString(candidate: string): Mime;
|
|
10
|
-
static fromExtension(extension: ExtensionType): Mime;
|
|
11
9
|
isSatisfiedBy(another: Mime): boolean;
|
|
12
|
-
toExtension(): ExtensionType;
|
|
13
10
|
toString(): string;
|
|
14
11
|
toJSON(): {
|
|
15
12
|
type: string;
|
package/dist/mime.vo.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as mime from "mime-types";
|
|
2
|
-
import { Extension } from "./extension.vo";
|
|
3
1
|
import { MimeValue } from "./mime-value.vo";
|
|
4
2
|
export const MimeError = { NotAccepted: "mime.not.accepted" };
|
|
5
3
|
export class Mime {
|
|
@@ -13,17 +11,11 @@ export class Mime {
|
|
|
13
11
|
const { type, subtype } = MimeValue.parse(candidate.split(";")[0].trim());
|
|
14
12
|
return new Mime(type, subtype);
|
|
15
13
|
}
|
|
16
|
-
static fromExtension(extension) {
|
|
17
|
-
return Mime.fromString(String(mime.contentType(extension)));
|
|
18
|
-
}
|
|
19
14
|
isSatisfiedBy(another) {
|
|
20
15
|
if (!(this.type === another.type || this.type === "*"))
|
|
21
16
|
return false;
|
|
22
17
|
return this.subtype === another.subtype || this.subtype === "*";
|
|
23
18
|
}
|
|
24
|
-
toExtension() {
|
|
25
|
-
return Extension.parse(mime.extension(this.toString()));
|
|
26
|
-
}
|
|
27
19
|
toString() {
|
|
28
20
|
return `${this.type}/${this.subtype}`;
|
|
29
21
|
}
|
|
@@ -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/distance-value.vo.ts","../src/distance.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/email.vo.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/integer-non-negative.vo.ts","../src/integer-positive.vo.ts","../src/integer.vo.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-decimal.strategy.ts","../src/rounding-down.strategy.ts","../src/rounding-to-nearest.strategy.ts","../src/rounding-up.strategy.ts","../src/rounding.strategy.ts","../src/size-bytes.vo.ts","../src/size.vo.ts","../src/slug.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/url-with-slash.vo.ts","../src/url-without-slash.vo.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"}
|
|
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/distance-value.vo.ts","../src/distance.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/email.vo.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/integer-non-negative.vo.ts","../src/integer-positive.vo.ts","../src/integer.vo.ts","../src/language.vo.ts","../src/linear-regression.service.ts","../src/mean.service.ts","../src/mime-registry.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-decimal.strategy.ts","../src/rounding-down.strategy.ts","../src/rounding-to-nearest.strategy.ts","../src/rounding-up.strategy.ts","../src/rounding.strategy.ts","../src/size-bytes.vo.ts","../src/size.vo.ts","../src/slug.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/url-with-slash.vo.ts","../src/url-without-slash.vo.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@commitlint/config-conventional": "20.3.1",
|
|
26
26
|
"@stryker-mutator/core": "9.4.0",
|
|
27
27
|
"@types/bun": "1.3.6",
|
|
28
|
-
"@types/mime-types": "3.0.1",
|
|
29
28
|
"cspell": "9.6.0",
|
|
30
29
|
"knip": "5.81.0",
|
|
31
30
|
"lefthook": "2.0.15",
|
|
@@ -36,8 +35,7 @@
|
|
|
36
35
|
"zod": "4.3.5"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"date-fns": "4.1.0"
|
|
40
|
-
"mime-types": "3.0.2"
|
|
38
|
+
"date-fns": "4.1.0"
|
|
41
39
|
},
|
|
42
40
|
"peerDependencies": {
|
|
43
41
|
"zod": "4.3.5"
|