@atlantjs/arch 15.6.7 → 15.7.0

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 (106) hide show
  1. package/index.js +60 -0
  2. package/package.json +4 -3
  3. package/{tsconfig.tsbuildinfo → tsconfig.build.tsbuildinfo} +1 -1
  4. package/src/@tool-box/tests/builder.abstract.util.js +0 -39
  5. package/src/@tool-box/tests/builders/datetime/datetime.edge.builder.js +0 -15
  6. package/src/@tool-box/tests/builders/failures/dummies/failure.dummy.js +0 -13
  7. package/src/@tool-box/tests/builders/failures/failure.builder.js +0 -17
  8. package/src/@tool-box/tests/builders/metadata/metadata-uv.builder.js +0 -18
  9. package/src/@tool-box/tests/builders/metadata/metadata.edge.builder.js +0 -15
  10. package/src/@tool-box/tests/builders/user/email.edge.builder.js +0 -15
  11. package/src/@tool-box/tests/builders/user/username.edge.builder.js +0 -15
  12. package/src/@tool-box/tests/faker/faker.js +0 -208
  13. package/src/@tool-box/utils/convert-units/convert-units.js +0 -154
  14. package/src/@tool-box/utils/datatypes/boolean-utils.js +0 -155
  15. package/src/@tool-box/utils/datatypes/generic-types.js +0 -3
  16. package/src/@tool-box/utils/datatypes/plainify.js +0 -2
  17. package/src/@tool-box/utils/datatypes/string-utils.js +0 -292
  18. package/src/@tool-box/utils/datetime/mappers/month.mapper.js +0 -58
  19. package/src/@tool-box/utils/datetime/mappers/points/month-abbreviation.enum.js +0 -18
  20. package/src/@tool-box/utils/datetime/mappers/points/month-number.enum.js +0 -18
  21. package/src/@tool-box/utils/ducts/common.js +0 -47
  22. package/src/@tool-box/utils/ducts/optional-type.js +0 -128
  23. package/src/@tool-box/utils/ducts/return-type.js +0 -67
  24. package/src/@tool-box/utils/http-provider/http-provider-failure-response.js +0 -19
  25. package/src/@tool-box/utils/http-provider/http-provider-success-response.js +0 -20
  26. package/src/@tool-box/utils/http-provider/http-provider.js +0 -85
  27. package/src/@tool-box/utils/logger/index.js +0 -31
  28. package/src/@tool-box/utils/map/map.abstract.js +0 -84
  29. package/src/@tool-box/utils/random/random.js +0 -260
  30. package/src/@tool-box/utils/type-guard/guardian-exception.js +0 -6
  31. package/src/@tool-box/utils/type-guard/guardian.js +0 -625
  32. package/src/@tool-box/utils/type-guard/guardian.type.js +0 -2
  33. package/src/@tool-box/utils/validators/is-cron-expression.js +0 -39
  34. package/src/@tool-box/utils/validators/is-date-string.js +0 -42
  35. package/src/@tool-box/utils/validators/is-password-match.js +0 -27
  36. package/src/@tool-box/utils/validators/is-password-policy.validator.js +0 -30
  37. package/src/@tool-box/utils/validators/is-schedule.js +0 -43
  38. package/src/@tool-box/utils/validators/is-time-string.js +0 -39
  39. package/src/@tool-box/utils/validators/is-ulid.js +0 -39
  40. package/src/index.js +0 -179
  41. package/src/objects/@common/edges/email.edge.js +0 -94
  42. package/src/objects/@common/edges/ulid.sketch.edge.js +0 -91
  43. package/src/objects/@common/edges/url.edge.js +0 -269
  44. package/src/objects/@common/edges/username.edge.js +0 -41
  45. package/src/objects/@common/edges/uuid.sketch.edge.js +0 -145
  46. package/src/objects/@common/points/environment.point.js +0 -10
  47. package/src/objects/@common/points/header-token-name.point.js +0 -10
  48. package/src/objects/@common/points/http-status-codes.point.js +0 -244
  49. package/src/objects/amount/amount-value.edge.js +0 -76
  50. package/src/objects/amount/amount.edge.js +0 -626
  51. package/src/objects/amount/amount.polygon.js +0 -2
  52. package/src/objects/amount/amount.uv.js +0 -29
  53. package/src/objects/amount/points/duration-unit.point.js +0 -15
  54. package/src/objects/amount/points/energy-unit.point.js +0 -10
  55. package/src/objects/amount/points/length-unit.point.js +0 -10
  56. package/src/objects/amount/points/mass-unit.point.js +0 -11
  57. package/src/objects/amount/points/month-name.point.js +0 -18
  58. package/src/objects/amount/points/object-unit.point.js +0 -7
  59. package/src/objects/amount/points/units.point.js +0 -2
  60. package/src/objects/amount/points/volume-unit.point.js +0 -8
  61. package/src/objects/amount/points/week-day.point.js +0 -13
  62. package/src/objects/datetime/edges/datetime.edge.js +0 -672
  63. package/src/objects/datetime/edges/locale/day/day-name-to-english.mapper.js +0 -19
  64. package/src/objects/datetime/edges/locale/day/day-name-to-portuguese.mapper.js +0 -19
  65. package/src/objects/datetime/edges/locale/day/today-to-language.mapper.js +0 -15
  66. package/src/objects/datetime/edges/locale/holidays-country.type.js +0 -2
  67. package/src/objects/datetime/edges/locale/month/month-to-english.mapper.js +0 -24
  68. package/src/objects/datetime/edges/locale/month/month-to-portuguese.mapper.js +0 -24
  69. package/src/objects/datetime/points/month-name.enum.js +0 -18
  70. package/src/objects/datetime/points/week-day.enum.js +0 -13
  71. package/src/objects/failure/edges/failure.abstract.js +0 -24
  72. package/src/objects/failure/edges/failure.abstract.polygon.js +0 -2
  73. package/src/objects/language/points/language.point.js +0 -135
  74. package/src/objects/metadata/metadata.edge.js +0 -25
  75. package/src/objects/metadata/metadata.polygon.js +0 -2
  76. package/src/objects/metadata/metadata.uv.js +0 -29
  77. package/src/objects/password/password.edge.js +0 -175
  78. package/src/objects/password/password.polygon.js +0 -2
  79. package/src/objects/password/steps/not-allowing-consecutive-chars-step.js +0 -34
  80. package/src/objects/password/steps/not-allowing-date-step.js +0 -61
  81. package/src/objects/password/steps/not-allowing-phone-step.js +0 -27
  82. package/src/objects/password/steps/not-allowing-repeated-chars-step.js +0 -34
  83. package/src/objects/password/steps/not-allowing-string-step.js +0 -19
  84. package/src/objects/password/steps/not-allowing-these-chars-step.js +0 -17
  85. package/src/objects/password/steps/numeric-step.js +0 -13
  86. package/src/objects/password/steps/with-at-least-one-letter-step.js +0 -14
  87. package/src/objects/password/steps/with-at-least-one-number-digit-step.js +0 -14
  88. package/src/objects/password/steps/with-at-least-one-special-char-step.js +0 -14
  89. package/src/objects/password/steps/with-length-step.js +0 -18
  90. package/src/objects/password/validation-step.js +0 -9
  91. package/src/objects/password/validation-step.type.js +0 -2
  92. package/src/objects/primitives/boolean.edge.sketch.js +0 -147
  93. package/src/objects/primitives/datetime.edge.sketch.js +0 -7
  94. package/src/objects/primitives/number.edge.sketch.js +0 -346
  95. package/src/objects/primitives/string.edge.sketch.js +0 -218
  96. package/src/objects/scheduling/scheduling.edge.failure.js +0 -14
  97. package/src/objects/scheduling/scheduling.edge.js +0 -280
  98. package/src/objects/time/time.edge.js +0 -447
  99. package/src/objects-interface/edges/edge.abstract.js +0 -6
  100. package/src/objects-interface/face.abstract.js +0 -6
  101. package/src/objects-interface/solid.abstract.js +0 -11
  102. package/src/objects-interface/uv.abstract.js +0 -6
  103. package/src/objects-interface/vertices/vertex.abstract.js +0 -11
  104. package/src/shared/payload.abstract.js +0 -6
  105. package/src/shared/request.abstract.js +0 -3
  106. package/src/shared/response.abstract.js +0 -6
@@ -1,447 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TimeEdge = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const guardian_1 = require("#/@tool-box/utils/type-guard/guardian");
9
- const scheduling_edge_1 = require("#/objects/scheduling/scheduling.edge");
10
- class TimeEdge {
11
- constructor(value) {
12
- this.value = value;
13
- this.validate();
14
- }
15
- // ==================== Getters ====================
16
- /**
17
- * Retorna as horas do tempo como número inteiro.
18
- * @returns Número inteiro representando as horas (0-23)
19
- * @example
20
- * new TimeEdge("14:30").getHours() // 14
21
- * new TimeEdge("08:00").getHours() // 8
22
- */
23
- getHours(in12HourFormat = false) {
24
- if (in12HourFormat.falsy()) {
25
- return Number(this.value.split(":")[0]);
26
- }
27
- return Number(this.toFormat12h().split(" ")[0]);
28
- }
29
- /**
30
- * Retorna os minutos do tempo como número inteiro.
31
- * @returns Número inteiro representando os minutos (0-59)
32
- * @example
33
- * new TimeEdge("14:30").getMinutes() // 30
34
- * new TimeEdge("08:05").getMinutes() // 5
35
- */
36
- getMinutes() {
37
- return Number(this.value.split(":")[1]);
38
- }
39
- /**
40
- * Retorna o tempo total convertido em minutos.
41
- * @returns Total de minutos representados pelo tempo
42
- * @example
43
- * new TimeEdge("01:30").toTotalMinutes() // 90
44
- * new TimeEdge("02:00").toTotalMinutes() // 120
45
- */
46
- toTotalMinutes() {
47
- return this.getHours() * 60 + this.getMinutes();
48
- }
49
- fromScheduling(date) {
50
- let scheduledFor;
51
- if (guardian_1._.isNotUndefined(date)) {
52
- const minute = date.getMinutes();
53
- const hour = date.getHours();
54
- const day = date.getDate();
55
- const month = date.getMonth() + 1;
56
- const dayOfWeek = date.getDay();
57
- const cron = `${minute} ${hour} ${day} ${month} ${dayOfWeek}`;
58
- scheduledFor = new scheduling_edge_1.SchedulingEdge(cron);
59
- }
60
- else {
61
- const minute = this.getMinutes();
62
- const hour = this.getHours();
63
- const cron = `${minute} ${hour} * * *`;
64
- scheduledFor = new scheduling_edge_1.SchedulingEdge(cron);
65
- }
66
- return scheduledFor;
67
- }
68
- /**
69
- * Retorna o tempo total convertido em segundos.
70
- * @returns Total de segundos representados pelo tempo
71
- * @example
72
- * new TimeEdge("00:01").toTotalSeconds() // 60
73
- * new TimeEdge("01:00").toTotalSeconds() // 3600
74
- */
75
- toTotalSeconds() {
76
- return this.toTotalMinutes() * 60;
77
- }
78
- // ==================== Operações Aritméticas ====================
79
- /**
80
- * Subtrai um tempo de outro e retorna uma nova instância.
81
- * @param time - Tempo a ser subtraído do valor atual
82
- * @returns Nova instância de TimeEdge com o resultado da subtração
83
- * @example
84
- * new TimeEdge("10:30").subtract(new TimeEdge("01:00")) // TimeEdge("09:30")
85
- * new TimeEdge("08:15").subtract(new TimeEdge("00:30")) // TimeEdge("07:45")
86
- */
87
- subtract(time) {
88
- const momentTime = (0, moment_1.default)()
89
- .hours(this.getHours())
90
- .minutes(this.getMinutes());
91
- return new TimeEdge(momentTime.clone().subtract(time.toString()).format("HH:mm"));
92
- }
93
- /**
94
- * Soma um tempo ao valor atual e retorna uma nova instância.
95
- * @param time - Tempo a ser somado ao valor atual
96
- * @returns Nova instância de TimeEdge com o resultado da soma
97
- * @example
98
- * new TimeEdge("08:30").add(new TimeEdge("01:00")) // TimeEdge("09:30")
99
- * new TimeEdge("23:30").add(new TimeEdge("01:00")) // TimeEdge("00:30")
100
- */
101
- add(time) {
102
- const momentTime = (0, moment_1.default)()
103
- .hours(this.getHours())
104
- .minutes(this.getMinutes());
105
- return new TimeEdge(momentTime.clone().add(time.toString()).format("HH:mm"));
106
- }
107
- /**
108
- * Calcula a diferença absoluta entre dois tempos.
109
- * @param time - Tempo para calcular a diferença
110
- * @returns Nova instância de TimeEdge com a diferença absoluta
111
- * @example
112
- * new TimeEdge("10:00").difference(new TimeEdge("08:30")) // TimeEdge("01:30")
113
- * new TimeEdge("08:30").difference(new TimeEdge("10:00")) // TimeEdge("01:30")
114
- */
115
- difference(time) {
116
- const diffMinutes = Math.abs(this.toTotalMinutes() - time.toTotalMinutes());
117
- const hours = Math.floor(diffMinutes / 60)
118
- .toString()
119
- .padStart(2, "0");
120
- const minutes = (diffMinutes % 60).toString().padStart(2, "0");
121
- return new TimeEdge(`${hours}:${minutes}`);
122
- }
123
- /**
124
- * Multiplica o tempo por um fator numérico e retorna uma nova instância.
125
- * @param factor - Fator de multiplicação
126
- * @returns Nova instância de TimeEdge com o tempo multiplicado
127
- * @example
128
- * new TimeEdge("01:30").multiply(2) // TimeEdge("03:00")
129
- * new TimeEdge("00:20").multiply(3) // TimeEdge("01:00")
130
- */
131
- multiply(factor) {
132
- const totalMinutes = Math.round(this.toTotalMinutes() * factor);
133
- const hours = Math.floor(totalMinutes / 60)
134
- .toString()
135
- .padStart(2, "0");
136
- const minutes = (totalMinutes % 60).toString().padStart(2, "0");
137
- return new TimeEdge(`${hours}:${minutes}`);
138
- }
139
- // ==================== Comparações ====================
140
- /**
141
- * Verifica se este tempo é igual a outro.
142
- * @param time - Tempo para comparação
143
- * @returns true se os tempos são iguais, false caso contrário
144
- * @example
145
- * new TimeEdge("10:30").isEqual(new TimeEdge("10:30")) // true
146
- * new TimeEdge("10:30").isEqual(new TimeEdge("10:00")) // false
147
- */
148
- isEqual(time) {
149
- return this.value === time.toString();
150
- }
151
- /**
152
- * Verifica se este tempo é diferente de outro.
153
- * @param time - Tempo para comparação
154
- * @returns true se os tempos são diferentes, false caso contrário
155
- * @example
156
- * new TimeEdge("10:30").isDifferent(new TimeEdge("09:00")) // true
157
- * new TimeEdge("10:30").isDifferent(new TimeEdge("10:30")) // false
158
- */
159
- isDifferent(time) {
160
- return !this.isEqual(time);
161
- }
162
- /**
163
- * Verifica se este tempo é maior que outro.
164
- * @param time - Tempo para comparação
165
- * @returns true se this > time, false caso contrário
166
- * @example
167
- * new TimeEdge("10:30").isGreaterThan(new TimeEdge("09:00")) // true
168
- * new TimeEdge("08:00").isGreaterThan(new TimeEdge("10:00")) // false
169
- */
170
- isGreaterThan(time) {
171
- return this.toTotalMinutes() > time.toTotalMinutes();
172
- }
173
- /**
174
- * Verifica se este tempo é menor que outro.
175
- * @param time - Tempo para comparação
176
- * @returns true se this < time, false caso contrário
177
- * @example
178
- * new TimeEdge("08:00").isLessThan(new TimeEdge("10:00")) // true
179
- * new TimeEdge("10:30").isLessThan(new TimeEdge("09:00")) // false
180
- */
181
- isLessThan(time) {
182
- return this.toTotalMinutes() < time.toTotalMinutes();
183
- }
184
- /**
185
- * Verifica se este tempo é maior ou igual a outro.
186
- * @param time - Tempo para comparação
187
- * @returns true se this >= time, false caso contrário
188
- * @example
189
- * new TimeEdge("10:30").isGreaterThanOrEqual(new TimeEdge("10:30")) // true
190
- * new TimeEdge("10:30").isGreaterThanOrEqual(new TimeEdge("09:00")) // true
191
- */
192
- isGreaterThanOrEqual(time) {
193
- return this.toTotalMinutes() >= time.toTotalMinutes();
194
- }
195
- /**
196
- * Verifica se este tempo é menor ou igual a outro.
197
- * @param time - Tempo para comparação
198
- * @returns true se this <= time, false caso contrário
199
- * @example
200
- * new TimeEdge("08:00").isLessThanOrEqual(new TimeEdge("08:00")) // true
201
- * new TimeEdge("08:00").isLessThanOrEqual(new TimeEdge("10:00")) // true
202
- */
203
- isLessThanOrEqual(time) {
204
- return this.toTotalMinutes() <= time.toTotalMinutes();
205
- }
206
- /**
207
- * Verifica se este tempo está entre dois limites (inclusive).
208
- * @param start - Tempo mínimo do intervalo
209
- * @param end - Tempo máximo do intervalo
210
- * @returns true se o tempo está entre start e end, false caso contrário
211
- * @example
212
- * new TimeEdge("10:00").isBetween(new TimeEdge("08:00"), new TimeEdge("12:00")) // true
213
- * new TimeEdge("14:00").isBetween(new TimeEdge("08:00"), new TimeEdge("12:00")) // false
214
- */
215
- isBetween(start, end) {
216
- return this.isGreaterThanOrEqual(start) && this.isLessThanOrEqual(end);
217
- }
218
- // ==================== Validações ====================
219
- /**
220
- * Verifica se o tempo representa meia-noite (00:00).
221
- * @returns true se o tempo é 00:00, false caso contrário
222
- * @example
223
- * new TimeEdge("00:00").isMidnight() // true
224
- * new TimeEdge("12:00").isMidnight() // false
225
- */
226
- isMidnight() {
227
- return this.value === "00:00";
228
- }
229
- /**
230
- * Verifica se o tempo representa o meio-dia (12:00).
231
- * @returns true se o tempo é 12:00, false caso contrário
232
- * @example
233
- * new TimeEdge("12:00").isNoon() // true
234
- * new TimeEdge("00:00").isNoon() // false
235
- */
236
- isNoon() {
237
- return this.value === "12:00";
238
- }
239
- /**
240
- * Verifica se o tempo está no período da manhã (00:00 até 11:59).
241
- * @returns true se o tempo é anterior às 12:00, false caso contrário
242
- * @example
243
- * new TimeEdge("09:00").isMorning() // true
244
- * new TimeEdge("13:00").isMorning() // false
245
- */
246
- isMorning() {
247
- return this.getHours() < 12;
248
- }
249
- /**
250
- * Verifica se o tempo está no período da tarde (12:00 até 17:59).
251
- * @returns true se o tempo está entre 12:00 e 17:59, false caso contrário
252
- * @example
253
- * new TimeEdge("14:00").isAfternoon() // true
254
- * new TimeEdge("20:00").isAfternoon() // false
255
- */
256
- isAfternoon() {
257
- return this.getHours() >= 12 && this.getHours() < 18;
258
- }
259
- /**
260
- * Verifica se o tempo está no período da noite (18:00 até 23:59).
261
- * @returns true se o tempo é a partir das 18:00, false caso contrário
262
- * @example
263
- * new TimeEdge("20:00").isEvening() // true
264
- * new TimeEdge("14:00").isEvening() // false
265
- */
266
- isEvening() {
267
- return this.getHours() >= 18;
268
- }
269
- // ==================== Clonagem e Imutabilidade ====================
270
- /**
271
- * Cria uma cópia independente desta instância de TimeEdge.
272
- * @returns Nova instância com o mesmo valor de tempo
273
- * @example
274
- * const time1 = new TimeEdge("10:30");
275
- * const time2 = time1.clone(); // instância independente com "10:30"
276
- */
277
- clone() {
278
- return new TimeEdge(this.value);
279
- }
280
- /**
281
- * Retorna uma nova instância com as horas alteradas.
282
- * @param hours - Novo valor de horas (0-23)
283
- * @returns Nova instância com as horas alteradas
284
- * @example
285
- * new TimeEdge("10:30").withHours(15) // TimeEdge("15:30")
286
- */
287
- withHours(hours) {
288
- const paddedHours = hours.toString().padStart(2, "0");
289
- const paddedMinutes = this.getMinutes().toString().padStart(2, "0");
290
- return new TimeEdge(`${paddedHours}:${paddedMinutes}`);
291
- }
292
- /**
293
- * Retorna uma nova instância com os minutos alterados.
294
- * @param minutes - Novo valor de minutos (0-59)
295
- * @returns Nova instância com os minutos alterados
296
- * @example
297
- * new TimeEdge("10:30").withMinutes(45) // TimeEdge("10:45")
298
- */
299
- withMinutes(minutes) {
300
- const paddedHours = this.getHours().toString().padStart(2, "0");
301
- const paddedMinutes = minutes.toString().padStart(2, "0");
302
- return new TimeEdge(`${paddedHours}:${paddedMinutes}`);
303
- }
304
- // ==================== Formatação ====================
305
- /**
306
- * Retorna o tempo como string no formato HH:mm.
307
- * @returns String no formato "HH:mm"
308
- * @example
309
- * new TimeEdge("14:30").toString() // "14:30"
310
- */
311
- toString() {
312
- return this.value;
313
- }
314
- /**
315
- * Retorna o tempo no formato de 12 horas com AM/PM.
316
- * @returns String no formato "hh:mm AM/PM"
317
- * @example
318
- * new TimeEdge("14:30").toFormat12h() // "02:30 PM"
319
- * new TimeEdge("08:00").toFormat12h() // "08:00 AM"
320
- */
321
- toFormat12h() {
322
- const hours = this.getHours();
323
- const minutes = this.getMinutes().toString().padStart(2, "0");
324
- const period = hours >= 12 ? "PM" : "AM";
325
- const formattedHours = (hours % 12 || 12).toString().padStart(2, "0");
326
- return `${formattedHours}:${minutes} ${period}`;
327
- }
328
- /**
329
- * Retorna uma representação legível do tempo em horas e minutos por extenso.
330
- * @returns String descritiva no formato "Xh Ym"
331
- * @example
332
- * new TimeEdge("14:30").toReadableString() // "14h 30m"
333
- * new TimeEdge("08:05").toReadableString() // "8h 5m"
334
- */
335
- toReadableString() {
336
- return `${this.getHours()}h ${this.getMinutes()}m`;
337
- }
338
- // ==================== Métodos Estáticos ====================
339
- /**
340
- * Cria um TimeEdge representando a hora atual do sistema.
341
- * @returns Nova instância com o horário atual no formato HH:mm
342
- * @example
343
- * TimeEdge.now() // pode retornar TimeEdge("14:35") dependendo da hora atual
344
- */
345
- static now() {
346
- return new TimeEdge((0, moment_1.default)().format("HH:mm"));
347
- }
348
- /**
349
- * Cria um TimeEdge representando a meia-noite (00:00).
350
- * @returns Nova instância com o valor "00:00"
351
- * @example
352
- * TimeEdge.midnight() // TimeEdge("00:00")
353
- */
354
- static midnight() {
355
- return new TimeEdge("00:00");
356
- }
357
- /**
358
- * Cria um TimeEdge representando o meio-dia (12:00).
359
- * @returns Nova instância com o valor "12:00"
360
- * @example
361
- * TimeEdge.noon() // TimeEdge("12:00")
362
- */
363
- static noon() {
364
- return new TimeEdge("12:00");
365
- }
366
- /**
367
- * Cria um TimeEdge a partir de um total de minutos.
368
- * @param totalMinutes - Total de minutos a converter para HH:mm
369
- * @returns Nova instância com o tempo correspondente ao total de minutos
370
- * @example
371
- * TimeEdge.fromMinutes(90) // TimeEdge("01:30")
372
- * TimeEdge.fromMinutes(125) // TimeEdge("02:05")
373
- */
374
- static fromMinutes(totalMinutes) {
375
- const hours = Math.floor(totalMinutes / 60)
376
- .toString()
377
- .padStart(2, "0");
378
- const minutes = (totalMinutes % 60).toString().padStart(2, "0");
379
- return new TimeEdge(`${hours}:${minutes}`);
380
- }
381
- /**
382
- * Retorna o maior tempo de uma lista.
383
- * @param times - Array de instâncias de TimeEdge para comparação
384
- * @returns A instância com o maior valor de tempo
385
- * @throws {Error} Se o array estiver vazio
386
- * @example
387
- * TimeEdge.max([new TimeEdge("08:00"), new TimeEdge("14:30"), new TimeEdge("10:00")])
388
- * // TimeEdge("14:30")
389
- */
390
- static max(times) {
391
- if (times.length === 0) {
392
- throw new Error("Cannot find max of an empty array of times.");
393
- }
394
- return times.reduce((max, time) => (time.isGreaterThan(max) ? time : max));
395
- }
396
- /**
397
- * Retorna o menor tempo de uma lista.
398
- * @param times - Array de instâncias de TimeEdge para comparação
399
- * @returns A instância com o menor valor de tempo
400
- * @throws {Error} Se o array estiver vazio
401
- * @example
402
- * TimeEdge.min([new TimeEdge("08:00"), new TimeEdge("14:30"), new TimeEdge("10:00")])
403
- * // TimeEdge("08:00")
404
- */
405
- static min(times) {
406
- if (times.length === 0) {
407
- throw new Error("Cannot find min of an empty array of times.");
408
- }
409
- return times.reduce((min, time) => (time.isLessThan(min) ? time : min));
410
- }
411
- /**
412
- * Soma uma lista de tempos e retorna o total.
413
- * @param times - Array de instâncias de TimeEdge para somar
414
- * @returns Nova instância com a soma total dos tempos
415
- * @throws {Error} Se o array estiver vazio
416
- * @example
417
- * TimeEdge.sumAll([new TimeEdge("01:00"), new TimeEdge("02:30"), new TimeEdge("00:15")])
418
- * // TimeEdge("03:45")
419
- */
420
- static sumAll(times) {
421
- if (times.length === 0) {
422
- throw new Error("Cannot sum an empty array of times.");
423
- }
424
- const totalMinutes = times.reduce((sum, time) => sum + time.toTotalMinutes(), 0);
425
- return TimeEdge.fromMinutes(totalMinutes);
426
- }
427
- // ==================== Privados ====================
428
- /**
429
- * Valida o formato do tempo informado no construtor.
430
- * @throws {Error} Se o formato não for HH:mm válido
431
- */
432
- validate() {
433
- if (!this.isValidTimeFormat(this.value)) {
434
- throw new Error("Invalid time format. Please provide time in 'HH:mm' format.");
435
- }
436
- }
437
- /**
438
- * Verifica se uma string está no formato de tempo HH:mm válido.
439
- * @param value - String a ser validada
440
- * @returns true se o formato é válido, false caso contrário
441
- */
442
- isValidTimeFormat(value) {
443
- const regex = /^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/;
444
- return regex.test(value);
445
- }
446
- }
447
- exports.TimeEdge = TimeEdge;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EdgeAbstract = void 0;
4
- class EdgeAbstract {
5
- }
6
- exports.EdgeAbstract = EdgeAbstract;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FaceAbstract = void 0;
4
- class FaceAbstract {
5
- }
6
- exports.FaceAbstract = FaceAbstract;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolidAbstract = void 0;
4
- const metadata_edge_1 = require("#/objects/metadata/metadata.edge");
5
- class SolidAbstract {
6
- constructor(_id, _metadata = new metadata_edge_1.MetadataEdge()) {
7
- this._id = _id;
8
- this._metadata = _metadata;
9
- }
10
- }
11
- exports.SolidAbstract = SolidAbstract;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UvAbstract = void 0;
4
- class UvAbstract {
5
- }
6
- exports.UvAbstract = UvAbstract;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VertexAbstract = void 0;
4
- const metadata_edge_1 = require("#/objects/metadata/metadata.edge");
5
- class VertexAbstract {
6
- constructor(_id, _metadata = new metadata_edge_1.MetadataEdge()) {
7
- this._id = _id;
8
- this._metadata = _metadata;
9
- }
10
- }
11
- exports.VertexAbstract = VertexAbstract;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PayloadAbstract = void 0;
4
- class PayloadAbstract {
5
- }
6
- exports.PayloadAbstract = PayloadAbstract;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const header_token_name_point_1 = require("#/objects/@common/points/header-token-name.point");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseAbstract = void 0;
4
- class ResponseAbstract {
5
- }
6
- exports.ResponseAbstract = ResponseAbstract;