@bgord/tools 1.4.5 → 1.4.7

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 (222) hide show
  1. package/package.json +3 -3
  2. package/dist/age-years.vo.d.ts +0 -11
  3. package/dist/age-years.vo.js +0 -6
  4. package/dist/age.vo.d.ts +0 -28
  5. package/dist/age.vo.js +0 -51
  6. package/dist/api-key.vo.d.ts +0 -7
  7. package/dist/api-key.vo.js +0 -7
  8. package/dist/basename.vo.d.ts +0 -12
  9. package/dist/basename.vo.js +0 -22
  10. package/dist/batch.d.ts +0 -2
  11. package/dist/batch.js +0 -3
  12. package/dist/date-calculator.service.d.ts +0 -10
  13. package/dist/date-calculator.service.js +0 -12
  14. package/dist/date-formatter.service.d.ts +0 -9
  15. package/dist/date-formatter.service.js +0 -15
  16. package/dist/date-range.vo.d.ts +0 -21
  17. package/dist/date-range.vo.js +0 -35
  18. package/dist/day-iso-id.vo.d.ts +0 -9
  19. package/dist/day-iso-id.vo.js +0 -12
  20. package/dist/day.vo.d.ts +0 -16
  21. package/dist/day.vo.js +0 -43
  22. package/dist/directory-path-absolute.vo.d.ts +0 -12
  23. package/dist/directory-path-absolute.vo.js +0 -20
  24. package/dist/directory-path-relative.vo.d.ts +0 -12
  25. package/dist/directory-path-relative.vo.js +0 -17
  26. package/dist/distance-value.vo.d.ts +0 -7
  27. package/dist/distance-value.vo.js +0 -5
  28. package/dist/distance.vo.d.ts +0 -23
  29. package/dist/distance.vo.js +0 -53
  30. package/dist/division-factor.vo.d.ts +0 -7
  31. package/dist/division-factor.vo.js +0 -5
  32. package/dist/dll.service.d.ts +0 -29
  33. package/dist/dll.service.js +0 -148
  34. package/dist/duration-ms.vo.d.ts +0 -6
  35. package/dist/duration-ms.vo.js +0 -5
  36. package/dist/duration.service.d.ts +0 -37
  37. package/dist/duration.service.js +0 -87
  38. package/dist/email-mask.service.d.ts +0 -4
  39. package/dist/email-mask.service.js +0 -12
  40. package/dist/email.vo.d.ts +0 -6
  41. package/dist/email.vo.js +0 -4
  42. package/dist/etags.vo.d.ts +0 -23
  43. package/dist/etags.vo.js +0 -37
  44. package/dist/extension.vo.d.ts +0 -9
  45. package/dist/extension.vo.js +0 -15
  46. package/dist/feature-flag-value.vo.d.ts +0 -10
  47. package/dist/feature-flag-value.vo.js +0 -8
  48. package/dist/feature-flag.vo.d.ts +0 -5
  49. package/dist/feature-flag.vo.js +0 -9
  50. package/dist/file-path-absolute-schema.vo.d.ts +0 -17
  51. package/dist/file-path-absolute-schema.vo.js +0 -20
  52. package/dist/file-path-relative-schema.vo.d.ts +0 -17
  53. package/dist/file-path-relative-schema.vo.js +0 -20
  54. package/dist/file-path.vo.d.ts +0 -31
  55. package/dist/file-path.vo.js +0 -81
  56. package/dist/filename-affix.vo.d.ts +0 -13
  57. package/dist/filename-affix.vo.js +0 -17
  58. package/dist/filename-from-string.vo.d.ts +0 -10
  59. package/dist/filename-from-string.vo.js +0 -17
  60. package/dist/filename.vo.d.ts +0 -24
  61. package/dist/filename.vo.js +0 -69
  62. package/dist/height-milimiters.vo.d.ts +0 -7
  63. package/dist/height-milimiters.vo.js +0 -8
  64. package/dist/height.vo.d.ts +0 -21
  65. package/dist/height.vo.js +0 -51
  66. package/dist/hour-value.vo.d.ts +0 -7
  67. package/dist/hour-value.vo.js +0 -5
  68. package/dist/hour.vo.d.ts +0 -20
  69. package/dist/hour.vo.js +0 -48
  70. package/dist/iban-mask.service.d.ts +0 -4
  71. package/dist/iban-mask.service.js +0 -12
  72. package/dist/iban-schema.vo.d.ts +0 -7
  73. package/dist/iban-schema.vo.js +0 -7
  74. package/dist/iban.vo.d.ts +0 -9
  75. package/dist/iban.vo.js +0 -23
  76. package/dist/image.vo.d.ts +0 -13
  77. package/dist/image.vo.js +0 -10
  78. package/dist/index.d.ts +0 -110
  79. package/dist/index.js +0 -110
  80. package/dist/int.vo.d.ts +0 -8
  81. package/dist/int.vo.js +0 -15
  82. package/dist/integer-non-negative.vo.d.ts +0 -7
  83. package/dist/integer-non-negative.vo.js +0 -8
  84. package/dist/integer-positive.vo.d.ts +0 -7
  85. package/dist/integer-positive.vo.js +0 -5
  86. package/dist/integer.vo.d.ts +0 -6
  87. package/dist/integer.vo.js +0 -4
  88. package/dist/language.vo.d.ts +0 -7
  89. package/dist/language.vo.js +0 -5
  90. package/dist/linear-regression.service.d.ts +0 -27
  91. package/dist/linear-regression.service.js +0 -58
  92. package/dist/mean.service.d.ts +0 -8
  93. package/dist/mean.service.js +0 -13
  94. package/dist/mime-registry-entry.vo.d.ts +0 -7
  95. package/dist/mime-registry-entry.vo.js +0 -8
  96. package/dist/mime-registry.service.d.ts +0 -16
  97. package/dist/mime-registry.service.js +0 -31
  98. package/dist/mime-value.vo.d.ts +0 -7
  99. package/dist/mime-value.vo.js +0 -7
  100. package/dist/mime.vo.d.ts +0 -12
  101. package/dist/mime.vo.js +0 -26
  102. package/dist/mimes.d.ts +0 -13
  103. package/dist/mimes.js +0 -19
  104. package/dist/min-max-scaler.service.d.ts +0 -46
  105. package/dist/min-max-scaler.service.js +0 -61
  106. package/dist/minute-value.vo.d.ts +0 -7
  107. package/dist/minute-value.vo.js +0 -5
  108. package/dist/minute.vo.d.ts +0 -20
  109. package/dist/minute.vo.js +0 -48
  110. package/dist/money-amount.vo.d.ts +0 -7
  111. package/dist/money-amount.vo.js +0 -5
  112. package/dist/money.vo.d.ts +0 -26
  113. package/dist/money.vo.js +0 -56
  114. package/dist/month-iso-id.vo.d.ts +0 -8
  115. package/dist/month-iso-id.vo.js +0 -14
  116. package/dist/month.vo.d.ts +0 -16
  117. package/dist/month.vo.js +0 -40
  118. package/dist/multiplication-factor.vo.d.ts +0 -7
  119. package/dist/multiplication-factor.vo.js +0 -8
  120. package/dist/noop.service.d.ts +0 -2
  121. package/dist/noop.service.js +0 -2
  122. package/dist/object-key.vo.d.ts +0 -11
  123. package/dist/object-key.vo.js +0 -19
  124. package/dist/outlier-detector.service.d.ts +0 -9
  125. package/dist/outlier-detector.service.js +0 -16
  126. package/dist/package-version-schema.vo.d.ts +0 -8
  127. package/dist/package-version-schema.vo.js +0 -10
  128. package/dist/package-version.vo.d.ts +0 -22
  129. package/dist/package-version.vo.js +0 -58
  130. package/dist/pagination-page.vo.d.ts +0 -6
  131. package/dist/pagination-page.vo.js +0 -3
  132. package/dist/pagination-skip.vo.d.ts +0 -7
  133. package/dist/pagination-skip.vo.js +0 -3
  134. package/dist/pagination-take.vo.d.ts +0 -7
  135. package/dist/pagination-take.vo.js +0 -3
  136. package/dist/pagination.service.d.ts +0 -53
  137. package/dist/pagination.service.js +0 -44
  138. package/dist/percentage.service.d.ts +0 -7
  139. package/dist/percentage.service.js +0 -9
  140. package/dist/population-standard-deviation.service.d.ts +0 -7
  141. package/dist/population-standard-deviation.service.js +0 -17
  142. package/dist/quarter-iso-id.vo.d.ts +0 -8
  143. package/dist/quarter-iso-id.vo.js +0 -7
  144. package/dist/quarter.vo.d.ts +0 -12
  145. package/dist/quarter.vo.js +0 -30
  146. package/dist/random.service.d.ts +0 -13
  147. package/dist/random.service.js +0 -13
  148. package/dist/rate-limiter.service.d.ts +0 -17
  149. package/dist/rate-limiter.service.js +0 -19
  150. package/dist/relative-date.vo.d.ts +0 -13
  151. package/dist/relative-date.vo.js +0 -14
  152. package/dist/reordering-item-position-value.vo.d.ts +0 -6
  153. package/dist/reordering-item-position-value.vo.js +0 -3
  154. package/dist/reordering.service.d.ts +0 -63
  155. package/dist/reordering.service.js +0 -135
  156. package/dist/repeat.d.ts +0 -1
  157. package/dist/repeat.js +0 -3
  158. package/dist/revision-value.vo.d.ts +0 -7
  159. package/dist/revision-value.vo.js +0 -3
  160. package/dist/revision.vo.d.ts +0 -18
  161. package/dist/revision.vo.js +0 -36
  162. package/dist/rounding-decimal.strategy.d.ts +0 -12
  163. package/dist/rounding-decimal.strategy.js +0 -14
  164. package/dist/rounding-down.strategy.d.ts +0 -4
  165. package/dist/rounding-down.strategy.js +0 -5
  166. package/dist/rounding-to-nearest.strategy.d.ts +0 -4
  167. package/dist/rounding-to-nearest.strategy.js +0 -5
  168. package/dist/rounding-up.strategy.d.ts +0 -4
  169. package/dist/rounding-up.strategy.js +0 -5
  170. package/dist/rounding.strategy.d.ts +0 -3
  171. package/dist/rounding.strategy.js +0 -1
  172. package/dist/size-bytes.vo.d.ts +0 -6
  173. package/dist/size-bytes.vo.js +0 -5
  174. package/dist/size.vo.d.ts +0 -41
  175. package/dist/size.vo.js +0 -91
  176. package/dist/slug.service.d.ts +0 -4
  177. package/dist/slug.service.js +0 -15
  178. package/dist/sms-body.vo.d.ts +0 -8
  179. package/dist/sms-body.vo.js +0 -9
  180. package/dist/sms-message.vo.d.ts +0 -13
  181. package/dist/sms-message.vo.js +0 -13
  182. package/dist/sum.service.d.ts +0 -4
  183. package/dist/sum.service.js +0 -16
  184. package/dist/telephone-number.vo.d.ts +0 -7
  185. package/dist/telephone-number.vo.js +0 -10
  186. package/dist/thousands-separator.service.d.ts +0 -4
  187. package/dist/thousands-separator.service.js +0 -9
  188. package/dist/time-zone-offset-value.vo.d.ts +0 -8
  189. package/dist/time-zone-offset-value.vo.js +0 -13
  190. package/dist/timestamp-value.vo.d.ts +0 -6
  191. package/dist/timestamp-value.vo.js +0 -5
  192. package/dist/timestamp.vo.d.ts +0 -21
  193. package/dist/timestamp.vo.js +0 -54
  194. package/dist/timezone.vo.d.ts +0 -9
  195. package/dist/timezone.vo.js +0 -20
  196. package/dist/ts-utils.d.ts +0 -3
  197. package/dist/ts-utils.js +0 -1
  198. package/dist/tsconfig.tsbuildinfo +0 -1
  199. package/dist/url-with-slash.vo.d.ts +0 -6
  200. package/dist/url-with-slash.vo.js +0 -5
  201. package/dist/url-without-slash.vo.d.ts +0 -6
  202. package/dist/url-without-slash.vo.js +0 -5
  203. package/dist/visually-unambiguous-characters-generator.service.d.ts +0 -4
  204. package/dist/visually-unambiguous-characters-generator.service.js +0 -32
  205. package/dist/week-iso-id.vo.d.ts +0 -8
  206. package/dist/week-iso-id.vo.js +0 -19
  207. package/dist/week.vo.d.ts +0 -16
  208. package/dist/week.vo.js +0 -45
  209. package/dist/weekday-iso-id.vo.d.ts +0 -7
  210. package/dist/weekday-iso-id.vo.js +0 -5
  211. package/dist/weekday.vo.d.ts +0 -28
  212. package/dist/weekday.vo.js +0 -60
  213. package/dist/weight-grams.vo.d.ts +0 -7
  214. package/dist/weight-grams.vo.js +0 -5
  215. package/dist/weight.vo.d.ts +0 -25
  216. package/dist/weight.vo.js +0 -65
  217. package/dist/year-iso-id.vo.d.ts +0 -7
  218. package/dist/year-iso-id.vo.js +0 -7
  219. package/dist/year.vo.d.ts +0 -18
  220. package/dist/year.vo.js +0 -50
  221. package/dist/z-score.service.d.ts +0 -11
  222. package/dist/z-score.service.js +0 -19
package/dist/int.vo.js DELETED
@@ -1,15 +0,0 @@
1
- import * as v from "valibot";
2
- import { Integer } from "./integer.vo";
3
- import { IntegerNonNegative } from "./integer-non-negative.vo";
4
- import { IntegerPositive } from "./integer-positive.vo";
5
- export class Int {
6
- static positive(candidate) {
7
- return v.parse(IntegerPositive, candidate);
8
- }
9
- static nonNegative(candidate) {
10
- return v.parse(IntegerNonNegative, candidate);
11
- }
12
- static of(candidate) {
13
- return v.parse(Integer, candidate);
14
- }
15
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const IntegerNonNegativeError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const IntegerNonNegative: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "IntegerNonNegative">]>;
7
- export type IntegerNonNegativeType = v.InferOutput<typeof IntegerNonNegative>;
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export const IntegerNonNegativeError = {
3
- Type: "integer.non.negative.type",
4
- Invalid: "integer.non.negative.invalid",
5
- };
6
- export const IntegerNonNegative = v.pipe(v.number(IntegerNonNegativeError.Type), v.integer(IntegerNonNegativeError.Type), v.minValue(0, IntegerNonNegativeError.Invalid),
7
- // Stryker disable next-line StringLiteral
8
- v.brand("IntegerNonNegative"));
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const IntegerPositiveError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const IntegerPositive: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.BrandAction<number, "IntegerPositive">]>;
7
- export type IntegerPositiveType = v.InferOutput<typeof IntegerPositive>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
3
- export const IntegerPositive = v.pipe(v.number(IntegerPositiveError.Type), v.integer(IntegerPositiveError.Type), v.minValue(1, IntegerPositiveError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("IntegerPositive"));
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const IntegerError: {
3
- Type: string;
4
- };
5
- export declare const Integer: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.BrandAction<number, "Integer">]>;
6
- export type IntegerType = v.InferOutput<typeof Integer>;
@@ -1,4 +0,0 @@
1
- import * as v from "valibot";
2
- export const IntegerError = { Type: "integer.type" };
3
- // Stryker disable next-line StringLiteral
4
- export const Integer = v.pipe(v.number(IntegerError.Type), v.integer(IntegerError.Type), v.brand("Integer"));
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const LanguageError: {
3
- Type: string;
4
- BadChars: string;
5
- };
6
- export declare const Language: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>]>;
7
- export type LanguageType = v.InferOutput<typeof Language>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const LanguageError = { Type: "language.type", BadChars: "language.bad.chars" };
3
- // Two lowercase letters
4
- const LANGUAGE_CHARS_WHITELIST = /^[a-z]{2}$/;
5
- export const Language = v.pipe(v.string(LanguageError.Type), v.regex(LANGUAGE_CHARS_WHITELIST, LanguageError.BadChars));
@@ -1,27 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export type LinearRegressionPairType = {
3
- x: number;
4
- y: number;
5
- };
6
- export type LinearRegressionParamsType = {
7
- a: number;
8
- b: number;
9
- };
10
- export type LinearRegressionPredictionType = number;
11
- export declare const LinearRegressionError: {
12
- MinPairs: string;
13
- SumXTooBig: string;
14
- SumYTooBig: string;
15
- SumXSquaredTooBig: string;
16
- SumXTimesYTooBig: string;
17
- ModelCreation: string;
18
- };
19
- export declare class LinearRegression {
20
- private static readonly DEFAULT_ROUNDING;
21
- private readonly params;
22
- private readonly rounding;
23
- constructor(params: LinearRegressionParamsType, rounding?: RoundingStrategy);
24
- static fromPairs(pairs: ReadonlyArray<LinearRegressionPairType>, rounding?: RoundingStrategy): LinearRegression;
25
- predict(x: LinearRegressionPairType["x"], rounding?: RoundingStrategy): LinearRegressionPredictionType;
26
- inspect(): LinearRegression["params"];
27
- }
@@ -1,58 +0,0 @@
1
- import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
2
- export const LinearRegressionError = {
3
- MinPairs: "linear.regression.min.pairs",
4
- SumXTooBig: "linear.regression.sum.x.too.big",
5
- SumYTooBig: "linear.regression.sum.y.too.big",
6
- SumXSquaredTooBig: "linear.regression.sum.x.squared.too.big",
7
- SumXTimesYTooBig: "linear.regression.sum.x.times.y.too.big",
8
- ModelCreation: "linear.regression.model.creation",
9
- };
10
- export class LinearRegression {
11
- static DEFAULT_ROUNDING = new RoundingToNearestStrategy();
12
- params;
13
- rounding;
14
- constructor(params, rounding) {
15
- this.params = params;
16
- this.rounding = rounding ?? LinearRegression.DEFAULT_ROUNDING;
17
- }
18
- static fromPairs(pairs, rounding) {
19
- const count = pairs.length;
20
- if (count < 2)
21
- throw new Error(LinearRegressionError.MinPairs);
22
- let sumX = 0;
23
- let sumY = 0;
24
- let sumXX = 0;
25
- let sumXY = 0;
26
- for (let index = 0; index < count; index++) {
27
- const pair = pairs[index];
28
- sumX += pair.x;
29
- sumY += pair.y;
30
- sumXX += pair.x * pair.x;
31
- sumXY += pair.x * pair.y;
32
- }
33
- if (Math.abs(sumX) >= Number.MAX_SAFE_INTEGER)
34
- throw new Error(LinearRegressionError.SumXTooBig);
35
- if (Math.abs(sumY) >= Number.MAX_SAFE_INTEGER)
36
- throw new Error(LinearRegressionError.SumYTooBig);
37
- // Stryker disable all
38
- if (Math.abs(sumXY) >= Number.MAX_SAFE_INTEGER)
39
- throw new Error(LinearRegressionError.SumXTimesYTooBig);
40
- if (Math.abs(sumXX) >= Number.MAX_SAFE_INTEGER)
41
- throw new Error(LinearRegressionError.SumXSquaredTooBig);
42
- // Stryker restore all
43
- const bDenominator = sumXX - sumX ** 2 / count;
44
- if (bDenominator === 0)
45
- throw new Error(LinearRegressionError.ModelCreation);
46
- const b = (sumXY - (sumX * sumY) / count) / bDenominator;
47
- const a = (sumY - b * sumX) / count;
48
- return new LinearRegression({ a, b }, rounding);
49
- }
50
- predict(x, rounding) {
51
- const chosen = rounding ?? this.rounding;
52
- const prediction = this.params.b * x + this.params.a;
53
- return chosen.round(prediction);
54
- }
55
- inspect() {
56
- return this.params;
57
- }
58
- }
@@ -1,8 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare const MeanError: {
3
- NotEnoughValues: string;
4
- };
5
- export declare class Mean {
6
- private static readonly DEFAULT_ROUNDING;
7
- static calculate(values: ReadonlyArray<number>, rounding?: RoundingStrategy): number;
8
- }
@@ -1,13 +0,0 @@
1
- import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
2
- import { Sum } from "./sum.service";
3
- export const MeanError = { NotEnoughValues: "mean.not.enough.values" };
4
- export class Mean {
5
- static DEFAULT_ROUNDING = new RoundingDecimalStrategy(2);
6
- static calculate(values, rounding) {
7
- if (values.length === 0)
8
- throw new Error(MeanError.NotEnoughValues);
9
- const sum = Sum.of(values);
10
- const mean = sum / values.length;
11
- return (rounding ?? Mean.DEFAULT_ROUNDING).round(mean);
12
- }
13
- }
@@ -1,7 +0,0 @@
1
- import type { ExtensionType } from "./extension.vo";
2
- import type { Mime } from "./mime.vo";
3
- export declare class MimeRegistryEntry {
4
- readonly mime: Mime;
5
- readonly extensions: ReadonlyArray<ExtensionType>;
6
- constructor(mime: Mime, extensions: ReadonlyArray<ExtensionType>);
7
- }
@@ -1,8 +0,0 @@
1
- export class MimeRegistryEntry {
2
- mime;
3
- extensions;
4
- constructor(mime, extensions) {
5
- this.mime = mime;
6
- this.extensions = extensions;
7
- }
8
- }
@@ -1,16 +0,0 @@
1
- import type { ExtensionType } from "./extension.vo";
2
- import type { Mime } from "./mime.vo";
3
- import type { MimeRegistryEntry } from "./mime-registry-entry.vo";
4
- export declare const MimeRegistryError: {
5
- ExtensionNotFound: string;
6
- MimeNotFound: string;
7
- };
8
- export declare class MimeRegistry {
9
- private readonly byExtension;
10
- private readonly byMime;
11
- constructor(entries: ReadonlyArray<MimeRegistryEntry>);
12
- hasExtension(extension: ExtensionType): boolean;
13
- hasMime(mime: Mime): boolean;
14
- fromExtension(extension: ExtensionType): Mime | undefined;
15
- toExtension(mime: Mime): ExtensionType | undefined;
16
- }
@@ -1,31 +0,0 @@
1
- // Stryker disable all
2
- export const MimeRegistryError = {
3
- ExtensionNotFound: "mime.registry.extension.not.found",
4
- MimeNotFound: "mime.registry.mime.not.found",
5
- };
6
- // Stryker restore all
7
- export class MimeRegistry {
8
- byExtension = new Map();
9
- byMime = new Map();
10
- constructor(entries) {
11
- for (const entry of entries) {
12
- for (const extension of entry.extensions) {
13
- this.byExtension.set(extension, entry.mime);
14
- }
15
- const canonical = entry.extensions[0];
16
- this.byMime.set(entry.mime.toString(), canonical);
17
- }
18
- }
19
- hasExtension(extension) {
20
- return this.byExtension.has(extension);
21
- }
22
- hasMime(mime) {
23
- return this.byMime.has(mime.toString());
24
- }
25
- fromExtension(extension) {
26
- return this.byExtension.get(extension);
27
- }
28
- toExtension(mime) {
29
- return this.byMime.get(mime.toString());
30
- }
31
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const MimeValueError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const MimeValue: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "MimeValue">]>;
7
- export type MimeValueType = v.InferOutput<typeof MimeValue>;
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export const MimeValueError = { Type: "mime.value.type", Invalid: "mime.value.invalid" };
3
- // One to twenty four lowercase letters, asterisk or hyphen, forward slash, one to seventy two lowercase letters, digits, asterisk, hyphen, plus, dot or underscore
4
- const MIME_VALUE_CHARS_WHITELIST = /^[a-z*-]{1,24}\/[a-z0-9*+-_.]{1,72}$/;
5
- export const MimeValue = v.pipe(v.string(MimeValueError.Type), v.regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid),
6
- // Stryker disable next-line StringLiteral
7
- v.brand("MimeValue"));
package/dist/mime.vo.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare class Mime {
2
- readonly type: string;
3
- readonly subtype: string;
4
- private constructor();
5
- static fromString(candidate: string): Mime;
6
- isSatisfiedBy(another: Mime): boolean;
7
- toString(): string;
8
- toJSON(): {
9
- type: string;
10
- subtype: string;
11
- };
12
- }
package/dist/mime.vo.js DELETED
@@ -1,26 +0,0 @@
1
- import * as v from "valibot";
2
- import { MimeValue } from "./mime-value.vo";
3
- export class Mime {
4
- type;
5
- subtype;
6
- constructor(type, subtype) {
7
- this.type = type;
8
- this.subtype = subtype;
9
- }
10
- static fromString(candidate) {
11
- const value = v.parse(MimeValue, candidate.split(";")[0].trim());
12
- const [type, subtype] = value.split("/");
13
- return new Mime(type, subtype);
14
- }
15
- isSatisfiedBy(another) {
16
- if (!(this.type === another.type || this.type === "*"))
17
- return false;
18
- return this.subtype === another.subtype || this.subtype === "*";
19
- }
20
- toString() {
21
- return `${this.type}/${this.subtype}`;
22
- }
23
- toJSON() {
24
- return { type: this.type, subtype: this.subtype };
25
- }
26
- }
package/dist/mimes.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { MimeRegistryEntry } from "./mime-registry-entry.vo";
2
- export declare const Mimes: {
3
- readonly csv: MimeRegistryEntry;
4
- readonly jpg: MimeRegistryEntry;
5
- readonly markdown: MimeRegistryEntry;
6
- readonly mp4: MimeRegistryEntry;
7
- readonly pdf: MimeRegistryEntry;
8
- readonly png: MimeRegistryEntry;
9
- readonly text: MimeRegistryEntry;
10
- readonly webp: MimeRegistryEntry;
11
- readonly wav: MimeRegistryEntry;
12
- readonly zip: MimeRegistryEntry;
13
- };
package/dist/mimes.js DELETED
@@ -1,19 +0,0 @@
1
- import * as v from "valibot";
2
- import { Extension } from "./extension.vo";
3
- import { Mime } from "./mime.vo";
4
- import { MimeRegistryEntry } from "./mime-registry-entry.vo";
5
- export const Mimes = {
6
- csv: new MimeRegistryEntry(Mime.fromString("text/csv"), [v.parse(Extension, "csv")]),
7
- jpg: new MimeRegistryEntry(Mime.fromString("image/jpeg"), [
8
- v.parse(Extension, "jpg"),
9
- v.parse(Extension, "jpeg"),
10
- ]),
11
- markdown: new MimeRegistryEntry(Mime.fromString("text/markdown"), [v.parse(Extension, "md")]),
12
- mp4: new MimeRegistryEntry(Mime.fromString("video/mp4"), [v.parse(Extension, "mp4")]),
13
- pdf: new MimeRegistryEntry(Mime.fromString("application/pdf"), [v.parse(Extension, "pdf")]),
14
- png: new MimeRegistryEntry(Mime.fromString("image/png"), [v.parse(Extension, "png")]),
15
- text: new MimeRegistryEntry(Mime.fromString("text/plain"), [v.parse(Extension, "txt")]),
16
- webp: new MimeRegistryEntry(Mime.fromString("image/webp"), [v.parse(Extension, "webp")]),
17
- wav: new MimeRegistryEntry(Mime.fromString("audio/wav"), [v.parse(Extension, "wav")]),
18
- zip: new MimeRegistryEntry(Mime.fromString("application/zip"), [v.parse(Extension, "zip")]),
19
- };
@@ -1,46 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- type MinMaxScalerValueType = number;
3
- type MinMaxScalerConfigType = {
4
- min: MinMaxScalerValueType;
5
- max: MinMaxScalerValueType;
6
- bound?: {
7
- lower: MinMaxScalerValueType;
8
- upper: MinMaxScalerValueType;
9
- };
10
- rounding?: RoundingStrategy;
11
- };
12
- type ScaleResult = {
13
- original: MinMaxScalerValueType;
14
- scaled: MinMaxScalerValueType;
15
- isMin: boolean;
16
- isMax: boolean;
17
- };
18
- type DescaleResult = {
19
- original: MinMaxScalerValueType;
20
- scaled: MinMaxScalerValueType;
21
- isLowerBound: boolean;
22
- isUpperBound: boolean;
23
- };
24
- export declare const MinMaxScalerError: {
25
- InvalidMinMax: string;
26
- InvalidBound: string;
27
- ValueOutOfRange: string;
28
- ScaledOutOfBounds: string;
29
- EmptyArray: string;
30
- };
31
- export declare class MinMaxScaler {
32
- private static readonly DEFAULT_ROUNDING;
33
- private readonly min;
34
- private readonly max;
35
- private readonly lower;
36
- private readonly upper;
37
- private readonly rounding;
38
- constructor(config: MinMaxScalerConfigType);
39
- scale(value: MinMaxScalerValueType): ScaleResult;
40
- descale(scaled: MinMaxScalerValueType): DescaleResult;
41
- static getMinMax(values: ReadonlyArray<MinMaxScalerValueType>): {
42
- min: number;
43
- max: number;
44
- };
45
- }
46
- export {};
@@ -1,61 +0,0 @@
1
- import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
2
- export const MinMaxScalerError = {
3
- InvalidMinMax: "min.max.scaler.invalid.min.max",
4
- InvalidBound: "min.max.scaler.invalid.bound",
5
- ValueOutOfRange: "min.max.scaler.value.out.of.range",
6
- ScaledOutOfBounds: "min.max.scaler.scaled.out.of.bounds",
7
- EmptyArray: "min.max.scaler.empty.array",
8
- };
9
- export class MinMaxScaler {
10
- static DEFAULT_ROUNDING = new RoundingDecimalStrategy(2);
11
- min;
12
- max;
13
- lower;
14
- upper;
15
- rounding;
16
- constructor(config) {
17
- const lower = config.bound?.lower ?? 0;
18
- const upper = config.bound?.upper ?? 1;
19
- if (config.max - config.min < 0)
20
- throw new Error(MinMaxScalerError.InvalidMinMax);
21
- if (upper - lower <= 0)
22
- throw new Error(MinMaxScalerError.InvalidBound);
23
- this.rounding = config.rounding ?? MinMaxScaler.DEFAULT_ROUNDING;
24
- this.min = config.min;
25
- this.max = config.max;
26
- this.lower = lower;
27
- this.upper = upper;
28
- }
29
- scale(value) {
30
- const { min, max, lower, upper } = this;
31
- if (value < min || value > max)
32
- throw new Error(MinMaxScalerError.ValueOutOfRange);
33
- if (min === max) {
34
- return { original: value, scaled: (lower + upper) / 2, isMin: true, isMax: true };
35
- }
36
- const result = ((value - min) / (max - min)) * (upper - lower) + lower;
37
- return {
38
- original: value,
39
- scaled: this.rounding.round(result),
40
- isMin: value === min,
41
- isMax: value === max,
42
- };
43
- }
44
- descale(scaled) {
45
- const { min, max, lower, upper } = this;
46
- if (scaled < lower || scaled > upper)
47
- throw new Error(MinMaxScalerError.ScaledOutOfBounds);
48
- const result = ((scaled - lower) / (upper - lower)) * (max - min) + min;
49
- return {
50
- original: this.rounding.round(result),
51
- scaled,
52
- isLowerBound: scaled === lower,
53
- isUpperBound: scaled === upper,
54
- };
55
- }
56
- static getMinMax(values) {
57
- if (values.length === 0)
58
- throw new Error(MinMaxScalerError.EmptyArray);
59
- return { min: Math.min(...values), max: Math.max(...values) };
60
- }
61
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const MinuteValueError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const MinuteValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.MaxValueAction<number, 59, string>, v.BrandAction<number, "MinuteValue">]>;
7
- export type MinuteValueType = v.InferOutput<typeof MinuteValue>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const MinuteValueError = { Type: "minute.value.type", Invalid: "minute.value.invalid" };
3
- export const MinuteValue = v.pipe(v.number(MinuteValueError.Type), v.integer(MinuteValueError.Type), v.minValue(0, MinuteValueError.Invalid), v.maxValue(59, MinuteValueError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("MinuteValue"));
@@ -1,20 +0,0 @@
1
- import { type MinuteValueType } from "./minute-value.vo";
2
- import { Timestamp } from "./timestamp.vo";
3
- import type { TimestampValueType } from "./timestamp-value.vo";
4
- export declare class Minute {
5
- private readonly value;
6
- private constructor();
7
- static fromValue(candidate: number): Minute;
8
- static fromValueSafe(candidate: MinuteValueType): Minute;
9
- static fromTimestamp(timestamp: Timestamp): Minute;
10
- static fromTimestampValue(timestamp: TimestampValueType): Minute;
11
- static zero(): Minute;
12
- static max(): Minute;
13
- get(): MinuteValueType;
14
- equals(another: Minute): boolean;
15
- isBefore(another: Minute): boolean;
16
- isAfter(another: Minute): boolean;
17
- static list(): ReadonlyArray<Minute>;
18
- toString(): string;
19
- toJSON(): number;
20
- }
package/dist/minute.vo.js DELETED
@@ -1,48 +0,0 @@
1
- import * as v from "valibot";
2
- import { MinuteValue } from "./minute-value.vo";
3
- import { Timestamp } from "./timestamp.vo";
4
- export class Minute {
5
- value;
6
- constructor(value) {
7
- this.value = value;
8
- }
9
- static fromValue(candidate) {
10
- return new Minute(v.parse(MinuteValue, candidate));
11
- }
12
- static fromValueSafe(candidate) {
13
- return new Minute(candidate);
14
- }
15
- static fromTimestamp(timestamp) {
16
- return new Minute(v.parse(MinuteValue, new Date(timestamp.ms).getUTCMinutes()));
17
- }
18
- static fromTimestampValue(timestamp) {
19
- return Minute.fromTimestamp(Timestamp.fromValue(timestamp));
20
- }
21
- static zero() {
22
- return Minute.fromValue(0);
23
- }
24
- static max() {
25
- return Minute.fromValue(59);
26
- }
27
- get() {
28
- return this.value;
29
- }
30
- equals(another) {
31
- return this.value === another.value;
32
- }
33
- isBefore(another) {
34
- return this.value < another.value;
35
- }
36
- isAfter(another) {
37
- return this.value > another.value;
38
- }
39
- static list() {
40
- return Array.from({ length: 60 }, (_, index) => Minute.fromValue(index));
41
- }
42
- toString() {
43
- return this.value.toString().padStart(2, "0");
44
- }
45
- toJSON() {
46
- return this.value;
47
- }
48
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const MoneyAmountError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const MoneyAmount: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "MoneyAmount">]>;
7
- export type MoneyAmountType = v.InferOutput<typeof MoneyAmount>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const MoneyAmountError = { Type: "money.amount.type", Invalid: "money.amount.invalid" };
3
- export const MoneyAmount = v.pipe(v.number(MoneyAmountError.Type), v.integer(MoneyAmountError.Type), v.minValue(0, MoneyAmountError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("MoneyAmount"));
@@ -1,26 +0,0 @@
1
- import type { DivisionFactorType } from "./division-factor.vo";
2
- import { type MoneyAmountType } from "./money-amount.vo";
3
- import type { MultiplicationFactorType } from "./multiplication-factor.vo";
4
- import type { RoundingStrategy } from "./rounding.strategy";
5
- export declare const MoneyError: {
6
- SubtractResultLessThanZero: string;
7
- };
8
- export declare class Money {
9
- private readonly amount;
10
- private static readonly ZERO;
11
- private constructor();
12
- static fromAmount(candidate: number): Money;
13
- static fromAmountSafe(candidate: MoneyAmountType): Money;
14
- static zero(): Money;
15
- getAmount(): MoneyAmountType;
16
- add(money: Money): Money;
17
- multiply(factor: MultiplicationFactorType, rounding?: RoundingStrategy): Money;
18
- subtract(money: Money): Money;
19
- divide(factor: DivisionFactorType, rounding?: RoundingStrategy): Money;
20
- equals(another: Money): boolean;
21
- isGreaterThan(another: Money): boolean;
22
- isLessThan(another: Money): boolean;
23
- isZero(): boolean;
24
- toString(): string;
25
- toJSON(): number;
26
- }
package/dist/money.vo.js DELETED
@@ -1,56 +0,0 @@
1
- import * as v from "valibot";
2
- import { MoneyAmount } from "./money-amount.vo";
3
- import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
4
- export const MoneyError = { SubtractResultLessThanZero: "money.subtract.result.less.than.zero" };
5
- export class Money {
6
- amount;
7
- static ZERO = v.parse(MoneyAmount, 0);
8
- constructor(amount) {
9
- this.amount = amount;
10
- }
11
- static fromAmount(candidate) {
12
- return new Money(v.parse(MoneyAmount, candidate));
13
- }
14
- static fromAmountSafe(candidate) {
15
- return new Money(candidate);
16
- }
17
- static zero() {
18
- return Money.fromAmount(0);
19
- }
20
- getAmount() {
21
- return this.amount;
22
- }
23
- add(money) {
24
- return new Money(v.parse(MoneyAmount, this.amount + money.getAmount()));
25
- }
26
- multiply(factor, rounding = new RoundingToNearestStrategy()) {
27
- return new Money(v.parse(MoneyAmount, rounding.round(this.amount * factor)));
28
- }
29
- subtract(money) {
30
- const result = this.amount - money.getAmount();
31
- if (result < Money.ZERO)
32
- throw new Error(MoneyError.SubtractResultLessThanZero);
33
- return new Money(v.parse(MoneyAmount, result));
34
- }
35
- divide(factor, rounding = new RoundingToNearestStrategy()) {
36
- return new Money(v.parse(MoneyAmount, rounding.round(this.amount / factor)));
37
- }
38
- equals(another) {
39
- return this.amount === another.getAmount();
40
- }
41
- isGreaterThan(another) {
42
- return this.amount > another.getAmount();
43
- }
44
- isLessThan(another) {
45
- return this.amount < another.getAmount();
46
- }
47
- isZero() {
48
- return this.amount === Money.ZERO;
49
- }
50
- toString() {
51
- return this.amount.toString();
52
- }
53
- toJSON() {
54
- return this.amount;
55
- }
56
- }
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const MonthIsoIdError: {
3
- Type: string;
4
- BadChars: string;
5
- Invalid: string;
6
- };
7
- export declare const MonthIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "MonthIsoId">]>;
8
- export type MonthIsoIdType = v.InferOutput<typeof MonthIsoId>;