@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.
- package/@tool-box/utils/convert-units/convert-units.d.ts +14 -5
- package/@tool-box/utils/convert-units/convert-units.js +100 -8
- package/@tool-box/utils/datatypes/boolean-utils.d.ts +7 -0
- package/@tool-box/utils/datatypes/boolean-utils.js +146 -4
- package/@tool-box/utils/datatypes/string-utils.d.ts +20 -4
- package/@tool-box/utils/datatypes/string-utils.js +300 -14
- package/@tool-box/utils/ducts/common.d.ts +49 -0
- package/@tool-box/utils/ducts/common.js +36 -3
- package/@tool-box/utils/ducts/optional-type.d.ts +85 -0
- package/@tool-box/utils/ducts/optional-type.js +79 -0
- package/@tool-box/utils/ducts/return-type.d.ts +17 -17
- package/@tool-box/utils/ducts/return-type.js +14 -4
- package/@tool-box/utils/http-provider/http-provider.d.ts +6 -0
- package/@tool-box/utils/http-provider/http-provider.js +43 -14
- package/@tool-box/utils/map/map.abstract.d.ts +39 -0
- package/@tool-box/utils/map/map.abstract.js +70 -6
- package/@tool-box/utils/random/random.d.ts +168 -0
- package/@tool-box/utils/random/random.js +235 -0
- package/@tool-box/utils/type-guard/guardian.d.ts +450 -7
- package/@tool-box/utils/type-guard/guardian.js +539 -35
- package/objects/@common/edges/cron-expression.edge.d.ts +30 -2
- package/objects/@common/edges/cron-expression.edge.js +77 -5
- package/objects/@common/edges/email.edge.d.ts +39 -1
- package/objects/@common/edges/email.edge.js +80 -2
- package/objects/@common/edges/ulid.sketch.edge.d.ts +48 -1
- package/objects/@common/edges/ulid.sketch.edge.js +75 -4
- package/objects/@common/edges/url.edge.d.ts +182 -0
- package/objects/@common/edges/url.edge.js +249 -0
- package/objects/@common/edges/username.edge.d.ts +9 -0
- package/objects/@common/edges/username.edge.js +34 -0
- package/objects/@common/edges/uuid.sketch.edge.d.ts +97 -1
- package/objects/@common/edges/uuid.sketch.edge.js +127 -6
- package/objects/amount/amount-value.edge.d.ts +42 -0
- package/objects/amount/amount-value.edge.js +76 -0
- package/objects/amount/amount.edge.d.ts +389 -11
- package/objects/amount/amount.edge.js +543 -4
- package/objects/datetime/edges/datetime.edge.d.ts +422 -4
- package/objects/datetime/edges/datetime.edge.js +538 -33
- package/objects/password/password.edge.d.ts +90 -0
- package/objects/password/password.edge.js +140 -6
- package/objects/primitives/boolean.edge.sketch.d.ts +105 -3
- package/objects/primitives/boolean.edge.sketch.js +132 -6
- package/objects/primitives/number.edge.sketch.d.ts +236 -0
- package/objects/primitives/number.edge.sketch.js +310 -24
- package/objects/primitives/string.edge.sketch.d.ts +148 -0
- package/objects/primitives/string.edge.sketch.js +191 -7
- package/objects/schedule/schedule.edge.d.ts +194 -0
- package/objects/schedule/schedule.edge.js +269 -2
- package/objects/time/time.edge.d.ts +285 -2
- package/objects/time/time.edge.js +385 -6
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -7,17 +7,89 @@ exports.CronExpressionEdge = void 0;
|
|
|
7
7
|
const cron_parser_1 = __importDefault(require("cron-parser"));
|
|
8
8
|
const string_edge_sketch_1 = require("../../primitives/string.edge.sketch");
|
|
9
9
|
class CronExpressionEdge extends string_edge_sketch_1.StringEdgeSketch {
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
constructor(expression) {
|
|
11
|
+
// normaliza espaços múltiplos para evitar inconsistência de validação
|
|
12
|
+
super(expression.replace(/\s+/g, " "));
|
|
13
13
|
this.validateCronExpression();
|
|
14
14
|
}
|
|
15
15
|
validateCronExpression() {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
// usa valor sanitizado do StringEdgeSketch
|
|
18
|
+
cron_parser_1.default.parse(this.toString());
|
|
18
19
|
}
|
|
19
20
|
catch {
|
|
20
|
-
throw new Error(`${this.
|
|
21
|
+
throw new Error(`${this.toString()} should be a valid Cron Expression.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// ==================== Getters ====================
|
|
25
|
+
/**
|
|
26
|
+
* Retorna a expressão cron.
|
|
27
|
+
*/
|
|
28
|
+
toString() {
|
|
29
|
+
return super.toString();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Retorna os campos da expressão cron.
|
|
33
|
+
*/
|
|
34
|
+
getFields() {
|
|
35
|
+
return this.toString().split(/\s+/);
|
|
36
|
+
}
|
|
37
|
+
// ==================== Comparações ====================
|
|
38
|
+
/**
|
|
39
|
+
* Compara com outra expressão cron (string ou edge).
|
|
40
|
+
*/
|
|
41
|
+
isEqual(other) {
|
|
42
|
+
const comparand = other instanceof CronExpressionEdge ? other.toString() : other;
|
|
43
|
+
return this.toString() === comparand.trim().replace(/\s+/g, " ");
|
|
44
|
+
}
|
|
45
|
+
isDifferent(other) {
|
|
46
|
+
return !this.isEqual(other);
|
|
47
|
+
}
|
|
48
|
+
// ==================== Cálculo de Execução ====================
|
|
49
|
+
/**
|
|
50
|
+
* Retorna a próxima execução a partir de uma data base.
|
|
51
|
+
*/
|
|
52
|
+
nextDate(fromDate = new Date()) {
|
|
53
|
+
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
54
|
+
currentDate: fromDate,
|
|
55
|
+
});
|
|
56
|
+
return interval.next().toDate();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retorna a execução anterior a partir de uma data base.
|
|
60
|
+
*/
|
|
61
|
+
previousDate(fromDate = new Date()) {
|
|
62
|
+
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
63
|
+
currentDate: fromDate,
|
|
64
|
+
});
|
|
65
|
+
return interval.prev().toDate();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Retorna as próximas N execuções.
|
|
69
|
+
*/
|
|
70
|
+
nextDates(count, fromDate = new Date()) {
|
|
71
|
+
if (count <= 0)
|
|
72
|
+
return [];
|
|
73
|
+
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
74
|
+
currentDate: fromDate,
|
|
75
|
+
});
|
|
76
|
+
const dates = [];
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
dates.push(interval.next().toDate());
|
|
79
|
+
}
|
|
80
|
+
return dates;
|
|
81
|
+
}
|
|
82
|
+
// ==================== Métodos Estáticos ====================
|
|
83
|
+
/**
|
|
84
|
+
* Valida expressão cron sem lançar exceção.
|
|
85
|
+
*/
|
|
86
|
+
static isValid(expression) {
|
|
87
|
+
try {
|
|
88
|
+
cron_parser_1.default.parse(expression.trim().replace(/\s+/g, " "));
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
21
93
|
}
|
|
22
94
|
}
|
|
23
95
|
}
|
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
import { StringEdgeSketch } from "../../primitives/string.edge.sketch";
|
|
2
2
|
export declare class EmailEdge extends StringEdgeSketch {
|
|
3
|
-
private readonly
|
|
3
|
+
private static readonly pattern;
|
|
4
4
|
constructor(email: string);
|
|
5
5
|
protected validation(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Retorna o e-mail como string.
|
|
8
|
+
*/
|
|
9
|
+
toString(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Retorna o e-mail normalizado (lowercase + trim já aplicado no super).
|
|
12
|
+
*/
|
|
13
|
+
toNormalized(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Retorna a parte local (antes do @).
|
|
16
|
+
*/
|
|
17
|
+
getLocalPart(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Retorna o domínio completo (após o @).
|
|
20
|
+
*/
|
|
21
|
+
getDomain(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Retorna o TLD (ex: "com", "com.br" -> "br").
|
|
24
|
+
*/
|
|
25
|
+
getTld(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Verifica se o e-mail pertence a um domínio.
|
|
28
|
+
*/
|
|
29
|
+
isFromDomain(domain: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Compara este e-mail com outro (string ou EmailEdge).
|
|
32
|
+
* Por padrão, ignora case.
|
|
33
|
+
*/
|
|
34
|
+
isEqual(other: string | EmailEdge, ignoreCase?: boolean): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Mascara a parte local do e-mail.
|
|
37
|
+
* Ex: "john.doe@mail.com" -> "j******e@mail.com"
|
|
38
|
+
*/
|
|
39
|
+
mask(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Verifica se uma string é um e-mail válido sem lançar exceção.
|
|
42
|
+
*/
|
|
43
|
+
static isValid(value: string): boolean;
|
|
6
44
|
}
|
|
@@ -5,13 +5,91 @@ const string_edge_sketch_1 = require("../../primitives/string.edge.sketch");
|
|
|
5
5
|
class EmailEdge extends string_edge_sketch_1.StringEdgeSketch {
|
|
6
6
|
constructor(email) {
|
|
7
7
|
super(email);
|
|
8
|
-
this.email = email;
|
|
9
8
|
this.validation();
|
|
10
9
|
}
|
|
11
10
|
validation() {
|
|
12
|
-
|
|
11
|
+
// usa valor sanitizado do StringEdgeSketch (trim aplicado)
|
|
12
|
+
if (!EmailEdge.pattern.test(this.toString())) {
|
|
13
13
|
throw new TypeError(`${this.constructor.name} should be valid.`);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
// ==================== Getters ====================
|
|
17
|
+
/**
|
|
18
|
+
* Retorna o e-mail como string.
|
|
19
|
+
*/
|
|
20
|
+
toString() {
|
|
21
|
+
return super.toString();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retorna o e-mail normalizado (lowercase + trim já aplicado no super).
|
|
25
|
+
*/
|
|
26
|
+
toNormalized() {
|
|
27
|
+
return this.toString().toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retorna a parte local (antes do @).
|
|
31
|
+
*/
|
|
32
|
+
getLocalPart() {
|
|
33
|
+
return this.toString().split("@")[0];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Retorna o domínio completo (após o @).
|
|
37
|
+
*/
|
|
38
|
+
getDomain() {
|
|
39
|
+
return this.toString().split("@")[1];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retorna o TLD (ex: "com", "com.br" -> "br").
|
|
43
|
+
*/
|
|
44
|
+
getTld() {
|
|
45
|
+
const domain = this.getDomain();
|
|
46
|
+
const parts = domain.split(".");
|
|
47
|
+
return parts[parts.length - 1];
|
|
48
|
+
}
|
|
49
|
+
// ==================== Verificações ====================
|
|
50
|
+
/**
|
|
51
|
+
* Verifica se o e-mail pertence a um domínio.
|
|
52
|
+
*/
|
|
53
|
+
isFromDomain(domain) {
|
|
54
|
+
return this.getDomain().toLowerCase() === domain.toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compara este e-mail com outro (string ou EmailEdge).
|
|
58
|
+
* Por padrão, ignora case.
|
|
59
|
+
*/
|
|
60
|
+
isEqual(other, ignoreCase = true) {
|
|
61
|
+
const comparand = other instanceof EmailEdge ? other.toString() : other;
|
|
62
|
+
if (ignoreCase) {
|
|
63
|
+
return this.toString().toLowerCase() === comparand.trim().toLowerCase();
|
|
64
|
+
}
|
|
65
|
+
return this.toString() === comparand.trim();
|
|
66
|
+
}
|
|
67
|
+
// ==================== Transformação ====================
|
|
68
|
+
/**
|
|
69
|
+
* Mascara a parte local do e-mail.
|
|
70
|
+
* Ex: "john.doe@mail.com" -> "j******e@mail.com"
|
|
71
|
+
*/
|
|
72
|
+
mask() {
|
|
73
|
+
const local = this.getLocalPart();
|
|
74
|
+
const domain = this.getDomain();
|
|
75
|
+
if (local.length <= 2) {
|
|
76
|
+
return `${"*".repeat(local.length)}@${domain}`;
|
|
77
|
+
}
|
|
78
|
+
return `${local[0]}${"*".repeat(local.length - 2)}${local[local.length - 1]}@${domain}`;
|
|
79
|
+
}
|
|
80
|
+
// ==================== Métodos Estáticos ====================
|
|
81
|
+
/**
|
|
82
|
+
* Verifica se uma string é um e-mail válido sem lançar exceção.
|
|
83
|
+
*/
|
|
84
|
+
static isValid(value) {
|
|
85
|
+
try {
|
|
86
|
+
const sanitized = value.trim();
|
|
87
|
+
return EmailEdge.pattern.test(sanitized);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
16
93
|
}
|
|
17
94
|
exports.EmailEdge = EmailEdge;
|
|
95
|
+
EmailEdge.pattern = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
|
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
export declare abstract class UlidSketchEdge {
|
|
2
2
|
private readonly value;
|
|
3
3
|
constructor(value?: string);
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Retorna o ULID como string.
|
|
6
|
+
*/
|
|
5
7
|
toString(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Retorna o ULID em minúsculas.
|
|
10
|
+
*/
|
|
11
|
+
toLowerCase(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Retorna o ULID em maiúsculas.
|
|
14
|
+
*/
|
|
15
|
+
toUpperCase(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Retorna o timestamp embutido no ULID em ms.
|
|
18
|
+
*/
|
|
19
|
+
getTimestamp(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Retorna a data do timestamp embutido no ULID.
|
|
22
|
+
*/
|
|
23
|
+
toDate(): Date;
|
|
24
|
+
/**
|
|
25
|
+
* Compara igualdade com outro ULID.
|
|
26
|
+
*/
|
|
27
|
+
isEqual(otherUlid: UlidSketchEdge): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Compara diferença com outro ULID.
|
|
30
|
+
*/
|
|
31
|
+
isDifferent(otherUlid: UlidSketchEdge): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use isEqual.
|
|
34
|
+
*/
|
|
35
|
+
equals(otherUlid: UlidSketchEdge): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Verifica se este ULID foi gerado antes de outro.
|
|
38
|
+
* (ULID é ordenável lexicograficamente por tempo)
|
|
39
|
+
*/
|
|
40
|
+
isBefore(otherUlid: UlidSketchEdge): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Verifica se este ULID foi gerado depois de outro.
|
|
43
|
+
*/
|
|
44
|
+
isAfter(otherUlid: UlidSketchEdge): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Gera um novo ULID.
|
|
47
|
+
*/
|
|
48
|
+
static generate(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Verifica se uma string é ULID válido.
|
|
51
|
+
*/
|
|
52
|
+
static isUlid(value: string): boolean;
|
|
6
53
|
}
|
|
@@ -6,15 +6,86 @@ const index_1 = require("../../../index");
|
|
|
6
6
|
class UlidSketchEdge {
|
|
7
7
|
constructor(value = (0, ulid_1.ulid)()) {
|
|
8
8
|
this.value = value;
|
|
9
|
-
|
|
9
|
+
// 🐛 fix: isValid retorna boolean, não possui .falsy()
|
|
10
|
+
if (!(0, ulid_1.isValid)(this.value)) {
|
|
10
11
|
throw new TypeError("The provided ULID is invalid. Please ensure it is in the correct format");
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// ==================== Getters ====================
|
|
15
|
+
/**
|
|
16
|
+
* Retorna o ULID como string.
|
|
17
|
+
*/
|
|
16
18
|
toString() {
|
|
17
19
|
return this.value;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Retorna o ULID em minúsculas.
|
|
23
|
+
*/
|
|
24
|
+
toLowerCase() {
|
|
25
|
+
return this.value.toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retorna o ULID em maiúsculas.
|
|
29
|
+
*/
|
|
30
|
+
toUpperCase() {
|
|
31
|
+
return this.value.toUpperCase();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Retorna o timestamp embutido no ULID em ms.
|
|
35
|
+
*/
|
|
36
|
+
getTimestamp() {
|
|
37
|
+
return (0, ulid_1.decodeTime)(this.value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Retorna a data do timestamp embutido no ULID.
|
|
41
|
+
*/
|
|
42
|
+
toDate() {
|
|
43
|
+
return new Date(this.getTimestamp());
|
|
44
|
+
}
|
|
45
|
+
// ==================== Comparações ====================
|
|
46
|
+
/**
|
|
47
|
+
* Compara igualdade com outro ULID.
|
|
48
|
+
*/
|
|
49
|
+
isEqual(otherUlid) {
|
|
50
|
+
return index_1._.isEqual(this.toString(), otherUlid.toString());
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Compara diferença com outro ULID.
|
|
54
|
+
*/
|
|
55
|
+
isDifferent(otherUlid) {
|
|
56
|
+
return !this.isEqual(otherUlid);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use isEqual.
|
|
60
|
+
*/
|
|
61
|
+
equals(otherUlid) {
|
|
62
|
+
return this.isEqual(otherUlid);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Verifica se este ULID foi gerado antes de outro.
|
|
66
|
+
* (ULID é ordenável lexicograficamente por tempo)
|
|
67
|
+
*/
|
|
68
|
+
isBefore(otherUlid) {
|
|
69
|
+
return this.toString() < otherUlid.toString();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Verifica se este ULID foi gerado depois de outro.
|
|
73
|
+
*/
|
|
74
|
+
isAfter(otherUlid) {
|
|
75
|
+
return this.toString() > otherUlid.toString();
|
|
76
|
+
}
|
|
77
|
+
// ==================== Métodos Estáticos ====================
|
|
78
|
+
/**
|
|
79
|
+
* Gera um novo ULID.
|
|
80
|
+
*/
|
|
81
|
+
static generate() {
|
|
82
|
+
return (0, ulid_1.ulid)();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Verifica se uma string é ULID válido.
|
|
86
|
+
*/
|
|
87
|
+
static isUlid(value) {
|
|
88
|
+
return (0, ulid_1.isValid)(value);
|
|
89
|
+
}
|
|
19
90
|
}
|
|
20
91
|
exports.UlidSketchEdge = UlidSketchEdge;
|
|
@@ -3,4 +3,186 @@ export declare class UrlEdge extends StringEdgeSketch {
|
|
|
3
3
|
protected _url: string;
|
|
4
4
|
constructor(_url: string);
|
|
5
5
|
protected validateUrl(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Retorna a URL completa como string.
|
|
8
|
+
* @returns String com a URL completa
|
|
9
|
+
* @example
|
|
10
|
+
* new UrlEdge("https://example.com/path?q=1").toString()
|
|
11
|
+
* // "https://example.com/path?q=1"
|
|
12
|
+
*/
|
|
13
|
+
toString(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Retorna o protocolo da URL (sem "://").
|
|
16
|
+
* @returns String com o protocolo
|
|
17
|
+
* @example
|
|
18
|
+
* new UrlEdge("https://example.com").getProtocol() // "https:"
|
|
19
|
+
* new UrlEdge("http://example.com").getProtocol() // "http:"
|
|
20
|
+
*/
|
|
21
|
+
getProtocol(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Retorna o hostname da URL (sem porta).
|
|
24
|
+
* @returns String com o hostname
|
|
25
|
+
* @example
|
|
26
|
+
* new UrlEdge("https://example.com:8080/path").getHostname() // "example.com"
|
|
27
|
+
*/
|
|
28
|
+
getHostname(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Retorna o host da URL (hostname + porta, se existir).
|
|
31
|
+
* @returns String com o host
|
|
32
|
+
* @example
|
|
33
|
+
* new UrlEdge("https://example.com:8080/path").getHost() // "example.com:8080"
|
|
34
|
+
* new UrlEdge("https://example.com/path").getHost() // "example.com"
|
|
35
|
+
*/
|
|
36
|
+
getHost(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Retorna a porta da URL, se definida.
|
|
39
|
+
* @returns String com a porta ou string vazia se não definida
|
|
40
|
+
* @example
|
|
41
|
+
* new UrlEdge("https://example.com:8080/path").getPort() // "8080"
|
|
42
|
+
* new UrlEdge("https://example.com/path").getPort() // ""
|
|
43
|
+
*/
|
|
44
|
+
getPort(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Retorna o pathname da URL.
|
|
47
|
+
* @returns String com o caminho da URL
|
|
48
|
+
* @example
|
|
49
|
+
* new UrlEdge("https://example.com/foo/bar").getPathname() // "/foo/bar"
|
|
50
|
+
* new UrlEdge("https://example.com").getPathname() // "/"
|
|
51
|
+
*/
|
|
52
|
+
getPathname(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Retorna a query string da URL (incluindo "?").
|
|
55
|
+
* @returns String com a query string ou string vazia se não existir
|
|
56
|
+
* @example
|
|
57
|
+
* new UrlEdge("https://example.com/path?q=1&page=2").getSearch() // "?q=1&page=2"
|
|
58
|
+
* new UrlEdge("https://example.com/path").getSearch() // ""
|
|
59
|
+
*/
|
|
60
|
+
getSearch(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Retorna o valor de um parâmetro específico da query string.
|
|
63
|
+
* @param key - Nome do parâmetro a buscar
|
|
64
|
+
* @returns Valor do parâmetro ou null se não existir
|
|
65
|
+
* @example
|
|
66
|
+
* new UrlEdge("https://example.com?q=hello&page=2").getSearchParam("q") // "hello"
|
|
67
|
+
* new UrlEdge("https://example.com?q=hello").getSearchParam("page") // null
|
|
68
|
+
*/
|
|
69
|
+
getSearchParam(key: string): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Retorna todos os parâmetros da query string como objeto.
|
|
72
|
+
* @returns Objeto com chave/valor de todos os parâmetros
|
|
73
|
+
* @example
|
|
74
|
+
* new UrlEdge("https://example.com?q=hello&page=2").getSearchParams()
|
|
75
|
+
* // { q: "hello", page: "2" }
|
|
76
|
+
*/
|
|
77
|
+
getSearchParams(): Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Retorna o hash/fragmento da URL (incluindo "#").
|
|
80
|
+
* @returns String com o hash ou string vazia se não existir
|
|
81
|
+
* @example
|
|
82
|
+
* new UrlEdge("https://example.com/page#section-1").getHash() // "#section-1"
|
|
83
|
+
* new UrlEdge("https://example.com/page").getHash() // ""
|
|
84
|
+
*/
|
|
85
|
+
getHash(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Retorna a origem da URL (protocolo + host).
|
|
88
|
+
* @returns String com a origem
|
|
89
|
+
* @example
|
|
90
|
+
* new UrlEdge("https://example.com:8080/path?q=1").getOrigin() // "https://example.com:8080"
|
|
91
|
+
*/
|
|
92
|
+
getOrigin(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Verifica se a URL usa o protocolo HTTPS.
|
|
95
|
+
* @returns true se o protocolo é HTTPS, false caso contrário
|
|
96
|
+
* @example
|
|
97
|
+
* new UrlEdge("https://example.com").isHttps() // true
|
|
98
|
+
* new UrlEdge("http://example.com").isHttps() // false
|
|
99
|
+
*/
|
|
100
|
+
isHttps(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Verifica se a URL usa o protocolo HTTP.
|
|
103
|
+
* @returns true se o protocolo é HTTP, false caso contrário
|
|
104
|
+
* @example
|
|
105
|
+
* new UrlEdge("http://example.com").isHttp() // true
|
|
106
|
+
* new UrlEdge("https://example.com").isHttp() // false
|
|
107
|
+
*/
|
|
108
|
+
isHttp(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Verifica se a URL possui query string.
|
|
111
|
+
* @returns true se a URL tem parâmetros de query, false caso contrário
|
|
112
|
+
* @example
|
|
113
|
+
* new UrlEdge("https://example.com?q=1").hasSearchParams() // true
|
|
114
|
+
* new UrlEdge("https://example.com").hasSearchParams() // false
|
|
115
|
+
*/
|
|
116
|
+
hasSearchParams(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Verifica se a URL possui um parâmetro específico na query string.
|
|
119
|
+
* @param key - Nome do parâmetro a verificar
|
|
120
|
+
* @returns true se o parâmetro existe, false caso contrário
|
|
121
|
+
* @example
|
|
122
|
+
* new UrlEdge("https://example.com?q=1").hasSearchParam("q") // true
|
|
123
|
+
* new UrlEdge("https://example.com?q=1").hasSearchParam("page") // false
|
|
124
|
+
*/
|
|
125
|
+
hasSearchParam(key: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Verifica se a URL possui hash/fragmento.
|
|
128
|
+
* @returns true se a URL tem hash, false caso contrário
|
|
129
|
+
* @example
|
|
130
|
+
* new UrlEdge("https://example.com#section").hasHash() // true
|
|
131
|
+
* new UrlEdge("https://example.com").hasHash() // false
|
|
132
|
+
*/
|
|
133
|
+
hasHash(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Verifica se esta URL é igual a outra.
|
|
136
|
+
* @param other - UrlEdge ou string para comparação
|
|
137
|
+
* @returns true se as URLs são iguais, false caso contrário
|
|
138
|
+
* @example
|
|
139
|
+
* const url = new UrlEdge("https://example.com");
|
|
140
|
+
* url.isEqual(new UrlEdge("https://example.com")) // true
|
|
141
|
+
* url.isEqual("https://other.com") // false
|
|
142
|
+
*/
|
|
143
|
+
isEqual(other: UrlEdge | string): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Retorna uma nova URL com um parâmetro de query adicionado ou atualizado.
|
|
146
|
+
* @param key - Nome do parâmetro
|
|
147
|
+
* @param value - Valor do parâmetro
|
|
148
|
+
* @returns Nova instância de UrlEdge com o parâmetro adicionado
|
|
149
|
+
* @example
|
|
150
|
+
* new UrlEdge("https://example.com?q=1").withSearchParam("page", "2")
|
|
151
|
+
* // UrlEdge("https://example.com?q=1&page=2")
|
|
152
|
+
*/
|
|
153
|
+
withSearchParam(key: string, value: string): UrlEdge;
|
|
154
|
+
/**
|
|
155
|
+
* Retorna uma nova URL sem um parâmetro de query específico.
|
|
156
|
+
* @param key - Nome do parâmetro a remover
|
|
157
|
+
* @returns Nova instância de UrlEdge sem o parâmetro
|
|
158
|
+
* @example
|
|
159
|
+
* new UrlEdge("https://example.com?q=1&page=2").withoutSearchParam("page")
|
|
160
|
+
* // UrlEdge("https://example.com?q=1")
|
|
161
|
+
*/
|
|
162
|
+
withoutSearchParam(key: string): UrlEdge;
|
|
163
|
+
/**
|
|
164
|
+
* Retorna uma nova URL sem a query string.
|
|
165
|
+
* @returns Nova instância de UrlEdge sem query string
|
|
166
|
+
* @example
|
|
167
|
+
* new UrlEdge("https://example.com/path?q=1&page=2").withoutSearch()
|
|
168
|
+
* // UrlEdge("https://example.com/path")
|
|
169
|
+
*/
|
|
170
|
+
withoutSearch(): UrlEdge;
|
|
171
|
+
/**
|
|
172
|
+
* Retorna uma nova URL sem o hash/fragmento.
|
|
173
|
+
* @returns Nova instância de UrlEdge sem hash
|
|
174
|
+
* @example
|
|
175
|
+
* new UrlEdge("https://example.com/page#section").withoutHash()
|
|
176
|
+
* // UrlEdge("https://example.com/page")
|
|
177
|
+
*/
|
|
178
|
+
withoutHash(): UrlEdge;
|
|
179
|
+
/**
|
|
180
|
+
* Verifica se uma string é uma URL válida sem lançar exceção.
|
|
181
|
+
* @param value - String a ser verificada
|
|
182
|
+
* @returns true se a string é uma URL válida, false caso contrário
|
|
183
|
+
* @example
|
|
184
|
+
* UrlEdge.isValid("https://example.com") // true
|
|
185
|
+
* UrlEdge.isValid("not-a-url") // false
|
|
186
|
+
*/
|
|
187
|
+
static isValid(value: string): boolean;
|
|
6
188
|
}
|