@atlantjs/arch 13.2.0 → 14.0.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 (52) hide show
  1. package/@tool-box/utils/convert-units/convert-units.d.ts +14 -5
  2. package/@tool-box/utils/convert-units/convert-units.js +100 -8
  3. package/@tool-box/utils/datatypes/boolean-utils.d.ts +7 -0
  4. package/@tool-box/utils/datatypes/boolean-utils.js +146 -4
  5. package/@tool-box/utils/datatypes/string-utils.d.ts +20 -4
  6. package/@tool-box/utils/datatypes/string-utils.js +300 -14
  7. package/@tool-box/utils/ducts/common.d.ts +49 -0
  8. package/@tool-box/utils/ducts/common.js +36 -3
  9. package/@tool-box/utils/ducts/optional-type.d.ts +85 -0
  10. package/@tool-box/utils/ducts/optional-type.js +79 -0
  11. package/@tool-box/utils/ducts/return-type.d.ts +17 -17
  12. package/@tool-box/utils/ducts/return-type.js +14 -4
  13. package/@tool-box/utils/http-provider/http-provider.d.ts +6 -0
  14. package/@tool-box/utils/http-provider/http-provider.js +43 -14
  15. package/@tool-box/utils/map/map.abstract.d.ts +39 -0
  16. package/@tool-box/utils/map/map.abstract.js +70 -6
  17. package/@tool-box/utils/random/random.d.ts +168 -0
  18. package/@tool-box/utils/random/random.js +235 -0
  19. package/@tool-box/utils/type-guard/guardian.d.ts +450 -7
  20. package/@tool-box/utils/type-guard/guardian.js +539 -35
  21. package/objects/@common/edges/cron-expression.edge.d.ts +30 -2
  22. package/objects/@common/edges/cron-expression.edge.js +77 -5
  23. package/objects/@common/edges/email.edge.d.ts +39 -1
  24. package/objects/@common/edges/email.edge.js +80 -2
  25. package/objects/@common/edges/ulid.sketch.edge.d.ts +48 -1
  26. package/objects/@common/edges/ulid.sketch.edge.js +75 -4
  27. package/objects/@common/edges/url.edge.d.ts +182 -0
  28. package/objects/@common/edges/url.edge.js +249 -0
  29. package/objects/@common/edges/username.edge.d.ts +9 -0
  30. package/objects/@common/edges/username.edge.js +34 -0
  31. package/objects/@common/edges/uuid.sketch.edge.d.ts +97 -1
  32. package/objects/@common/edges/uuid.sketch.edge.js +127 -6
  33. package/objects/amount/amount-value.edge.d.ts +42 -0
  34. package/objects/amount/amount-value.edge.js +76 -0
  35. package/objects/amount/amount.edge.d.ts +389 -11
  36. package/objects/amount/amount.edge.js +543 -4
  37. package/objects/datetime/edges/datetime.edge.d.ts +422 -4
  38. package/objects/datetime/edges/datetime.edge.js +538 -33
  39. package/objects/password/password.edge.d.ts +90 -0
  40. package/objects/password/password.edge.js +140 -6
  41. package/objects/primitives/boolean.edge.sketch.d.ts +105 -3
  42. package/objects/primitives/boolean.edge.sketch.js +132 -6
  43. package/objects/primitives/number.edge.sketch.d.ts +236 -0
  44. package/objects/primitives/number.edge.sketch.js +310 -24
  45. package/objects/primitives/string.edge.sketch.d.ts +148 -0
  46. package/objects/primitives/string.edge.sketch.js +191 -7
  47. package/objects/schedule/schedule.edge.d.ts +194 -0
  48. package/objects/schedule/schedule.edge.js +269 -2
  49. package/objects/time/time.edge.d.ts +285 -2
  50. package/objects/time/time.edge.js +385 -6
  51. package/package.json +1 -1
  52. package/tsconfig.tsbuildinfo +1 -1
@@ -1,16 +1,394 @@
1
1
  import { AmountPolygon } from "./amount.polygon";
2
- export declare class AmountEdge<UnitsPoint> {
2
+ export declare class AmountEdge<TUnitsPoint> {
3
3
  protected _value: number;
4
- protected _unit: UnitsPoint;
5
- constructor(_value: number, _unit: UnitsPoint);
4
+ protected _unit: TUnitsPoint;
5
+ constructor(_value: number, _unit: TUnitsPoint);
6
6
  get value(): number;
7
- get unit(): UnitsPoint;
8
- sum(amount: AmountEdge<UnitsPoint>): this;
9
- subtract(amount: AmountEdge<UnitsPoint>): this;
10
- divideBy(amount: AmountEdge<UnitsPoint> | number): this;
11
- multiplyBy(amount: AmountEdge<UnitsPoint> | number): this;
12
- changeUnit(unit: UnitsPoint): void;
13
- changeValue(value: number): void;
7
+ get unit(): TUnitsPoint;
8
+ /**
9
+ * Arredonda o valor para o inteiro mais próximo.
10
+ * @returns this para permitir encadeamento de métodos
11
+ * @example
12
+ * const amount = new AmountEdge(5.7, MassUnitPoint.gram);
13
+ * amount.round(); // valor agora é 6
14
+ */
15
+ round(): this;
16
+ /**
17
+ * Arredonda o valor para cima (sempre para o próximo inteiro maior).
18
+ * @returns this para permitir encadeamento de métodos
19
+ * @example
20
+ * const amount = new AmountEdge(5.2, MassUnitPoint.gram);
21
+ * amount.ceil(); // valor agora é 6
22
+ */
23
+ ceil(): this;
24
+ /**
25
+ * Arredonda o valor para baixo (sempre para o próximo inteiro menor).
26
+ * @returns this para permitir encadeamento de métodos
27
+ * @example
28
+ * const amount = new AmountEdge(5.9, MassUnitPoint.gram);
29
+ * amount.floor(); // valor agora é 5
30
+ */
31
+ floor(): this;
32
+ /**
33
+ * Arredonda o valor com uma precisão decimal específica.
34
+ * @param precision - Número de casas decimais desejadas
35
+ * @returns this para permitir encadeamento de métodos
36
+ * @example
37
+ * const amount = new AmountEdge(5.6789, MassUnitPoint.gram);
38
+ * amount.toFixed(2); // valor agora é 5.68
39
+ */
40
+ toFixed(precision: number): this;
41
+ /**
42
+ * Retorna o valor absoluto (sem sinal).
43
+ * @returns this para permitir encadeamento de métodos
44
+ * @example
45
+ * const amount = new AmountEdge(-5.5, MassUnitPoint.gram);
46
+ * amount.abs(); // valor agora é 5.5
47
+ */
48
+ abs(): this;
49
+ /**
50
+ * Compacta a quantidade para uma unidade mais apropriada baseado no valor.
51
+ * Por exemplo, 1000 gramas é convertido para 1 quilograma.
52
+ * @returns Nova instância com a unidade compactada
53
+ * @example
54
+ * const amount = new AmountEdge(1500, MassUnitPoint.gram);
55
+ * const compact = amount.compact(); // 1.5 kg
56
+ */
57
+ compact(): AmountEdge<TUnitsPoint>;
58
+ /**
59
+ * Soma outra quantidade ao valor atual.
60
+ * @param amount - Quantidade a ser somada
61
+ * @returns this para permitir encadeamento de métodos
62
+ * @example
63
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
64
+ * const amount2 = new AmountEdge(3, MassUnitPoint.gram);
65
+ * amount1.sum(amount2); // valor agora é 8
66
+ */
67
+ sum(amount: AmountEdge<TUnitsPoint>): this;
68
+ /**
69
+ * Subtrai outra quantidade do valor atual.
70
+ * @param amount - Quantidade a ser subtraída
71
+ * @returns this para permitir encadeamento de métodos
72
+ * @example
73
+ * const amount1 = new AmountEdge(8, MassUnitPoint.gram);
74
+ * const amount2 = new AmountEdge(3, MassUnitPoint.gram);
75
+ * amount1.subtract(amount2); // valor agora é 5
76
+ */
77
+ subtract(amount: AmountEdge<TUnitsPoint>): this;
78
+ /**
79
+ * Divide o valor por um número ou outra quantidade.
80
+ * @param amount - Divisor (número ou AmountEdge)
81
+ * @returns this para permitir encadeamento de métodos
82
+ * @example
83
+ * const amount = new AmountEdge(10, MassUnitPoint.gram);
84
+ * amount.divideBy(2); // valor agora é 5
85
+ * amount.divideBy(new AmountEdge(2, MassUnitPoint.gram)); // valor agora é 2.5
86
+ */
87
+ divideBy(amount: AmountEdge<TUnitsPoint> | number): this;
88
+ /**
89
+ * Multiplica o valor por um número ou outra quantidade.
90
+ * @param amount - Multiplicador (número ou AmountEdge)
91
+ * @returns this para permitir encadeamento de métodos
92
+ * @example
93
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
94
+ * amount.multiplyBy(2); // valor agora é 10
95
+ * amount.multiplyBy(new AmountEdge(3, MassUnitPoint.gram)); // valor agora é 30
96
+ */
97
+ multiplyBy(amount: AmountEdge<TUnitsPoint> | number): this;
98
+ /**
99
+ * Calcula o resto da divisão (módulo) do valor atual.
100
+ * @param amount - Divisor (número ou AmountEdge)
101
+ * @returns this para permitir encadeamento de métodos
102
+ * @example
103
+ * const amount = new AmountEdge(10, MassUnitPoint.gram);
104
+ * amount.modBy(3); // valor agora é 1
105
+ */
106
+ modBy(amount: AmountEdge<TUnitsPoint> | number): this;
107
+ /**
108
+ * Calcula a diferença absoluta entre esta quantidade e outra.
109
+ * @param amount - Quantidade para comparação
110
+ * @returns Nova instância com a diferença absoluta
111
+ * @example
112
+ * const amount1 = new AmountEdge(10, MassUnitPoint.gram);
113
+ * const amount2 = new AmountEdge(3, MassUnitPoint.gram);
114
+ * const diff = amount1.difference(amount2); // 7
115
+ */
116
+ difference(amount: AmountEdge<TUnitsPoint>): AmountEdge<TUnitsPoint>;
117
+ /**
118
+ * Aplica uma porcentagem sobre o valor atual.
119
+ * @param percentage - Porcentagem a aplicar (0-100)
120
+ * @returns this para permitir encadeamento de métodos
121
+ * @example
122
+ * const amount = new AmountEdge(100, MassUnitPoint.gram);
123
+ * amount.applyPercentage(20); // valor agora é 120 (100 + 20%)
124
+ */
125
+ applyPercentage(percentage: number): this;
126
+ /**
127
+ * Calcula a porcentagem que esta quantidade representa de um total.
128
+ * @param total - Quantidade total
129
+ * @returns Porcentagem como número (0-100)
130
+ * @example
131
+ * const amount = new AmountEdge(25, MassUnitPoint.gram);
132
+ * const total = new AmountEdge(100, MassUnitPoint.gram);
133
+ * const percentage = amount.percentageOf(total); // 25
134
+ */
135
+ percentageOf(total: AmountEdge<TUnitsPoint>): number;
136
+ /**
137
+ * Verifica se esta quantidade é igual a outra.
138
+ * @param amount - Quantidade para comparação
139
+ * @returns true se as quantidades são iguais (valor e unidade), false caso contrário
140
+ * @example
141
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
142
+ * const amount2 = new AmountEdge(5, MassUnitPoint.gram);
143
+ * amount1.isEqual(amount2); // true
144
+ */
145
+ isEqual(amount: AmountEdge<TUnitsPoint>): boolean;
146
+ /**
147
+ * Verifica se esta quantidade é diferente de outra.
148
+ * @param amount - Quantidade para comparação
149
+ * @returns true se as quantidades são diferentes, false caso contrário
150
+ * @example
151
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
152
+ * const amount2 = new AmountEdge(3, MassUnitPoint.gram);
153
+ * amount1.isDifferent(amount2); // true
154
+ */
155
+ isDifferent(amount: AmountEdge<TUnitsPoint>): boolean;
156
+ /**
157
+ * Verifica se esta quantidade é maior que outra.
158
+ * @param amount - Quantidade para comparação
159
+ * @returns true se this.value > amount.value, false caso contrário
160
+ * @example
161
+ * const amount1 = new AmountEdge(10, MassUnitPoint.gram);
162
+ * const amount2 = new AmountEdge(5, MassUnitPoint.gram);
163
+ * amount1.isGreaterThan(amount2); // true
164
+ */
165
+ isGreaterThan(amount: AmountEdge<TUnitsPoint>): boolean;
166
+ /**
167
+ * Verifica se esta quantidade é menor que outra.
168
+ * @param amount - Quantidade para comparação
169
+ * @returns true se this.value < amount.value, false caso contrário
170
+ * @example
171
+ * const amount1 = new AmountEdge(3, MassUnitPoint.gram);
172
+ * const amount2 = new AmountEdge(5, MassUnitPoint.gram);
173
+ * amount1.isLessThan(amount2); // true
174
+ */
175
+ isLessThan(amount: AmountEdge<TUnitsPoint>): boolean;
176
+ /**
177
+ * Verifica se esta quantidade é maior ou igual a outra.
178
+ * @param amount - Quantidade para comparação
179
+ * @returns true se this.value >= amount.value, false caso contrário
180
+ * @example
181
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
182
+ * const amount2 = new AmountEdge(5, MassUnitPoint.gram);
183
+ * amount1.isGreaterThanOrEqual(amount2); // true
184
+ */
185
+ isGreaterThanOrEqual(amount: AmountEdge<TUnitsPoint>): boolean;
186
+ /**
187
+ * Verifica se esta quantidade é menor ou igual a outra.
188
+ * @param amount - Quantidade para comparação
189
+ * @returns true se this.value <= amount.value, false caso contrário
190
+ * @example
191
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
192
+ * const amount2 = new AmountEdge(5, MassUnitPoint.gram);
193
+ * amount1.isLessThanOrEqual(amount2); // true
194
+ */
195
+ isLessThanOrEqual(amount: AmountEdge<TUnitsPoint>): boolean;
196
+ /**
197
+ * Verifica se esta quantidade está entre dois limites (inclusive).
198
+ * @param min - Quantidade mínima
199
+ * @param max - Quantidade máxima
200
+ * @returns true se o valor está entre min e max, false caso contrário
201
+ * @example
202
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
203
+ * const min = new AmountEdge(1, MassUnitPoint.gram);
204
+ * const max = new AmountEdge(10, MassUnitPoint.gram);
205
+ * amount.isBetween(min, max); // true
206
+ */
207
+ isBetween(min: AmountEdge<TUnitsPoint>, max: AmountEdge<TUnitsPoint>): boolean;
208
+ /**
209
+ * Verifica se o valor é zero.
210
+ * @returns true se this.value === 0, false caso contrário
211
+ * @example
212
+ * const amount = new AmountEdge(0, MassUnitPoint.gram);
213
+ * amount.isZero(); // true
214
+ */
215
+ isZero(): boolean;
216
+ /**
217
+ * Verifica se o valor é positivo (maior que zero).
218
+ * @returns true se this.value > 0, false caso contrário
219
+ * @example
220
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
221
+ * amount.isPositive(); // true
222
+ */
223
+ isPositive(): boolean;
224
+ /**
225
+ * Verifica se o valor é negativo (menor que zero).
226
+ * @returns true se this.value < 0, false caso contrário
227
+ * @example
228
+ * const amount = new AmountEdge(-5, MassUnitPoint.gram);
229
+ * amount.isNegative(); // true
230
+ */
231
+ isNegative(): boolean;
232
+ /**
233
+ * Verifica se a unidade é igual a uma unidade específica.
234
+ * @param unit - Unidade a comparar
235
+ * @returns true se a unidade é igual, false caso contrário
236
+ * @example
237
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
238
+ * amount.hasUnit(MassUnitPoint.gram); // true
239
+ * amount.hasUnit(MassUnitPoint.kilogram); // false
240
+ */
241
+ hasUnit(unit: TUnitsPoint): boolean;
242
+ /**
243
+ * Cria uma cópia independente desta quantidade.
244
+ * Útil para evitar mutações indesejadas.
245
+ * @returns Nova instância com os mesmos valores
246
+ * @example
247
+ * const amount1 = new AmountEdge(5, MassUnitPoint.gram);
248
+ * const amount2 = amount1.clone();
249
+ * amount2.multiplyBy(2); // amount1 continua 5, amount2 é 10
250
+ */
251
+ clone(): AmountEdge<TUnitsPoint>;
252
+ /**
253
+ * Retorna uma nova instância com o valor alterado.
254
+ * Mantém a imutabilidade da instância original.
255
+ * @param value - Novo valor
256
+ * @returns Nova instância com o valor alterado
257
+ * @example
258
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
259
+ * const newAmount = amount.withValue(10); // amount continua 5, newAmount é 10
260
+ */
261
+ withValue(value: number): AmountEdge<TUnitsPoint>;
262
+ /**
263
+ * Retorna uma nova instância com a unidade alterada.
264
+ * Mantém a imutabilidade da instância original.
265
+ * @param unit - Nova unidade
266
+ * @returns Nova instância com a unidade alterada
267
+ * @example
268
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
269
+ * const newAmount = amount.withUnit(MassUnitPoint.kilogram);
270
+ */
271
+ withUnit(unit: TUnitsPoint): AmountEdge<TUnitsPoint>;
272
+ /**
273
+ * Retorna uma representação em string da quantidade.
274
+ * @returns String no formato "valor unidade"
275
+ * @example
276
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
277
+ * amount.toString(); // "5 g"
278
+ */
14
279
  toString(): string;
15
- toPolygon(precision?: number): AmountPolygon<UnitsPoint>;
280
+ /**
281
+ * Formata a quantidade como string com separador de milhar e precisão decimal.
282
+ * @param locale - Localização para formatação (ex: 'en-US', 'pt-BR')
283
+ * @param precision - Número de casas decimais
284
+ * @returns String formatada
285
+ * @example
286
+ * const amount = new AmountEdge(1234.5678, MassUnitPoint.gram);
287
+ * amount.toFormattedString('pt-BR', 2); // "1.234,57 g"
288
+ */
289
+ toFormattedString(locale?: string, precision?: number): string;
290
+ /**
291
+ * Retorna apenas o valor como string com precisão específica.
292
+ * @param precision - Número de casas decimais
293
+ * @returns String do valor formatado
294
+ * @example
295
+ * const amount = new AmountEdge(5.6789, MassUnitPoint.gram);
296
+ * amount.toValueString(2); // "5.68"
297
+ */
298
+ toValueString(precision?: number): string;
299
+ /**
300
+ * Converte a quantidade para um objeto Polygon.
301
+ * @param precision - Número de casas decimais
302
+ * @returns Objeto polygon com valor e unidade
303
+ * @example
304
+ * const amount = new AmountEdge(5.6789, MassUnitPoint.gram);
305
+ * amount.toPolygon(2); // { value: 5.68, unit: MassUnitPoint.gram }
306
+ */
307
+ toPolygon(precision?: number): AmountPolygon<TUnitsPoint>;
308
+ /**
309
+ * Converte a quantidade para um objeto JSON.
310
+ * @returns Objeto JSON com value e unit
311
+ * @example
312
+ * const amount = new AmountEdge(5, MassUnitPoint.gram);
313
+ * amount.toJSON(); // { value: 5, unit: "g" }
314
+ */
315
+ toJSON(): {
316
+ value: number;
317
+ unit: TUnitsPoint;
318
+ };
319
+ /**
320
+ * Cria uma nova quantidade com valor zero.
321
+ * @template T - Tipo da unidade
322
+ * @param unit - Unidade da quantidade
323
+ * @returns Nova instância com valor zero
324
+ * @example
325
+ * const zero = AmountEdge.zero(MassUnitPoint.gram); // 0 g
326
+ */
327
+ static zero<T>(unit: T): AmountEdge<T>;
328
+ /**
329
+ * Soma uma lista de quantidades.
330
+ * @template T - Tipo da unidade
331
+ * @param amounts - Array de quantidades a somar
332
+ * @returns Nova instância com a soma total
333
+ * @example
334
+ * const amounts = [
335
+ * new AmountEdge(5, MassUnitPoint.gram),
336
+ * new AmountEdge(3, MassUnitPoint.gram),
337
+ * new AmountEdge(2, MassUnitPoint.gram),
338
+ * ];
339
+ * const total = AmountEdge.sumAll(amounts); // 10 g
340
+ */
341
+ static sumAll<T>(amounts: AmountEdge<T>[]): AmountEdge<T>;
342
+ /**
343
+ * Retorna a quantidade máxima de uma lista.
344
+ * @template T - Tipo da unidade
345
+ * @param amounts - Array de quantidades
346
+ * @returns Nova instância com o maior valor
347
+ * @example
348
+ * const amounts = [
349
+ * new AmountEdge(5, MassUnitPoint.gram),
350
+ * new AmountEdge(10, MassUnitPoint.gram),
351
+ * new AmountEdge(3, MassUnitPoint.gram),
352
+ * ];
353
+ * const max = AmountEdge.max(amounts); // 10 g
354
+ */
355
+ static max<T>(amounts: AmountEdge<T>[]): AmountEdge<T>;
356
+ /**
357
+ * Retorna a quantidade mínima de uma lista.
358
+ * @template T - Tipo da unidade
359
+ * @param amounts - Array de quantidades
360
+ * @returns Nova instância com o menor valor
361
+ * @example
362
+ * const amounts = [
363
+ * new AmountEdge(5, MassUnitPoint.gram),
364
+ * new AmountEdge(10, MassUnitPoint.gram),
365
+ * new AmountEdge(3, MassUnitPoint.gram),
366
+ * ];
367
+ * const min = AmountEdge.min(amounts); // 3 g
368
+ */
369
+ static min<T>(amounts: AmountEdge<T>[]): AmountEdge<T>;
370
+ /**
371
+ * Calcula a média de uma lista de quantidades.
372
+ * @template T - Tipo da unidade
373
+ * @param amounts - Array de quantidades
374
+ * @returns Nova instância com a média dos valores
375
+ * @example
376
+ * const amounts = [
377
+ * new AmountEdge(10, MassUnitPoint.gram),
378
+ * new AmountEdge(20, MassUnitPoint.gram),
379
+ * new AmountEdge(30, MassUnitPoint.gram),
380
+ * ];
381
+ * const average = AmountEdge.average(amounts); // 20 g
382
+ */
383
+ static average<T>(amounts: AmountEdge<T>[]): AmountEdge<T>;
384
+ /**
385
+ * Cria uma quantidade a partir de um objeto Polygon.
386
+ * @template T - Tipo da unidade
387
+ * @param polygon - Objeto polygon com value e unit
388
+ * @returns Nova instância de AmountEdge
389
+ * @example
390
+ * const polygon = { value: 5, unit: MassUnitPoint.gram };
391
+ * const amount = AmountEdge.fromPolygon(polygon); // 5 g
392
+ */
393
+ static fromPolygon<T>(polygon: AmountPolygon<T>): AmountEdge<T>;
16
394
  }