@bgord/tools 1.4.6 → 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 (221) hide show
  1. package/package.json +1 -1
  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 -0
  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 -0
  198. package/dist/url-with-slash.vo.d.ts +0 -6
  199. package/dist/url-with-slash.vo.js +0 -5
  200. package/dist/url-without-slash.vo.d.ts +0 -6
  201. package/dist/url-without-slash.vo.js +0 -5
  202. package/dist/visually-unambiguous-characters-generator.service.d.ts +0 -4
  203. package/dist/visually-unambiguous-characters-generator.service.js +0 -32
  204. package/dist/week-iso-id.vo.d.ts +0 -8
  205. package/dist/week-iso-id.vo.js +0 -19
  206. package/dist/week.vo.d.ts +0 -16
  207. package/dist/week.vo.js +0 -45
  208. package/dist/weekday-iso-id.vo.d.ts +0 -7
  209. package/dist/weekday-iso-id.vo.js +0 -5
  210. package/dist/weekday.vo.d.ts +0 -28
  211. package/dist/weekday.vo.js +0 -60
  212. package/dist/weight-grams.vo.d.ts +0 -7
  213. package/dist/weight-grams.vo.js +0 -5
  214. package/dist/weight.vo.d.ts +0 -25
  215. package/dist/weight.vo.js +0 -65
  216. package/dist/year-iso-id.vo.d.ts +0 -7
  217. package/dist/year-iso-id.vo.js +0 -7
  218. package/dist/year.vo.d.ts +0 -18
  219. package/dist/year.vo.js +0 -50
  220. package/dist/z-score.service.d.ts +0 -11
  221. package/dist/z-score.service.js +0 -19
@@ -1,63 +0,0 @@
1
- import * as v from "valibot";
2
- import { type ReorderingItemPositionValueType } from "./reordering-item-position-value.vo";
3
- export declare const ReorderingError: {
4
- CannotFindItem: string;
5
- CannotFindCurrent: string;
6
- CannotFindTarget: string;
7
- };
8
- export declare const ReorderingId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
9
- export type ReorderingItemIdType = v.InferOutput<typeof ReorderingId>;
10
- export declare const Reordering: v.ObjectSchema<{
11
- readonly correlationId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
12
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
13
- readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
14
- }, undefined>;
15
- export type ReorderingType = v.InferOutput<typeof Reordering>;
16
- export type WithReorderingPositionValue<T> = T & {
17
- position: ReorderingItemPositionValueType;
18
- };
19
- export declare class ReorderingPosition {
20
- readonly value: ReorderingItemPositionValueType;
21
- constructor(value: ReorderingItemPositionValueType);
22
- eq(another: ReorderingPosition): boolean;
23
- }
24
- declare class ReorderingItem {
25
- readonly id: ReorderingItemIdType;
26
- readonly position: ReorderingPosition;
27
- constructor(id: ReorderingItemIdType, position: ReorderingPosition);
28
- eq(anotherItemId: ReorderingItem["id"]): boolean;
29
- }
30
- declare enum ReorderingTransferDirection {
31
- upwards = "upwards",
32
- downwards = "downwards",
33
- noop = "noop"
34
- }
35
- export declare class ReorderingTransfer {
36
- readonly id: ReorderingItem["id"];
37
- readonly to: ReorderingPosition;
38
- constructor(config: {
39
- id: ReorderingItem["id"];
40
- to: ReorderingItemPositionValueType;
41
- });
42
- getDirection(currentPosition: ReorderingPosition): ReorderingTransferDirection;
43
- }
44
- export declare class ReorderingCalculator {
45
- private dll;
46
- constructor();
47
- static fromArray(ids: ReadonlyArray<ReorderingItem["id"]>): ReorderingCalculator;
48
- add(id: ReorderingItem["id"]): ReorderingItem;
49
- delete(id: ReorderingItem["id"]): void;
50
- transfer(transfer: ReorderingTransfer): ReturnType<ReorderingCalculator["read"]>;
51
- read(): {
52
- ids: string[];
53
- items: ReorderingItem[];
54
- };
55
- private recalculate;
56
- }
57
- export declare class ReorderingIntegrator {
58
- static appendPosition(reordering: ReadonlyArray<ReorderingType>): <T extends {
59
- id: ReorderingItemIdType;
60
- }>(item: T) => WithReorderingPositionValue<T>;
61
- static sortByPosition(): (a: WithReorderingPositionValue<unknown>, b: WithReorderingPositionValue<unknown>) => number;
62
- }
63
- export {};
@@ -1,135 +0,0 @@
1
- // Stryker disable all
2
- import * as v from "valibot";
3
- import { DoublyLinkedList, Node } from "./dll.service";
4
- import { ReorderingItemPositionValue, } from "./reordering-item-position-value.vo";
5
- export const ReorderingError = {
6
- CannotFindItem: "reordering.cannot.find.item",
7
- CannotFindCurrent: "reordering.cannot.find.current",
8
- CannotFindTarget: "reordering.cannot.find.target",
9
- };
10
- const ReorderingIdError = { Type: "reordering.id.type" };
11
- export const ReorderingId = v.pipe(v.string(ReorderingIdError.Type), v.minLength(1, ReorderingIdError.Type));
12
- export const Reordering = v.object({
13
- correlationId: ReorderingId,
14
- id: ReorderingId,
15
- position: ReorderingItemPositionValue,
16
- });
17
- export class ReorderingPosition {
18
- value;
19
- constructor(value) {
20
- this.value = v.parse(ReorderingItemPositionValue, value);
21
- }
22
- eq(another) {
23
- return this.value === another.value;
24
- }
25
- }
26
- class ReorderingItem {
27
- id;
28
- position;
29
- constructor(id, position) {
30
- this.id = id;
31
- this.position = position;
32
- }
33
- eq(anotherItemId) {
34
- return this.id === anotherItemId;
35
- }
36
- }
37
- var ReorderingTransferDirection;
38
- (function (ReorderingTransferDirection) {
39
- ReorderingTransferDirection["upwards"] = "upwards";
40
- ReorderingTransferDirection["downwards"] = "downwards";
41
- ReorderingTransferDirection["noop"] = "noop";
42
- })(ReorderingTransferDirection || (ReorderingTransferDirection = {}));
43
- export class ReorderingTransfer {
44
- id;
45
- to;
46
- constructor(config) {
47
- const id = config.id;
48
- const to = new ReorderingPosition(config.to);
49
- this.id = id;
50
- this.to = to;
51
- }
52
- getDirection(currentPosition) {
53
- if (this.to.value === currentPosition.value)
54
- return ReorderingTransferDirection.noop;
55
- if (this.to.value > currentPosition.value)
56
- return ReorderingTransferDirection.downwards;
57
- return ReorderingTransferDirection.upwards;
58
- }
59
- }
60
- export class ReorderingCalculator {
61
- dll;
62
- constructor() {
63
- this.dll = DoublyLinkedList.fromArray([]);
64
- }
65
- static fromArray(ids) {
66
- const reordering = new ReorderingCalculator();
67
- for (const id of ids) {
68
- reordering.add(id);
69
- }
70
- return reordering;
71
- }
72
- add(id) {
73
- const size = this.dll.getSize();
74
- const position = new ReorderingPosition(v.parse(ReorderingItemPositionValue, size));
75
- const item = new ReorderingItem(id, position);
76
- const node = new Node(item);
77
- this.dll.append(node);
78
- return item;
79
- }
80
- delete(id) {
81
- const node = this.dll.find((x) => x.data.eq(id));
82
- if (!node)
83
- throw new Error(ReorderingError.CannotFindItem);
84
- this.dll.remove(node);
85
- this.recalculate();
86
- }
87
- transfer(transfer) {
88
- const current = this.dll.find((node) => node.data.eq(transfer.id));
89
- if (!current)
90
- throw new Error(ReorderingError.CannotFindCurrent);
91
- const target = this.dll.find((node) => node.data.position.eq(transfer.to));
92
- if (!target)
93
- throw new Error(ReorderingError.CannotFindTarget);
94
- const direction = transfer.getDirection(current.data.position);
95
- if (direction === ReorderingTransferDirection.noop)
96
- return this.read();
97
- // remove first to avoid temporary invalid duplicates of positions
98
- this.dll.remove(current);
99
- if (direction === ReorderingTransferDirection.upwards) {
100
- this.dll.insertBefore(current, target);
101
- }
102
- else {
103
- this.dll.insertAfter(current, target);
104
- }
105
- this.recalculate();
106
- return this.read();
107
- }
108
- read() {
109
- const ids = Array.from(this.dll).map((node) => node.data.id);
110
- const items = Array.from(this.dll).map((node) => node.data);
111
- return { ids, items };
112
- }
113
- recalculate() {
114
- let index = 0;
115
- for (const node of this.dll) {
116
- const id = node.data.id;
117
- const position = new ReorderingPosition(v.parse(ReorderingItemPositionValue, index));
118
- node.data = new ReorderingItem(id, position);
119
- index += 1;
120
- }
121
- }
122
- }
123
- export class ReorderingIntegrator {
124
- static appendPosition(reordering) {
125
- return function (item) {
126
- const found = reordering.find((x) => x.id === item.id);
127
- const positionValue = v.parse(ReorderingItemPositionValue, found?.position ?? 0);
128
- return { ...item, position: positionValue };
129
- };
130
- }
131
- static sortByPosition() {
132
- return (a, b) => a.position - b.position;
133
- }
134
- }
135
- // Stryker restore all
package/dist/repeat.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function repeat<T>(value: T, count: number): Array<T>;
package/dist/repeat.js DELETED
@@ -1,3 +0,0 @@
1
- export function repeat(value, count) {
2
- return Array.from({ length: count }).map(() => value);
3
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const RevisionValueError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const RevisionValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
7
- export type RevisionValueType = v.InferOutput<typeof RevisionValue>;
@@ -1,3 +0,0 @@
1
- import * as v from "valibot";
2
- export const RevisionValueError = { Type: "revision.value.type", Invalid: "revision.value.invalid" };
3
- export const RevisionValue = v.pipe(v.number(RevisionValueError.Type), v.integer(RevisionValueError.Type), v.minValue(0, RevisionValueError.Invalid));
@@ -1,18 +0,0 @@
1
- import type { ETag, WeakETag } from "./etags.vo";
2
- import { type RevisionValueType } from "./revision-value.vo";
3
- export declare const RevisionError: {
4
- Missing: string;
5
- Mismatch: string;
6
- };
7
- export declare class Revision {
8
- static readonly INITIAL: RevisionValueType;
9
- readonly value: RevisionValueType;
10
- constructor(value: unknown);
11
- equals(another: RevisionValueType): boolean;
12
- validate(another: RevisionValueType): void;
13
- next(): Revision;
14
- static fromETag(etag: ETag | null): Revision;
15
- static fromWeakETag(weakEtag: WeakETag | null): Revision;
16
- toString(): string;
17
- toJSON(): number;
18
- }
@@ -1,36 +0,0 @@
1
- import * as v from "valibot";
2
- import { RevisionValue } from "./revision-value.vo";
3
- export const RevisionError = { Missing: "revision.missing", Mismatch: "revision.mismatch" };
4
- export class Revision {
5
- static INITIAL = v.parse(RevisionValue, 0);
6
- value;
7
- constructor(value) {
8
- this.value = v.parse(RevisionValue, value);
9
- }
10
- equals(another) {
11
- return this.value === another;
12
- }
13
- validate(another) {
14
- if (!this.equals(another))
15
- throw new Error(RevisionError.Mismatch);
16
- }
17
- next() {
18
- return new Revision(this.value + 1);
19
- }
20
- static fromETag(etag) {
21
- if (!etag)
22
- throw new Error(RevisionError.Missing);
23
- return new Revision(etag.revision);
24
- }
25
- static fromWeakETag(weakEtag) {
26
- if (!weakEtag)
27
- throw new Error(RevisionError.Missing);
28
- return new Revision(weakEtag.revision);
29
- }
30
- toString() {
31
- return this.value.toString();
32
- }
33
- toJSON() {
34
- return this.value;
35
- }
36
- }
@@ -1,12 +0,0 @@
1
- import * as v from "valibot";
2
- import type { RoundingStrategy } from "./rounding.strategy";
3
- export declare const RoundingDecimalError: {
4
- Type: string;
5
- Invalid: string;
6
- };
7
- export declare const RoundingDecimal: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.MaxValueAction<number, 100, string>, v.BrandAction<number, "RoundingDecimal">]>;
8
- export declare class RoundingDecimalStrategy implements RoundingStrategy {
9
- private readonly decimals;
10
- constructor(candidate: number);
11
- round(value: number): number;
12
- }
@@ -1,14 +0,0 @@
1
- import * as v from "valibot";
2
- export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
3
- export const RoundingDecimal = v.pipe(v.number(RoundingDecimalError.Type), v.integer(RoundingDecimalError.Invalid), v.minValue(1, RoundingDecimalError.Invalid), v.maxValue(100, RoundingDecimalError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("RoundingDecimal"));
6
- export class RoundingDecimalStrategy {
7
- decimals;
8
- constructor(candidate) {
9
- this.decimals = v.parse(RoundingDecimal, candidate);
10
- }
11
- round(value) {
12
- return Number.parseFloat(value.toFixed(this.decimals));
13
- }
14
- }
@@ -1,4 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare class RoundingDownStrategy implements RoundingStrategy {
3
- round(value: number): number;
4
- }
@@ -1,5 +0,0 @@
1
- export class RoundingDownStrategy {
2
- round(value) {
3
- return Math.floor(value);
4
- }
5
- }
@@ -1,4 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare class RoundingToNearestStrategy implements RoundingStrategy {
3
- round(value: number): number;
4
- }
@@ -1,5 +0,0 @@
1
- export class RoundingToNearestStrategy {
2
- round(value) {
3
- return Math.round(value);
4
- }
5
- }
@@ -1,4 +0,0 @@
1
- import type { RoundingStrategy } from "./rounding.strategy";
2
- export declare class RoundingUpStrategy implements RoundingStrategy {
3
- round(value: number): number;
4
- }
@@ -1,5 +0,0 @@
1
- export class RoundingUpStrategy {
2
- round(value) {
3
- return Math.ceil(value);
4
- }
5
- }
@@ -1,3 +0,0 @@
1
- export interface RoundingStrategy {
2
- round(value: number): number;
3
- }
File without changes
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const SizeBytesError: {
3
- Invalid: string;
4
- };
5
- export declare const SizeBytes: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "SizeBytes">]>;
6
- export type SizeBytesType = v.InferOutput<typeof SizeBytes>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const SizeBytesError = { Invalid: "size.bytes.invalid" };
3
- export const SizeBytes = v.pipe(v.number(SizeBytesError.Invalid), v.integer(SizeBytesError.Invalid), v.minValue(0, SizeBytesError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("SizeBytes"));
package/dist/size.vo.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { type SizeBytesType } from "./size-bytes.vo";
2
- declare enum SizeUnitEnum {
3
- b = "b",
4
- kB = "kB",
5
- MB = "MB",
6
- GB = "GB"
7
- }
8
- type SizeConfigType = {
9
- unit: SizeUnitEnum;
10
- value: number;
11
- };
12
- export declare class Size {
13
- private readonly unit;
14
- private readonly bytes;
15
- private static readonly KB_MULTIPLIER;
16
- private static readonly MB_MULTIPLIER;
17
- private static readonly GB_MULTIPLIER;
18
- private static readonly CONVERT_ROUND;
19
- private static readonly FORMAT_ROUND;
20
- private constructor();
21
- static fromBytes(value: SizeConfigType["value"]): Size;
22
- static fromKb(value: SizeConfigType["value"]): Size;
23
- static fromMB(value: SizeConfigType["value"]): Size;
24
- static fromGB(value: SizeConfigType["value"]): Size;
25
- toBytes(): SizeBytesType;
26
- tokB(): number;
27
- toMB(): number;
28
- toGB(): number;
29
- equals(another: Size): boolean;
30
- isSmallerThan(another: Size): boolean;
31
- isGreaterThan(another: Size): boolean;
32
- format(unit: SizeUnitEnum): string;
33
- static toBytes(config: SizeConfigType): SizeBytesType;
34
- static unit: typeof SizeUnitEnum;
35
- private calculateBytes;
36
- toString(): string;
37
- toJSON(): {
38
- bytes: number;
39
- };
40
- }
41
- export {};
package/dist/size.vo.js DELETED
@@ -1,91 +0,0 @@
1
- import * as v from "valibot";
2
- import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
3
- import { RoundingUpStrategy } from "./rounding-up.strategy";
4
- import { SizeBytes } from "./size-bytes.vo";
5
- var SizeUnitEnum;
6
- (function (SizeUnitEnum) {
7
- SizeUnitEnum["b"] = "b";
8
- SizeUnitEnum["kB"] = "kB";
9
- SizeUnitEnum["MB"] = "MB";
10
- SizeUnitEnum["GB"] = "GB";
11
- })(SizeUnitEnum || (SizeUnitEnum = {}));
12
- export class Size {
13
- unit;
14
- bytes;
15
- static KB_MULTIPLIER = 1024;
16
- static MB_MULTIPLIER = 1024 * Size.KB_MULTIPLIER;
17
- static GB_MULTIPLIER = 1024 * Size.MB_MULTIPLIER;
18
- static CONVERT_ROUND = new RoundingUpStrategy();
19
- static FORMAT_ROUND = new RoundingDecimalStrategy(2);
20
- constructor(config) {
21
- this.unit = config.unit;
22
- this.bytes = this.calculateBytes(config.value, config.unit);
23
- }
24
- static fromBytes(value) {
25
- return new Size({ value, unit: SizeUnitEnum.b });
26
- }
27
- static fromKb(value) {
28
- return new Size({ value, unit: SizeUnitEnum.kB });
29
- }
30
- static fromMB(value) {
31
- return new Size({ value, unit: SizeUnitEnum.MB });
32
- }
33
- static fromGB(value) {
34
- return new Size({ value, unit: SizeUnitEnum.GB });
35
- }
36
- toBytes() {
37
- return this.bytes;
38
- }
39
- tokB() {
40
- return Size.CONVERT_ROUND.round(this.bytes / Size.KB_MULTIPLIER);
41
- }
42
- toMB() {
43
- return Size.CONVERT_ROUND.round(this.bytes / Size.MB_MULTIPLIER);
44
- }
45
- toGB() {
46
- return Size.CONVERT_ROUND.round(this.bytes / Size.GB_MULTIPLIER);
47
- }
48
- equals(another) {
49
- return this.bytes === another.toBytes();
50
- }
51
- isSmallerThan(another) {
52
- return this.bytes < another.toBytes();
53
- }
54
- isGreaterThan(another) {
55
- return this.bytes > another.toBytes();
56
- }
57
- format(unit) {
58
- switch (unit) {
59
- case SizeUnitEnum.kB:
60
- return `${Size.FORMAT_ROUND.round(this.bytes / Size.KB_MULTIPLIER)} ${SizeUnitEnum.kB}`;
61
- case SizeUnitEnum.MB:
62
- return `${Size.FORMAT_ROUND.round(this.bytes / Size.MB_MULTIPLIER)} ${SizeUnitEnum.MB}`;
63
- case SizeUnitEnum.GB:
64
- return `${Size.FORMAT_ROUND.round(this.bytes / Size.GB_MULTIPLIER)} ${SizeUnitEnum.GB}`;
65
- default:
66
- return `${this.bytes} ${SizeUnitEnum.b}`;
67
- }
68
- }
69
- static toBytes(config) {
70
- return new Size(config).toBytes();
71
- }
72
- static unit = SizeUnitEnum;
73
- calculateBytes(value, unit) {
74
- switch (unit) {
75
- case SizeUnitEnum.kB:
76
- return v.parse(SizeBytes, value * Size.KB_MULTIPLIER);
77
- case SizeUnitEnum.MB:
78
- return v.parse(SizeBytes, value * Size.MB_MULTIPLIER);
79
- case SizeUnitEnum.GB:
80
- return v.parse(SizeBytes, value * Size.GB_MULTIPLIER);
81
- default:
82
- return v.parse(SizeBytes, value);
83
- }
84
- }
85
- toString() {
86
- return this.format(this.unit);
87
- }
88
- toJSON() {
89
- return { bytes: this.bytes };
90
- }
91
- }
@@ -1,4 +0,0 @@
1
- export declare class Slug {
2
- private static WHITELIST;
3
- static generate(input: string, separator?: string): string;
4
- }
@@ -1,15 +0,0 @@
1
- export class Slug {
2
- // Any letter or any number
3
- static WHITELIST = /[\p{L}\p{N}]/u;
4
- static generate(input, separator = "-") {
5
- return (input
6
- .split("")
7
- .map((character) => (Slug.WHITELIST.test(character) ? character : separator))
8
- .join("")
9
- // Collapse multiple consecutive separators
10
- .replace(new RegExp(`\\${separator}+`, "g"), separator)
11
- // Trim leading and trailing separators
12
- .replace(new RegExp(`^\\${separator}|\\${separator}$`, "g"), "")
13
- .toLocaleLowerCase());
14
- }
15
- }
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const SmsBodyError: {
3
- Type: string;
4
- Empty: string;
5
- TooLong: string;
6
- };
7
- export declare const SmsBody: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 640, string>, v.BrandAction<string, "SmsBody">]>;
8
- export type SmsBodyType = v.InferOutput<typeof SmsBody>;
@@ -1,9 +0,0 @@
1
- import * as v from "valibot";
2
- export const SmsBodyError = {
3
- Type: "sms.body.type",
4
- Empty: "sms.body.empty",
5
- TooLong: "sms.body.too.long",
6
- };
7
- export const SmsBody = v.pipe(v.string(SmsBodyError.Type), v.minLength(1, SmsBodyError.Empty), v.maxLength(640, SmsBodyError.TooLong),
8
- // Stryker disable next-line StringLiteral
9
- v.brand("SmsBody"));
@@ -1,13 +0,0 @@
1
- import type { SmsBodyType } from "./sms-body.vo";
2
- import type { TelephoneNumberType } from "./telephone-number.vo";
3
- export declare class SmsMessage {
4
- readonly to: TelephoneNumberType;
5
- readonly body: SmsBodyType;
6
- readonly from?: TelephoneNumberType | undefined;
7
- constructor(to: TelephoneNumberType, body: SmsBodyType, from?: TelephoneNumberType | undefined);
8
- toJSON(): {
9
- to: string & import("valibot").Brand<"TelephoneNumber">;
10
- from: (string & import("valibot").Brand<"TelephoneNumber">) | undefined;
11
- body: string & import("valibot").Brand<"SmsBody">;
12
- };
13
- }
@@ -1,13 +0,0 @@
1
- export class SmsMessage {
2
- to;
3
- body;
4
- from;
5
- constructor(to, body, from) {
6
- this.to = to;
7
- this.body = body;
8
- this.from = from;
9
- }
10
- toJSON() {
11
- return { to: this.to, from: this.from, body: this.body };
12
- }
13
- }
@@ -1,4 +0,0 @@
1
- export declare class Sum {
2
- static of(values: ReadonlyArray<number>): number;
3
- static precise(values: ReadonlyArray<number>): number;
4
- }
@@ -1,16 +0,0 @@
1
- export class Sum {
2
- static of(values) {
3
- return values.reduce((sum, x) => sum + x, 0);
4
- }
5
- static precise(values) {
6
- let sum = 0;
7
- let compensation = 0;
8
- for (const value of values) {
9
- const adjusted = value - compensation;
10
- const temporary = sum + adjusted;
11
- compensation = temporary - sum - adjusted;
12
- sum = temporary;
13
- }
14
- return sum;
15
- }
16
- }
@@ -1,7 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const TelephoneNumberError: {
3
- Type: string;
4
- Invalid: string;
5
- };
6
- export declare const TelephoneNumber: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "TelephoneNumber">]>;
7
- export type TelephoneNumberType = v.InferOutput<typeof TelephoneNumber>;
@@ -1,10 +0,0 @@
1
- import * as v from "valibot";
2
- export const TelephoneNumberError = {
3
- Type: "telephone.number.type",
4
- Invalid: "telephone.number.invalid",
5
- };
6
- // E.164 format: + followed by 2-15 digits, no leading zero in country code
7
- const E164 = /^\+[1-9]\d{1,14}$/;
8
- export const TelephoneNumber = v.pipe(v.string(TelephoneNumberError.Type), v.regex(E164, TelephoneNumberError.Invalid),
9
- // Stryker disable next-line StringLiteral
10
- v.brand("TelephoneNumber"));
@@ -1,4 +0,0 @@
1
- export declare class ThousandsSeparator {
2
- private static DEFAULT_SEPARATOR;
3
- static format(value: number, separator?: string): string;
4
- }
@@ -1,9 +0,0 @@
1
- export class ThousandsSeparator {
2
- static DEFAULT_SEPARATOR = " ";
3
- static format(value, separator = ThousandsSeparator.DEFAULT_SEPARATOR) {
4
- // B - not a word boundary, prevents inserting at the very start
5
- // (?=([0-9]{3})+(?![0-9])) - positive lookahead, find three digits
6
- // (?![0-9]) - negative lookahead, the next character is not a digit
7
- return value.toString().replace(/\B(?=([0-9]{3})+(?![0-9]))/g, separator);
8
- }
9
- }
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const TimeZoneOffsetValueError: {
3
- Type: string;
4
- Min: string;
5
- Max: string;
6
- };
7
- export declare const TimeZoneOffsetValue: v.SchemaWithPipe<readonly [v.UnknownSchema, v.TransformAction<unknown, number>, v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, -840, string>, v.MaxValueAction<number, 720, string>, v.BrandAction<number, "TimeZoneOffsetValue">]>;
8
- export type TimeZoneOffsetValueType = v.InferOutput<typeof TimeZoneOffsetValue>;
@@ -1,13 +0,0 @@
1
- import * as v from "valibot";
2
- export const TimeZoneOffsetValueError = {
3
- Type: "time.zone.offset.value.type",
4
- Min: "time.zone.offset.value.min",
5
- Max: "time.zone.offset.value.max",
6
- };
7
- export const TimeZoneOffsetValue = v.pipe(v.unknown(), v.transform((value) => (value === undefined ? 0 : Number(value))), v.number(TimeZoneOffsetValueError.Type), v.integer(TimeZoneOffsetValueError.Type),
8
- // UTC+14 (Kiribati)
9
- v.minValue(-840, TimeZoneOffsetValueError.Min),
10
- // UTC-12 (Baker Island)
11
- v.maxValue(720, TimeZoneOffsetValueError.Max),
12
- // Stryker disable next-line StringLiteral
13
- v.brand("TimeZoneOffsetValue"));