@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
@@ -1,14 +0,0 @@
1
- import * as v from "valibot";
2
- export const MonthIsoIdError = {
3
- Type: "month.iso.id.type",
4
- BadChars: "month.iso.id.bad.chars",
5
- Invalid: "month.iso.id.invalid",
6
- };
7
- // Four digits, hyphen, two digits
8
- const MONTH_ISO_ID_CHARS_WHITELIST = /^\d{4}-\d{2}$/;
9
- export const MonthIsoId = v.pipe(v.string(MonthIsoIdError.Type), v.regex(MONTH_ISO_ID_CHARS_WHITELIST, MonthIsoIdError.BadChars), v.check((value) => {
10
- const month = value.split("-").map(Number)[1];
11
- return month >= 1 && month <= 12;
12
- }, MonthIsoIdError.Invalid),
13
- // Stryker disable next-line StringLiteral
14
- v.brand("MonthIsoId"));
@@ -1,16 +0,0 @@
1
- import { DateRange } from "./date-range.vo";
2
- import type { IntegerType } from "./integer.vo";
3
- import { type MonthIsoIdType } from "./month-iso-id.vo";
4
- import { Timestamp } from "./timestamp.vo";
5
- import type { TimestampValueType } from "./timestamp-value.vo";
6
- export declare class Month extends DateRange {
7
- static fromTimestamp(timestamp: Timestamp): Month;
8
- static fromTimestampValue(timestamp: TimestampValueType): Month;
9
- static fromNow(now: Timestamp): Month;
10
- static fromIsoId(iso: MonthIsoIdType): Month;
11
- toIsoId(): MonthIsoIdType;
12
- previous(): Month;
13
- next(): Month;
14
- shift(count: IntegerType): Month;
15
- toString(): string;
16
- }
package/dist/month.vo.js DELETED
@@ -1,40 +0,0 @@
1
- import { endOfMonth, format, startOfMonth } from "date-fns";
2
- import * as v from "valibot";
3
- import { DateRange } from "./date-range.vo";
4
- import { Int } from "./int.vo";
5
- import { MonthIsoId } from "./month-iso-id.vo";
6
- import { Timestamp } from "./timestamp.vo";
7
- export class Month extends DateRange {
8
- static fromTimestamp(timestamp) {
9
- const start = Timestamp.fromNumber(startOfMonth(timestamp.ms).getTime());
10
- const end = Timestamp.fromNumber(endOfMonth(timestamp.ms).getTime());
11
- return new Month(start, end);
12
- }
13
- static fromTimestampValue(timestamp) {
14
- return Month.fromTimestamp(Timestamp.fromValue(timestamp));
15
- }
16
- static fromNow(now) {
17
- return Month.fromTimestamp(now);
18
- }
19
- static fromIsoId(iso) {
20
- const [year, month] = v.parse(MonthIsoId, iso).split("-").map(Number);
21
- const reference = Timestamp.fromNumber(Date.UTC(year, month - 1, 1));
22
- return Month.fromTimestamp(reference);
23
- }
24
- toIsoId() {
25
- return v.parse(MonthIsoId, format(this.getStart().ms, "yyyy-MM"));
26
- }
27
- previous() {
28
- return this.shift(Int.of(-1));
29
- }
30
- next() {
31
- return this.shift(Int.of(1));
32
- }
33
- shift(count) {
34
- const start = new Date(this.getStart().ms);
35
- return Month.fromTimestamp(Timestamp.fromNumber(Date.UTC(start.getUTCFullYear(), start.getUTCMonth() + count, 1)));
36
- }
37
- toString() {
38
- return this.toIsoId();
39
- }
40
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const MultiplicationFactorError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const MultiplicationFactor: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "MultiplicationFactor">]>;
7
- export type MultiplicationFactorType = v.InferOutput<typeof MultiplicationFactor>;
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export const MultiplicationFactorError = {
3
- Type: "multiplication.factor.type",
4
- Invalid: "multiplication.factor.invalid",
5
- };
6
- export const MultiplicationFactor = v.pipe(v.number(MultiplicationFactorError.Type), v.minValue(0, MultiplicationFactorError.Invalid),
7
- // Stryker disable next-line StringLiteral
8
- v.brand("MultiplicationFactor"));
@@ -1,2 +0,0 @@
1
- export declare function noop(): void;
2
- export declare function anoop(): Promise<void>;
@@ -1,2 +0,0 @@
1
- export function noop() { }
2
- export async function anoop() { }
@@ -1,11 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const ObjectKeyError: {
3
- Type: string;
4
- LeadingSlash: string;
5
- Empty: string;
6
- TooLong: string;
7
- BadChars: string;
8
- DotSegments: string;
9
- };
10
- export declare const ObjectKey: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 256, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "ObjectKey">]>;
11
- export type ObjectKeyType = v.InferOutput<typeof ObjectKey>;
@@ -1,19 +0,0 @@
1
- import * as v from "valibot";
2
- export const ObjectKeyError = {
3
- Type: "object.key.type",
4
- LeadingSlash: "object.key.leading.slash",
5
- Empty: "object.key.empty",
6
- TooLong: "object.key.too.long",
7
- BadChars: "object.key.bad.chars",
8
- DotSegments: "object.key.dot.segments",
9
- };
10
- // Lowercase letters, digits, dots, underscores, and hyphens
11
- const OBJECT_KEY_SEGMENT_CHARS_WHITELIST = /^[a-z0-9._-]+$/;
12
- const DOT_SEGMENTS = [".", ".."];
13
- export const ObjectKey = v.pipe(v.string(ObjectKeyError.Type), v.minLength(1, ObjectKeyError.Empty), v.maxLength(256, ObjectKeyError.TooLong), v.check((value) => !value.startsWith("/"), ObjectKeyError.LeadingSlash),
14
- // Allow only known characters for users/avatars/1234567890/avatar.png segments
15
- v.check((value) => value.split("/").every((segment) => OBJECT_KEY_SEGMENT_CHARS_WHITELIST.test(segment)), ObjectKeyError.BadChars),
16
- // Reject object keys like users/./avatar.png or users/../avatar.png
17
- v.check((value) => value.split("/").every((segment) => !DOT_SEGMENTS.includes(segment)), ObjectKeyError.DotSegments),
18
- // Stryker disable next-line StringLiteral
19
- v.brand("ObjectKey"));
@@ -1,9 +0,0 @@
1
- export declare const OutlierDetectorError: {
2
- NotEnoughValues: string;
3
- };
4
- export declare class OutlierDetector {
5
- private readonly zScore;
6
- private readonly threshold;
7
- constructor(values: ReadonlyArray<number>, threshold: number);
8
- isInlier(value: number): boolean;
9
- }
@@ -1,16 +0,0 @@
1
- import { ZScore } from "./z-score.service";
2
- export const OutlierDetectorError = { NotEnoughValues: "outlier.detector.not.enough.values" };
3
- export class OutlierDetector {
4
- zScore;
5
- threshold;
6
- constructor(values, threshold) {
7
- if (values.length < 2)
8
- throw new Error(OutlierDetectorError.NotEnoughValues);
9
- this.zScore = new ZScore(values);
10
- this.threshold = Math.abs(threshold);
11
- }
12
- isInlier(value) {
13
- const score = this.zScore.calculate(value);
14
- return Math.abs(score) <= this.threshold;
15
- }
16
- }
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const PackageVersionSchemaError: {
3
- Type: string;
4
- BadChars: string;
5
- };
6
- export declare const PACKAGE_VERSIONS_CHARS_WHITELIST: RegExp;
7
- export declare const PackageVersionSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "PackageVersionSchema">]>;
8
- export type PackageVersionSchemaType = v.InferOutput<typeof PackageVersionSchema>;
@@ -1,10 +0,0 @@
1
- import * as v from "valibot";
2
- export const PackageVersionSchemaError = {
3
- Type: "package.version.schema.error",
4
- BadChars: "package.version.schema.bad.chars",
5
- };
6
- // v, 1-4 digits, dot, 1-4 digits, dot, 1-4 digits - () for capturing groups
7
- export const PACKAGE_VERSIONS_CHARS_WHITELIST = /^v([0-9]{1,4})\.([0-9]{1,4})\.([0-9]{1,4})$/;
8
- export const PackageVersionSchema = v.pipe(v.string(PackageVersionSchemaError.Type), v.regex(PACKAGE_VERSIONS_CHARS_WHITELIST, PackageVersionSchemaError.BadChars),
9
- // Stryker disable next-line StringLiteral
10
- v.brand("PackageVersionSchema"));
@@ -1,22 +0,0 @@
1
- import { type PackageVersionSchemaType } from "./package-version-schema.vo";
2
- export declare class PackageVersion {
3
- private readonly major;
4
- private readonly minor;
5
- private readonly patch;
6
- private constructor();
7
- static fromVersionString(candidate: string): PackageVersion;
8
- static fromVersionStringSafe(candidate: PackageVersionSchemaType): PackageVersion;
9
- static fromString(candidate: string): PackageVersion;
10
- private compareTo;
11
- equals(another: PackageVersion): boolean;
12
- isGreaterThan(another: PackageVersion): boolean;
13
- isGreaterThanOrEqual(another: PackageVersion): boolean;
14
- isSmallerThan(another: PackageVersion): boolean;
15
- isSmallerThanOrEqual(another: PackageVersion): boolean;
16
- toString(): string;
17
- toJSON(): {
18
- major: number;
19
- minor: number;
20
- patch: number;
21
- };
22
- }
@@ -1,58 +0,0 @@
1
- import * as v from "valibot";
2
- import { PACKAGE_VERSIONS_CHARS_WHITELIST, PackageVersionSchema, } from "./package-version-schema.vo";
3
- export class PackageVersion {
4
- major;
5
- minor;
6
- patch;
7
- constructor(major, minor, patch) {
8
- this.major = major;
9
- this.minor = minor;
10
- this.patch = patch;
11
- }
12
- static fromVersionString(candidate) {
13
- return PackageVersion.fromVersionStringSafe(v.parse(PackageVersionSchema, candidate));
14
- }
15
- static fromVersionStringSafe(candidate) {
16
- const [, major, minor, patch] = PACKAGE_VERSIONS_CHARS_WHITELIST.exec(candidate).map(Number);
17
- return new PackageVersion(major, minor, patch);
18
- }
19
- static fromString(candidate) {
20
- return PackageVersion.fromVersionStringSafe(v.parse(PackageVersionSchema, `v${candidate}`));
21
- }
22
- compareTo(another) {
23
- if (this.major > another.major)
24
- return 1;
25
- if (this.major < another.major)
26
- return -1;
27
- if (this.minor > another.minor)
28
- return 1;
29
- if (this.minor < another.minor)
30
- return -1;
31
- if (this.patch > another.patch)
32
- return 1;
33
- if (this.patch < another.patch)
34
- return -1;
35
- return 0;
36
- }
37
- equals(another) {
38
- return this.compareTo(another) === 0;
39
- }
40
- isGreaterThan(another) {
41
- return this.compareTo(another) === 1;
42
- }
43
- isGreaterThanOrEqual(another) {
44
- return this.compareTo(another) !== -1;
45
- }
46
- isSmallerThan(another) {
47
- return this.compareTo(another) === -1;
48
- }
49
- isSmallerThanOrEqual(another) {
50
- return this.compareTo(another) !== 1;
51
- }
52
- toString() {
53
- return `${this.major}.${this.minor}.${this.patch}`;
54
- }
55
- toJSON() {
56
- return { major: this.major, minor: this.minor, patch: this.patch };
57
- }
58
- }
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const PaginationPageError: {
3
- Type: string;
4
- };
5
- export declare const Page: v.SchemaWithPipe<readonly [v.UnknownSchema, v.TransformAction<unknown, number>, v.NumberSchema<string>, v.IntegerAction<number, string>, v.TransformAction<number, number>]>;
6
- export type PageType = v.InferOutput<typeof Page>;
@@ -1,3 +0,0 @@
1
- import * as v from "valibot";
2
- export const PaginationPageError = { Type: "pagination.page.type" };
3
- export const Page = v.pipe(v.unknown(), v.transform((value) => (value === undefined ? 1 : Number(value))), v.number(PaginationPageError.Type), v.integer(PaginationPageError.Type), v.transform((value) => (value <= 0 ? 1 : value)));
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const PaginationSkipError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const Skip: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
7
- export type SkipType = v.InferOutput<typeof Skip>;
@@ -1,3 +0,0 @@
1
- import * as v from "valibot";
2
- export const PaginationSkipError = { Type: "pagination.skip.type", Invalid: "pagination.skip.invalid" };
3
- export const Skip = v.pipe(v.number(PaginationSkipError.Type), v.integer(PaginationSkipError.Type), v.minValue(0, PaginationSkipError.Invalid));
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const PaginationTakeError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const Take: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>]>;
7
- export type TakeType = v.InferOutput<typeof Take>;
@@ -1,3 +0,0 @@
1
- import * as v from "valibot";
2
- export const PaginationTakeError = { Type: "pagination.take.type", Invalid: "pagination.take.invalid" };
3
- export const Take = v.pipe(v.number(PaginationTakeError.Type), v.integer(PaginationTakeError.Type), v.minValue(1, PaginationTakeError.Invalid));
@@ -1,53 +0,0 @@
1
- import { type PageType } from "./pagination-page.vo";
2
- import { type SkipType } from "./pagination-skip.vo";
3
- import { type TakeType } from "./pagination-take.vo";
4
- export type PaginationType = {
5
- values: {
6
- take: TakeType;
7
- skip: SkipType;
8
- };
9
- page: PageType;
10
- };
11
- export type PaginationValuesType = Record<string, unknown>;
12
- export type TotalType = number;
13
- export type ExhaustedType = boolean;
14
- export type PaginationExhaustedConfig = {
15
- total: TotalType;
16
- pagination: PaginationType;
17
- };
18
- export type PaginationPrepareConfigType<T> = {
19
- total: TotalType;
20
- pagination: PaginationType;
21
- result: ReadonlyArray<T>;
22
- };
23
- export declare class Pagination {
24
- static parse(values: PaginationValuesType, _take: TakeType): PaginationType;
25
- static prepare<T>(config: PaginationPrepareConfigType<T>): Paged<T>;
26
- static isExhausted(config: PaginationExhaustedConfig): ExhaustedType;
27
- private static getLastPage;
28
- static empty: {
29
- result: never[];
30
- meta: {
31
- exhausted: boolean;
32
- currentPage: number;
33
- previousPage: undefined;
34
- nextPage: undefined;
35
- lastPage: number;
36
- total: number;
37
- };
38
- };
39
- static getFirstPage(input: {
40
- take: TakeType;
41
- }): PaginationType;
42
- }
43
- export type Paged<T> = {
44
- result: ReadonlyArray<T>;
45
- meta: {
46
- exhausted: ExhaustedType;
47
- currentPage: PageType;
48
- previousPage: PageType | undefined;
49
- nextPage: PageType | undefined;
50
- lastPage: PageType;
51
- total: TotalType;
52
- };
53
- };
@@ -1,44 +0,0 @@
1
- import * as v from "valibot";
2
- import { Page } from "./pagination-page.vo";
3
- import { Skip } from "./pagination-skip.vo";
4
- import { Take } from "./pagination-take.vo";
5
- import { RoundingUpStrategy } from "./rounding-up.strategy";
6
- export class Pagination {
7
- static parse(values, _take) {
8
- const page = v.parse(Page, values.page);
9
- const take = v.parse(Take, _take);
10
- const skip = v.parse(Skip, (page - 1) * take);
11
- return { values: { take, skip }, page };
12
- }
13
- static prepare(config) {
14
- const exhausted = Pagination.isExhausted(config);
15
- const currentPage = config.pagination.page;
16
- const lastPage = Pagination.getLastPage(config);
17
- const previousPage = currentPage > 1 ? v.parse(Page, currentPage - 1) : undefined;
18
- const nextPage = currentPage < lastPage ? v.parse(Page, currentPage + 1) : undefined;
19
- return {
20
- result: config.result,
21
- meta: { exhausted, currentPage, previousPage, nextPage, lastPage, total: config.total },
22
- };
23
- }
24
- static isExhausted(config) {
25
- return Pagination.getLastPage(config) <= config.pagination.page;
26
- }
27
- static getLastPage(config) {
28
- return v.parse(Page, new RoundingUpStrategy().round(config.total / config.pagination.values.take));
29
- }
30
- static empty = {
31
- result: [],
32
- meta: {
33
- exhausted: true,
34
- currentPage: 1,
35
- previousPage: undefined,
36
- nextPage: undefined,
37
- lastPage: 1,
38
- total: 0,
39
- },
40
- };
41
- static getFirstPage(input) {
42
- return { values: { take: v.parse(Take, input.take), skip: v.parse(Skip, 0) }, page: v.parse(Page, 1) };
43
- }
44
- }
@@ -1,7 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare const PercentageError: {
3
- InvalidDenominator: string;
4
- };
5
- export declare class Percentage {
6
- static of(numerator: number, denominator: number, rounding?: RoundingStrategy): number;
7
- }
@@ -1,9 +0,0 @@
1
- import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
2
- export const PercentageError = { InvalidDenominator: "percentage.invalid.denominator" };
3
- export class Percentage {
4
- static of(numerator, denominator, rounding = new RoundingToNearestStrategy()) {
5
- if (denominator === 0)
6
- throw new Error(PercentageError.InvalidDenominator);
7
- return rounding.round((numerator / denominator) * 100);
8
- }
9
- }
@@ -1,7 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare const PopulationStandardDeviationError: {
3
- NotEnoughValues: string;
4
- };
5
- export declare class PopulationStandardDeviation {
6
- static calculate(values: ReadonlyArray<number>, rounding?: RoundingStrategy): number;
7
- }
@@ -1,17 +0,0 @@
1
- import { Mean } from "./mean.service";
2
- import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
3
- import { Sum } from "./sum.service";
4
- export const PopulationStandardDeviationError = {
5
- NotEnoughValues: "population.standard.deviation.not.enough.values",
6
- };
7
- export class PopulationStandardDeviation {
8
- static calculate(values, rounding = new RoundingDecimalStrategy(2)) {
9
- if (values.length < 2)
10
- throw new Error(PopulationStandardDeviationError.NotEnoughValues);
11
- const mean = Mean.calculate(values);
12
- const count = values.length;
13
- const squaredDifferences = values.map((value) => (value - mean) ** 2);
14
- const variance = Sum.of(squaredDifferences) / count;
15
- return rounding.round(Math.sqrt(variance));
16
- }
17
- }
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const QuarterIsoIdError: {
3
- Type: string;
4
- BadChars: string;
5
- };
6
- export declare const QUARTER_ISO_ID_CHARS_WHITELIST: RegExp;
7
- export declare const QuarterIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "QuarterIsoId">]>;
8
- export type QuarterIsoIdType = v.InferOutput<typeof QuarterIsoId>;
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export const QuarterIsoIdError = { Type: "quarter.iso.id.type", BadChars: "quarter.iso.id.bad.chars" };
3
- // 4 digits, hyphen, Q, digits from 1 to 4
4
- export const QUARTER_ISO_ID_CHARS_WHITELIST = /^\d{4}-Q[1-4]$/;
5
- export const QuarterIsoId = v.pipe(v.string(QuarterIsoIdError.Type), v.regex(QUARTER_ISO_ID_CHARS_WHITELIST, QuarterIsoIdError.BadChars),
6
- // Stryker disable next-line StringLiteral
7
- v.brand("QuarterIsoId"));
@@ -1,12 +0,0 @@
1
- import { DateRange } from "./date-range.vo";
2
- import { type QuarterIsoIdType } from "./quarter-iso-id.vo";
3
- import { Timestamp } from "./timestamp.vo";
4
- import type { TimestampValueType } from "./timestamp-value.vo";
5
- export declare class Quarter extends DateRange {
6
- static fromTimestamp(timestamp: Timestamp): Quarter;
7
- static fromTimestampValue(timestamp: TimestampValueType): Quarter;
8
- static fromNow(now: Timestamp): Quarter;
9
- static fromIsoId(isoId: QuarterIsoIdType): Quarter;
10
- toIsoId(): QuarterIsoIdType;
11
- toString(): string;
12
- }
@@ -1,30 +0,0 @@
1
- import { endOfQuarter, getQuarter, getYear, startOfQuarter } from "date-fns";
2
- import * as v from "valibot";
3
- import { DateRange } from "./date-range.vo";
4
- import { QuarterIsoId } from "./quarter-iso-id.vo";
5
- import { Timestamp } from "./timestamp.vo";
6
- export class Quarter extends DateRange {
7
- static fromTimestamp(timestamp) {
8
- const start = Timestamp.fromNumber(startOfQuarter(timestamp.ms).getTime());
9
- const end = Timestamp.fromNumber(endOfQuarter(timestamp.ms).getTime());
10
- return new Quarter(start, end);
11
- }
12
- static fromTimestampValue(timestamp) {
13
- return Quarter.fromTimestamp(Timestamp.fromValue(timestamp));
14
- }
15
- static fromNow(now) {
16
- return Quarter.fromTimestamp(now);
17
- }
18
- static fromIsoId(isoId) {
19
- const [year, quarter] = v.parse(QuarterIsoId, isoId).split("-Q").map(Number);
20
- return Quarter.fromTimestamp(Timestamp.fromNumber(Date.UTC(year, (quarter - 1) * 3, 1)));
21
- }
22
- toIsoId() {
23
- const year = getYear(this.getStart().ms);
24
- const quarter = getQuarter(this.getStart().ms);
25
- return v.parse(QuarterIsoId, `${year}-Q${quarter}`);
26
- }
27
- toString() {
28
- return this.toIsoId();
29
- }
30
- }
@@ -1,13 +0,0 @@
1
- type RandomGenerateConfigType = {
2
- min: number;
3
- max: number;
4
- };
5
- export declare const RandomError: {
6
- MinMax: string;
7
- };
8
- export declare class Random {
9
- private static readonly DEFAULT_MIN;
10
- private static readonly DEFAULT_MAX;
11
- static generate(config?: RandomGenerateConfigType): number;
12
- }
13
- export {};
@@ -1,13 +0,0 @@
1
- import { RoundingDownStrategy } from "./rounding-down.strategy";
2
- export const RandomError = { MinMax: "random.min.max" };
3
- export class Random {
4
- static DEFAULT_MIN = 0;
5
- static DEFAULT_MAX = 1;
6
- static generate(config) {
7
- const min = config ? config.min : Random.DEFAULT_MIN;
8
- const max = config ? config.max : Random.DEFAULT_MAX;
9
- if (min >= max)
10
- throw new Error(RandomError.MinMax);
11
- return new RoundingDownStrategy().round(Math.random() * (max - min + 1)) + min;
12
- }
13
- }
@@ -1,17 +0,0 @@
1
- import type { Duration } from "./duration.service";
2
- import type { Timestamp } from "./timestamp.vo";
3
- type RateLimiterResultSuccessType = {
4
- allowed: true;
5
- };
6
- type RateLimiterResultErrorType = {
7
- allowed: false;
8
- remaining: Duration;
9
- };
10
- type RateLimiterResultType = RateLimiterResultSuccessType | RateLimiterResultErrorType;
11
- export declare class RateLimiter {
12
- private readonly duration;
13
- private lastInvocation;
14
- constructor(duration: Duration);
15
- verify(now: Timestamp): RateLimiterResultType;
16
- }
17
- export {};
@@ -1,19 +0,0 @@
1
- export class RateLimiter {
2
- duration;
3
- lastInvocation = null;
4
- constructor(duration) {
5
- this.duration = duration;
6
- }
7
- verify(now) {
8
- if (this.lastInvocation == null) {
9
- this.lastInvocation = now;
10
- return { allowed: true };
11
- }
12
- const nextAllowedTimestamp = this.lastInvocation.add(this.duration);
13
- if (nextAllowedTimestamp.isBeforeOrEqual(now)) {
14
- this.lastInvocation = now;
15
- return { allowed: true };
16
- }
17
- return { allowed: false, remaining: nextAllowedTimestamp.difference(now) };
18
- }
19
- }
@@ -1,13 +0,0 @@
1
- import type { Timestamp } from "./timestamp.vo";
2
- import type { TimestampValueType } from "./timestamp-value.vo";
3
- import type { Falsy } from "./ts-utils";
4
- type RelativeDateType = {
5
- raw: TimestampValueType;
6
- relative: string;
7
- };
8
- export declare class RelativeDate {
9
- static truthy(timestamp: Timestamp): RelativeDateType;
10
- static falsy(timestamp: Falsy<Timestamp>): RelativeDateType | null;
11
- private static _format;
12
- }
13
- export {};
@@ -1,14 +0,0 @@
1
- import { DateFormatters } from "./date-formatter.service";
2
- export class RelativeDate {
3
- static truthy(timestamp) {
4
- return RelativeDate._format(timestamp);
5
- }
6
- static falsy(timestamp) {
7
- if (!timestamp)
8
- return null;
9
- return RelativeDate._format(timestamp);
10
- }
11
- static _format(timestamp) {
12
- return { raw: timestamp.ms, relative: DateFormatters.relative(timestamp.ms) };
13
- }
14
- }
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const ReorderingItemPositionValueError: {
3
- Invalid: string;
4
- };
5
- export declare const ReorderingItemPositionValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
6
- export type ReorderingItemPositionValueType = v.InferOutput<typeof ReorderingItemPositionValue>;
@@ -1,3 +0,0 @@
1
- import * as v from "valibot";
2
- export const ReorderingItemPositionValueError = { Invalid: "reordering.position.type" };
3
- export const ReorderingItemPositionValue = v.pipe(v.number(ReorderingItemPositionValueError.Invalid), v.integer(ReorderingItemPositionValueError.Invalid), v.minValue(0, ReorderingItemPositionValueError.Invalid));