@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,148 +0,0 @@
1
- export class Node {
2
- data;
3
- prev = null;
4
- next = null;
5
- constructor(data) {
6
- this.data = data;
7
- }
8
- forward(n) {
9
- let currentNode = this;
10
- let steps = n;
11
- while (steps > 0 && currentNode) {
12
- currentNode = currentNode.next;
13
- steps -= 1;
14
- }
15
- return currentNode;
16
- }
17
- backward(n) {
18
- let currentNode = this;
19
- let steps = n;
20
- while (steps > 0 && currentNode) {
21
- currentNode = currentNode.prev;
22
- steps -= 1;
23
- }
24
- return currentNode;
25
- }
26
- }
27
- export class DoublyLinkedList {
28
- static EMPTY_SIZE = 0;
29
- size = DoublyLinkedList.EMPTY_SIZE;
30
- head = null;
31
- tail = null;
32
- getSize() {
33
- return this.size;
34
- }
35
- isEmpty() {
36
- return this.size === 0;
37
- }
38
- getHead() {
39
- return this.head;
40
- }
41
- getTail() {
42
- return this.tail;
43
- }
44
- append(node) {
45
- if (this.tail === null) {
46
- this.head = node;
47
- this.tail = node;
48
- }
49
- else {
50
- this.tail.next = node;
51
- node.prev = this.tail;
52
- this.tail = node;
53
- }
54
- this.size += 1;
55
- }
56
- prepend(node) {
57
- if (this.head === null) {
58
- this.head = node;
59
- this.tail = node;
60
- }
61
- else {
62
- node.next = this.head;
63
- this.head.prev = node;
64
- this.head = node;
65
- }
66
- this.size += 1;
67
- }
68
- clear() {
69
- this.size = 0;
70
- this.head = null;
71
- this.tail = null;
72
- }
73
- remove(node) {
74
- if (node.prev) {
75
- node.prev.next = node.next;
76
- }
77
- else {
78
- this.head = node.next;
79
- }
80
- if (node.next) {
81
- node.next.prev = node.prev;
82
- }
83
- else {
84
- this.tail = node.prev;
85
- }
86
- this.size -= 1;
87
- node.prev = null;
88
- node.next = null;
89
- }
90
- insertAfter(node, target) {
91
- if (target === this.tail) {
92
- this.append(node);
93
- return;
94
- }
95
- const nextNode = target.next;
96
- this.size += 1;
97
- node.prev = target;
98
- node.next = nextNode;
99
- nextNode.prev = node;
100
- target.next = node;
101
- }
102
- insertBefore(node, target) {
103
- if (target === this.head) {
104
- this.prepend(node);
105
- return;
106
- }
107
- const prevNode = target.prev;
108
- this.size += 1;
109
- node.next = target;
110
- node.prev = prevNode;
111
- prevNode.next = node;
112
- target.prev = node;
113
- }
114
- find(callback) {
115
- let current = this.head;
116
- while (current) {
117
- if (callback(current))
118
- return current;
119
- current = current.next;
120
- }
121
- return null;
122
- }
123
- reverse() {
124
- [this.head, this.tail] = [this.tail, this.head];
125
- for (const node of this) {
126
- const originalNext = node.next;
127
- node.next = node.prev;
128
- node.prev = originalNext;
129
- }
130
- }
131
- toArray() {
132
- return Array.from(this);
133
- }
134
- static fromArray(array) {
135
- const dll = new DoublyLinkedList();
136
- for (const item of array) {
137
- dll.append(new Node(item));
138
- }
139
- return dll;
140
- }
141
- *[Symbol.iterator]() {
142
- let current = this.head;
143
- while (current) {
144
- yield current;
145
- current = current.next;
146
- }
147
- }
148
- }
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const DurationMsError: {
3
- Invalid: string;
4
- };
5
- export declare const DurationMs: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.BrandAction<number, "DurationMs">]>;
6
- export type DurationMsType = v.InferOutput<typeof DurationMs>;
@@ -1,5 +0,0 @@
1
- import * as v from "valibot";
2
- export const DurationMsError = { Invalid: "duration.invalid" };
3
- export const DurationMs = v.pipe(v.number(DurationMsError.Invalid), v.integer(DurationMsError.Invalid),
4
- // Stryker disable next-line StringLiteral
5
- v.brand("DurationMs"));
@@ -1,37 +0,0 @@
1
- import { type DurationMsType } from "./duration-ms.vo";
2
- import type { MultiplicationFactorType } from "./multiplication-factor.vo";
3
- export declare class Duration {
4
- private static readonly rounding;
5
- private readonly internal;
6
- static readonly MIN: Duration;
7
- private static readonly NS_IN_MS;
8
- private static readonly MS_IN_SECOND;
9
- private static readonly MS_IN_MINUTE;
10
- private static readonly MS_IN_HOUR;
11
- private static readonly MS_IN_DAY;
12
- private static readonly MS_IN_WEEK;
13
- constructor(candidateMs: number);
14
- static Weeks(value: number): Duration;
15
- static Days(value: number): Duration;
16
- static Hours(value: number): Duration;
17
- static Minutes(value: number): Duration;
18
- static Seconds(value: number): Duration;
19
- static Ms(value: number): Duration;
20
- static Ns(value: number): Duration;
21
- get weeks(): number;
22
- get days(): number;
23
- get hours(): number;
24
- get minutes(): number;
25
- get seconds(): number;
26
- get ms(): DurationMsType;
27
- get ns(): number;
28
- isLongerThan(another: Duration): boolean;
29
- isShorterThan(another: Duration): boolean;
30
- equals(other: Duration): boolean;
31
- add(another: Duration): Duration;
32
- subtract(another: Duration): Duration;
33
- times(factor: MultiplicationFactorType): Duration;
34
- toAbsolute(): Duration;
35
- toString(): string;
36
- toJSON(): number;
37
- }
@@ -1,87 +0,0 @@
1
- import * as v from "valibot";
2
- import { DurationMs } from "./duration-ms.vo";
3
- import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
4
- import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
5
- export class Duration {
6
- static rounding = new RoundingDecimalStrategy(2);
7
- internal;
8
- static MIN = Duration.Ms(1);
9
- static NS_IN_MS = 1000000;
10
- static MS_IN_SECOND = 1_000;
11
- static MS_IN_MINUTE = 60 * Duration.MS_IN_SECOND;
12
- static MS_IN_HOUR = 60 * Duration.MS_IN_MINUTE;
13
- static MS_IN_DAY = 24 * Duration.MS_IN_HOUR;
14
- static MS_IN_WEEK = 7 * Duration.MS_IN_DAY;
15
- constructor(candidateMs) {
16
- this.internal = v.parse(DurationMs, candidateMs);
17
- }
18
- static Weeks(value) {
19
- return new Duration(value * Duration.MS_IN_WEEK);
20
- }
21
- static Days(value) {
22
- return new Duration(value * Duration.MS_IN_DAY);
23
- }
24
- static Hours(value) {
25
- return new Duration(value * Duration.MS_IN_HOUR);
26
- }
27
- static Minutes(value) {
28
- return new Duration(value * Duration.MS_IN_MINUTE);
29
- }
30
- static Seconds(value) {
31
- return new Duration(value * Duration.MS_IN_SECOND);
32
- }
33
- static Ms(value) {
34
- return new Duration(value);
35
- }
36
- static Ns(value) {
37
- return new Duration(new RoundingToNearestStrategy().round(value / Duration.NS_IN_MS));
38
- }
39
- get weeks() {
40
- return Duration.rounding.round(this.internal / Duration.MS_IN_WEEK);
41
- }
42
- get days() {
43
- return Duration.rounding.round(this.internal / Duration.MS_IN_DAY);
44
- }
45
- get hours() {
46
- return Duration.rounding.round(this.internal / Duration.MS_IN_HOUR);
47
- }
48
- get minutes() {
49
- return Duration.rounding.round(this.internal / Duration.MS_IN_MINUTE);
50
- }
51
- get seconds() {
52
- return Duration.rounding.round(this.internal / Duration.MS_IN_SECOND);
53
- }
54
- get ms() {
55
- return this.internal;
56
- }
57
- get ns() {
58
- return this.internal * Duration.NS_IN_MS;
59
- }
60
- isLongerThan(another) {
61
- return this.internal > another.internal;
62
- }
63
- isShorterThan(another) {
64
- return this.internal < another.internal;
65
- }
66
- equals(other) {
67
- return this.internal === other.internal;
68
- }
69
- add(another) {
70
- return Duration.Ms(this.internal + another.internal);
71
- }
72
- subtract(another) {
73
- return Duration.Ms(this.internal - another.internal);
74
- }
75
- times(factor) {
76
- return Duration.Ms(new RoundingToNearestStrategy().round(this.internal * factor));
77
- }
78
- toAbsolute() {
79
- return Duration.Ms(Math.abs(this.internal));
80
- }
81
- toString() {
82
- return this.internal.toString();
83
- }
84
- toJSON() {
85
- return this.internal;
86
- }
87
- }
@@ -1,4 +0,0 @@
1
- import type { EmailType } from "./email.vo";
2
- export declare class EmailMask {
3
- static censor(email: EmailType): string;
4
- }
@@ -1,12 +0,0 @@
1
- export class EmailMask {
2
- static censor(email) {
3
- const [local, domain] = email.split("@");
4
- if (local.length <= 2)
5
- return `${"*".repeat(local.length)}@${domain}`;
6
- const firstCharacter = local.at(0);
7
- const censoredPart = "*".repeat(local.length - 2);
8
- const lastCharacter = local.at(-1);
9
- const censoredLocal = `${firstCharacter}${censoredPart}${lastCharacter}`;
10
- return `${censoredLocal}@${domain}`;
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const EmailError: {
3
- Invalid: string;
4
- };
5
- export declare const Email: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.EmailAction<string, string>, v.BrandAction<string, "Email">]>;
6
- export type EmailType = v.InferOutput<typeof Email>;
package/dist/email.vo.js DELETED
@@ -1,4 +0,0 @@
1
- import * as v from "valibot";
2
- export const EmailError = { Invalid: "email.invalid" };
3
- // Stryker disable next-line StringLiteral
4
- export const Email = v.pipe(v.string(EmailError.Invalid), v.email(EmailError.Invalid), v.brand("Email"));
@@ -1,23 +0,0 @@
1
- import { type RevisionValueType } from "./revision-value.vo";
2
- type ETagValueType = string;
3
- export declare class ETag {
4
- readonly revision: RevisionValueType;
5
- static HEADER_NAME: string;
6
- static IF_MATCH_HEADER_NAME: string;
7
- readonly value: ETagValueType;
8
- private constructor();
9
- static fromHeader(value?: ETagValueType): ETag | null;
10
- }
11
- export type WeakETagValueType = string;
12
- export declare const WeakETagError: {
13
- Invalid: string;
14
- };
15
- export declare class WeakETag {
16
- readonly revision: RevisionValueType;
17
- static HEADER_NAME: string;
18
- static IF_MATCH_HEADER_NAME: string;
19
- readonly value: WeakETagValueType;
20
- private constructor();
21
- static fromHeader(value?: WeakETagValueType): WeakETag | null;
22
- }
23
- export {};
package/dist/etags.vo.js DELETED
@@ -1,37 +0,0 @@
1
- import * as v from "valibot";
2
- import { RevisionValue } from "./revision-value.vo";
3
- export class ETag {
4
- revision;
5
- static HEADER_NAME = "ETag";
6
- static IF_MATCH_HEADER_NAME = "if-match";
7
- value;
8
- constructor(revision) {
9
- this.revision = revision;
10
- this.value = revision.toString();
11
- }
12
- static fromHeader(value) {
13
- const candidate = Number(value);
14
- if (Number.isNaN(candidate))
15
- return null;
16
- return new ETag(v.parse(RevisionValue, candidate));
17
- }
18
- }
19
- export const WeakETagError = { Invalid: "weak.etag.invalid" };
20
- export class WeakETag {
21
- revision;
22
- static HEADER_NAME = "ETag";
23
- static IF_MATCH_HEADER_NAME = "if-match";
24
- value;
25
- constructor(revision) {
26
- this.revision = revision;
27
- this.value = `W/${revision.toString()}`;
28
- }
29
- static fromHeader(value) {
30
- if (!value?.startsWith("W/"))
31
- throw new Error(WeakETagError.Invalid);
32
- const candidate = Number(value.split("W/")[1]);
33
- if (Number.isNaN(candidate))
34
- return null;
35
- return new WeakETag(v.parse(RevisionValue, candidate));
36
- }
37
- }
@@ -1,9 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const ExtensionError: {
3
- Type: string;
4
- Empty: string;
5
- TooLong: string;
6
- BadChars: string;
7
- };
8
- export declare const Extension: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.ToLowerCaseAction, v.TransformAction<string, string>, v.MinLengthAction<string, 2, string>, v.MaxLengthAction<string, 16, string>, v.CheckAction<string, string>, v.BrandAction<string, "Extension">]>;
9
- export type ExtensionType = v.InferOutput<typeof Extension>;
@@ -1,15 +0,0 @@
1
- import * as v from "valibot";
2
- export const ExtensionError = {
3
- Type: "extension.type",
4
- Empty: "extension.empty",
5
- TooLong: "extension.too.long",
6
- BadChars: "extension.bad.chars",
7
- };
8
- // Lowercase letters and digits allowed
9
- const EXTENSION_WHITELIST = /^[a-z0-9]+$/;
10
- const LEADING_DOT_FILE = /^\./;
11
- export const Extension = v.pipe(v.string(ExtensionError.Type), v.toLowerCase(),
12
- // Transform ".png" -> "png"
13
- v.transform((value) => value.replace(LEADING_DOT_FILE, "")), v.minLength(2, ExtensionError.Empty), v.maxLength(16, ExtensionError.TooLong), v.check((value) => EXTENSION_WHITELIST.test(value), ExtensionError.BadChars),
14
- // Stryker disable next-line StringLiteral
15
- v.brand("Extension"));
@@ -1,10 +0,0 @@
1
- import * as v from "valibot";
2
- export declare const FeatureFlagValueError: {
3
- Invalid: string;
4
- };
5
- export declare enum FeatureFlagEnum {
6
- yes = "yes",
7
- no = "no"
8
- }
9
- export declare const FeatureFlagValue: v.PicklistSchema<FeatureFlagEnum[], string>;
10
- export type FeatureFlagValueType = v.InferOutput<typeof FeatureFlagValue>;
@@ -1,8 +0,0 @@
1
- import * as v from "valibot";
2
- export const FeatureFlagValueError = { Invalid: "feature.flag.value.invalid" };
3
- export var FeatureFlagEnum;
4
- (function (FeatureFlagEnum) {
5
- FeatureFlagEnum["yes"] = "yes";
6
- FeatureFlagEnum["no"] = "no";
7
- })(FeatureFlagEnum || (FeatureFlagEnum = {}));
8
- export const FeatureFlagValue = v.picklist(Object.values(FeatureFlagEnum), FeatureFlagValueError.Invalid);
@@ -1,5 +0,0 @@
1
- import { type FeatureFlagValueType } from "./feature-flag-value.vo";
2
- export declare class FeatureFlag {
3
- static isEnabled(flag: FeatureFlagValueType): boolean;
4
- static isDisabled(flag: FeatureFlagValueType): boolean;
5
- }
@@ -1,9 +0,0 @@
1
- import { FeatureFlagEnum } from "./feature-flag-value.vo";
2
- export class FeatureFlag {
3
- static isEnabled(flag) {
4
- return flag === FeatureFlagEnum.yes;
5
- }
6
- static isDisabled(flag) {
7
- return flag === FeatureFlagEnum.no;
8
- }
9
- }
@@ -1,17 +0,0 @@
1
- import * as v from "valibot";
2
- import { Filename } from "./filename.vo";
3
- export declare const FilePathAbsoluteSchemaError: {
4
- Type: string;
5
- LeadingSlash: string;
6
- TrailingSlash: string;
7
- BackslashForbidden: string;
8
- Empty: string;
9
- };
10
- export declare const FilePathAbsoluteSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.TransformAction<string, {
11
- directory: string & v.Brand<"DirectoryPathAbsoluteSchema">;
12
- filename: Filename;
13
- }>, v.BrandAction<{
14
- directory: string & v.Brand<"DirectoryPathAbsoluteSchema">;
15
- filename: Filename;
16
- }, "FilePathAbsoluteSchema">]>;
17
- export type FilePathAbsoluteType = v.InferOutput<typeof FilePathAbsoluteSchema>;
@@ -1,20 +0,0 @@
1
- import * as v from "valibot";
2
- import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
3
- import { Filename } from "./filename.vo";
4
- export const FilePathAbsoluteSchemaError = {
5
- Type: "file.path.absolute.type",
6
- LeadingSlash: "file.path.absolute.leading.slash",
7
- TrailingSlash: "file.path.absolute.trailing.slash",
8
- BackslashForbidden: "file.path.absolute.backslash.forbidden",
9
- Empty: "file.path.absolute.empty",
10
- };
11
- export const FilePathAbsoluteSchema = v.pipe(v.string(FilePathAbsoluteSchemaError.Type), v.minLength(1, FilePathAbsoluteSchemaError.Empty), v.check((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash), v.check((value) => !value.endsWith("/"), FilePathAbsoluteSchemaError.TrailingSlash), v.check((value) => !value.includes("\\"), FilePathAbsoluteSchemaError.BackslashForbidden), v.transform((normalized) => {
12
- const index = normalized.lastIndexOf("/");
13
- const directoryCandidate = index === 0 ? "/" : normalized.slice(0, index);
14
- const filenameCandidate = normalized.slice(index + 1);
15
- const directory = v.parse(DirectoryPathAbsoluteSchema, directoryCandidate);
16
- const filename = Filename.fromString(filenameCandidate);
17
- return { directory, filename };
18
- }),
19
- // Stryker disable next-line StringLiteral
20
- v.brand("FilePathAbsoluteSchema"));
@@ -1,17 +0,0 @@
1
- import * as v from "valibot";
2
- import { Filename } from "./filename.vo";
3
- export declare const FilePathRelativeSchemaError: {
4
- Type: string;
5
- LeadingSlash: string;
6
- BackslashForbidden: string;
7
- RequiresDirectory: string;
8
- Empty: string;
9
- };
10
- export declare const FilePathRelativeSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.CheckAction<string, string>, v.TransformAction<string, {
11
- directory: string & v.Brand<"DirectoryPathRelativeSchema">;
12
- filename: Filename;
13
- }>, v.BrandAction<{
14
- directory: string & v.Brand<"DirectoryPathRelativeSchema">;
15
- filename: Filename;
16
- }, "FilePathRelativeSchema">]>;
17
- export type FilePathRelativeType = v.InferOutput<typeof FilePathRelativeSchema>;
@@ -1,20 +0,0 @@
1
- import * as v from "valibot";
2
- import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
3
- import { Filename } from "./filename.vo";
4
- export const FilePathRelativeSchemaError = {
5
- Type: "file.path.relative.type",
6
- LeadingSlash: "file.path.relative.leading.slash",
7
- BackslashForbidden: "file.path.relative.backslash.forbidden",
8
- RequiresDirectory: "file.path.relative.requires.directory",
9
- Empty: "file.path.relative.empty",
10
- };
11
- export const FilePathRelativeSchema = v.pipe(v.string(FilePathRelativeSchemaError.Type), v.minLength(1, FilePathRelativeSchemaError.Empty), v.check((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash), v.check((value) => !value.includes("\\"), FilePathRelativeSchemaError.BackslashForbidden), v.check((value) => value.includes("/"), FilePathRelativeSchemaError.RequiresDirectory), v.transform((normalized) => {
12
- const lastSlashIndex = normalized.lastIndexOf("/");
13
- const directoryCandidate = normalized.slice(0, lastSlashIndex);
14
- const filenameCandidate = normalized.slice(lastSlashIndex + 1);
15
- const directory = v.parse(DirectoryPathRelativeSchema, directoryCandidate);
16
- const filename = Filename.fromString(filenameCandidate);
17
- return { directory, filename };
18
- }),
19
- // Stryker disable next-line StringLiteral
20
- v.brand("FilePathRelativeSchema"));
@@ -1,31 +0,0 @@
1
- import { type DirectoryPathAbsoluteType } from "./directory-path-absolute.vo";
2
- import { type DirectoryPathRelativeType } from "./directory-path-relative.vo";
3
- import type { Filename } from "./filename.vo";
4
- export declare class FilePathRelative {
5
- private readonly directory;
6
- private readonly filename;
7
- private constructor();
8
- static fromParts(directoryCandidate: string, filename: Filename): FilePathRelative;
9
- static fromPartsSafe(directory: DirectoryPathRelativeType, filename: Filename): FilePathRelative;
10
- static fromString(candidate: string): FilePathRelative;
11
- get(): string;
12
- getDirectory(): DirectoryPathRelativeType;
13
- getFilename(): Filename;
14
- withDirectory(newDirectory: DirectoryPathRelativeType): FilePathRelative;
15
- withFilename(newFilename: Filename): FilePathRelative;
16
- toAbsolute(newDirectory: DirectoryPathAbsoluteType): FilePathAbsolute;
17
- }
18
- export declare class FilePathAbsolute {
19
- private readonly directory;
20
- private readonly filename;
21
- private constructor();
22
- static fromParts(directoryCandidate: string, filename: Filename): FilePathAbsolute;
23
- static fromPartsSafe(directory: DirectoryPathAbsoluteType, filename: Filename): FilePathAbsolute;
24
- static fromString(candidate: string): FilePathAbsolute;
25
- get(): string;
26
- getDirectory(): DirectoryPathAbsoluteType;
27
- getFilename(): Filename;
28
- withDirectory(newDirectory: DirectoryPathAbsoluteType): FilePathAbsolute;
29
- withFilename(newFilename: Filename): FilePathAbsolute;
30
- toRelative(newDirectory: DirectoryPathRelativeType): FilePathRelative;
31
- }
@@ -1,81 +0,0 @@
1
- import * as v from "valibot";
2
- import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
3
- import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
4
- import { FilePathAbsoluteSchema } from "./file-path-absolute-schema.vo";
5
- import { FilePathRelativeSchema } from "./file-path-relative-schema.vo";
6
- export class FilePathRelative {
7
- directory;
8
- filename;
9
- constructor(directory, filename) {
10
- this.directory = directory;
11
- this.filename = filename;
12
- }
13
- static fromParts(directoryCandidate, filename) {
14
- const directory = v.parse(DirectoryPathRelativeSchema, directoryCandidate);
15
- return new FilePathRelative(directory, filename);
16
- }
17
- static fromPartsSafe(directory, filename) {
18
- return new FilePathRelative(directory, filename);
19
- }
20
- static fromString(candidate) {
21
- const schema = v.parse(FilePathRelativeSchema, candidate);
22
- return new FilePathRelative(schema.directory, schema.filename);
23
- }
24
- get() {
25
- return `${this.directory}/${this.filename.get()}`;
26
- }
27
- getDirectory() {
28
- return this.directory;
29
- }
30
- getFilename() {
31
- return this.filename;
32
- }
33
- withDirectory(newDirectory) {
34
- return new FilePathRelative(newDirectory, this.filename);
35
- }
36
- withFilename(newFilename) {
37
- return new FilePathRelative(this.directory, newFilename);
38
- }
39
- toAbsolute(newDirectory) {
40
- return FilePathAbsolute.fromPartsSafe(newDirectory, this.filename);
41
- }
42
- }
43
- export class FilePathAbsolute {
44
- directory;
45
- filename;
46
- constructor(directory, filename) {
47
- this.directory = directory;
48
- this.filename = filename;
49
- }
50
- static fromParts(directoryCandidate, filename) {
51
- const directory = v.parse(DirectoryPathAbsoluteSchema, directoryCandidate);
52
- return new FilePathAbsolute(directory, filename);
53
- }
54
- static fromPartsSafe(directory, filename) {
55
- return new FilePathAbsolute(directory, filename);
56
- }
57
- static fromString(candidate) {
58
- const schema = v.parse(FilePathAbsoluteSchema, candidate);
59
- return new FilePathAbsolute(schema.directory, schema.filename);
60
- }
61
- get() {
62
- if (this.directory === "/")
63
- return `/${this.filename.get()}`;
64
- return `${this.directory}/${this.filename.get()}`;
65
- }
66
- getDirectory() {
67
- return this.directory;
68
- }
69
- getFilename() {
70
- return this.filename;
71
- }
72
- withDirectory(newDirectory) {
73
- return new FilePathAbsolute(newDirectory, this.filename);
74
- }
75
- withFilename(newFilename) {
76
- return new FilePathAbsolute(this.directory, newFilename);
77
- }
78
- toRelative(newDirectory) {
79
- return FilePathRelative.fromPartsSafe(newDirectory, this.filename);
80
- }
81
- }
@@ -1,13 +0,0 @@
1
- import * as v from "valibot";
2
- export declare enum FilenameAffixStrategy {
3
- prefix = "prefix",
4
- suffix = "suffix"
5
- }
6
- export declare const FilenameAffixError: {
7
- Type: string;
8
- Empty: string;
9
- TooLong: string;
10
- BadChars: string;
11
- };
12
- export declare const FilenameAffix: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 32, string>, v.RegexAction<string, string>, v.BrandAction<string, "FilenameAffix">]>;
13
- export type FilenameAffixType = v.InferOutput<typeof FilenameAffix>;