@atlantjs/arch 13.3.0 → 14.0.1
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/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 +32 -4
- package/@tool-box/utils/datatypes/string-utils.js +303 -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 +39 -0
- package/objects/amount/amount-value.edge.js +69 -0
- package/objects/amount/amount.edge.d.ts +378 -2
- package/objects/amount/amount.edge.js +493 -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
|
@@ -1,10 +1,158 @@
|
|
|
1
1
|
export declare abstract class StringEdgeSketch {
|
|
2
2
|
private value;
|
|
3
3
|
constructor(value: string);
|
|
4
|
+
/**
|
|
5
|
+
* Retorna o valor da string.
|
|
6
|
+
* @returns String interna do edge
|
|
7
|
+
* @example
|
|
8
|
+
* new MyStringEdge("hello").toString() // "hello"
|
|
9
|
+
*/
|
|
4
10
|
toString(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Retorna o comprimento da string.
|
|
13
|
+
* @returns Número de caracteres da string
|
|
14
|
+
* @example
|
|
15
|
+
* new MyStringEdge("hello").length() // 5
|
|
16
|
+
*/
|
|
17
|
+
length(): number;
|
|
18
|
+
/**
|
|
19
|
+
* Verifica se a string contém uma substring específica.
|
|
20
|
+
* @param value - Substring a ser procurada
|
|
21
|
+
* @returns true se a substring foi encontrada, false caso contrário
|
|
22
|
+
* @example
|
|
23
|
+
* new MyStringEdge("hello world").has("world") // true
|
|
24
|
+
* new MyStringEdge("hello world").has("foo") // false
|
|
25
|
+
*/
|
|
5
26
|
has(value: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Verifica se a string começa com uma substring específica.
|
|
29
|
+
* @param value - Substring a ser verificada no início
|
|
30
|
+
* @returns true se a string começa com a substring, false caso contrário
|
|
31
|
+
* @example
|
|
32
|
+
* new MyStringEdge("hello world").startsWith("hello") // true
|
|
33
|
+
* new MyStringEdge("hello world").startsWith("world") // false
|
|
34
|
+
*/
|
|
35
|
+
startsWith(value: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Verifica se a string termina com uma substring específica.
|
|
38
|
+
* @param value - Substring a ser verificada no final
|
|
39
|
+
* @returns true se a string termina com a substring, false caso contrário
|
|
40
|
+
* @example
|
|
41
|
+
* new MyStringEdge("hello world").endsWith("world") // true
|
|
42
|
+
* new MyStringEdge("hello world").endsWith("hello") // false
|
|
43
|
+
*/
|
|
44
|
+
endsWith(value: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Verifica se a string é igual a outra (case-sensitive).
|
|
47
|
+
* @param value - String para comparação
|
|
48
|
+
* @returns true se as strings são iguais, false caso contrário
|
|
49
|
+
* @example
|
|
50
|
+
* new MyStringEdge("hello").isEqual("hello") // true
|
|
51
|
+
* new MyStringEdge("hello").isEqual("Hello") // false
|
|
52
|
+
*/
|
|
53
|
+
isEqual(value: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Verifica se a string é igual a outra ignorando maiúsculas/minúsculas.
|
|
56
|
+
* @param value - String para comparação
|
|
57
|
+
* @returns true se as strings são iguais (case-insensitive), false caso contrário
|
|
58
|
+
* @example
|
|
59
|
+
* new MyStringEdge("hello").isEqualIgnoreCase("HELLO") // true
|
|
60
|
+
* new MyStringEdge("hello").isEqualIgnoreCase("world") // false
|
|
61
|
+
*/
|
|
62
|
+
isEqualIgnoreCase(value: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Extrai uma substring entre dois delimitadores (exclusivo).
|
|
65
|
+
* @param start - Delimitador de início (não incluído no resultado)
|
|
66
|
+
* @param end - Delimitador de fim (não incluído no resultado)
|
|
67
|
+
* @returns Substring entre os delimitadores
|
|
68
|
+
* @example
|
|
69
|
+
* new MyStringEdge("[hello]").extract("[", "]") // "hello"
|
|
70
|
+
* new MyStringEdge("(foo bar)").extract("(", ")") // "foo bar"
|
|
71
|
+
*/
|
|
6
72
|
extract(start: string, end: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Retorna uma fatia da string entre dois índices.
|
|
75
|
+
* @param start - Índice inicial (inclusivo)
|
|
76
|
+
* @param end - Índice final (exclusivo, opcional)
|
|
77
|
+
* @returns Substring entre os índices fornecidos
|
|
78
|
+
* @example
|
|
79
|
+
* new MyStringEdge("hello world").slice(0, 5) // "hello"
|
|
80
|
+
* new MyStringEdge("hello world").slice(6) // "world"
|
|
81
|
+
*/
|
|
82
|
+
slice(start: number, end?: number): string;
|
|
83
|
+
/**
|
|
84
|
+
* Remove todas as ocorrências das substrings fornecidas.
|
|
85
|
+
* @param substrings - Array de substrings a serem removidas
|
|
86
|
+
* @returns Nova string sem as substrings fornecidas
|
|
87
|
+
* @example
|
|
88
|
+
* new MyStringEdge("hello world").remove(["hello", " "]) // "world"
|
|
89
|
+
* new MyStringEdge("foo-bar_baz").remove(["-", "_"]) // "foobarbaz"
|
|
90
|
+
*/
|
|
7
91
|
remove(substrings: string[]): string;
|
|
92
|
+
/**
|
|
93
|
+
* Substitui a primeira ocorrência de uma substring por outra.
|
|
94
|
+
* @param search - Substring a ser substituída
|
|
95
|
+
* @param replacement - Substring substituta
|
|
96
|
+
* @returns Nova string com a primeira ocorrência substituída
|
|
97
|
+
* @example
|
|
98
|
+
* new MyStringEdge("foo bar foo").replace("foo", "baz") // "baz bar foo"
|
|
99
|
+
*/
|
|
100
|
+
replace(search: string, replacement: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Substitui todas as ocorrências de uma substring por outra.
|
|
103
|
+
* @param search - Substring a ser substituída
|
|
104
|
+
* @param replacement - Substring substituta
|
|
105
|
+
* @returns Nova string com todas as ocorrências substituídas
|
|
106
|
+
* @example
|
|
107
|
+
* new MyStringEdge("foo bar foo").replaceAll("foo", "baz") // "baz bar baz"
|
|
108
|
+
*/
|
|
109
|
+
replaceAll(search: string, replacement: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Converte a string para letras maiúsculas.
|
|
112
|
+
* @returns String em maiúsculas
|
|
113
|
+
* @example
|
|
114
|
+
* new MyStringEdge("hello").toUpperCase() // "HELLO"
|
|
115
|
+
*/
|
|
116
|
+
toUpperCase(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Converte a string para letras minúsculas.
|
|
119
|
+
* @returns String em minúsculas
|
|
120
|
+
* @example
|
|
121
|
+
* new MyStringEdge("HELLO").toLowerCase() // "hello"
|
|
122
|
+
*/
|
|
123
|
+
toLowerCase(): string;
|
|
124
|
+
/**
|
|
125
|
+
* Reverte os caracteres da string.
|
|
126
|
+
* @returns String com os caracteres em ordem inversa
|
|
127
|
+
* @example
|
|
128
|
+
* new MyStringEdge("hello").reverse() // "olleh"
|
|
129
|
+
*/
|
|
130
|
+
reverse(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Trunca a string para um comprimento máximo, adicionando "..." ao final.
|
|
133
|
+
* Se a string já for menor ou igual ao comprimento, retorna sem alteração.
|
|
134
|
+
* @param length - Comprimento máximo da string resultante (incluindo "...")
|
|
135
|
+
* @returns String truncada com "..." se necessário
|
|
136
|
+
* @example
|
|
137
|
+
* new MyStringEdge("Hello World").truncate(8) // "Hello..."
|
|
138
|
+
* new MyStringEdge("Hi").truncate(8) // "Hi"
|
|
139
|
+
*/
|
|
140
|
+
truncate(length: number): string;
|
|
141
|
+
/**
|
|
142
|
+
* Conta o número de ocorrências de uma substring na string.
|
|
143
|
+
* @param substring - Substring a ser contada
|
|
144
|
+
* @returns Número de ocorrências encontradas
|
|
145
|
+
* @example
|
|
146
|
+
* new MyStringEdge("hello world hello").countOccurrences("hello") // 2
|
|
147
|
+
*/
|
|
148
|
+
countOccurrences(substring: string): number;
|
|
149
|
+
/**
|
|
150
|
+
* Remove espaços extras no início e no fim da string.
|
|
151
|
+
*/
|
|
8
152
|
private sanitize;
|
|
153
|
+
/**
|
|
154
|
+
* Valida se a string não está vazia após o sanitize.
|
|
155
|
+
* @throws {TypeError} Se a string estiver vazia
|
|
156
|
+
*/
|
|
9
157
|
private validate;
|
|
10
158
|
}
|
|
@@ -7,27 +7,211 @@ class StringEdgeSketch {
|
|
|
7
7
|
this.sanitize();
|
|
8
8
|
this.validate();
|
|
9
9
|
}
|
|
10
|
+
// ==================== Getters ====================
|
|
11
|
+
/**
|
|
12
|
+
* Retorna o valor da string.
|
|
13
|
+
* @returns String interna do edge
|
|
14
|
+
* @example
|
|
15
|
+
* new MyStringEdge("hello").toString() // "hello"
|
|
16
|
+
*/
|
|
10
17
|
toString() {
|
|
11
18
|
return this.value;
|
|
12
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Retorna o comprimento da string.
|
|
22
|
+
* @returns Número de caracteres da string
|
|
23
|
+
* @example
|
|
24
|
+
* new MyStringEdge("hello").length() // 5
|
|
25
|
+
*/
|
|
26
|
+
length() {
|
|
27
|
+
return this.value.length;
|
|
28
|
+
}
|
|
29
|
+
// ==================== Verificações ====================
|
|
30
|
+
/**
|
|
31
|
+
* Verifica se a string contém uma substring específica.
|
|
32
|
+
* @param value - Substring a ser procurada
|
|
33
|
+
* @returns true se a substring foi encontrada, false caso contrário
|
|
34
|
+
* @example
|
|
35
|
+
* new MyStringEdge("hello world").has("world") // true
|
|
36
|
+
* new MyStringEdge("hello world").has("foo") // false
|
|
37
|
+
*/
|
|
13
38
|
has(value) {
|
|
14
|
-
return
|
|
39
|
+
return this.value.includes(value); // 🐛 fix: !indexOf() falha quando index é 0
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Verifica se a string começa com uma substring específica.
|
|
43
|
+
* @param value - Substring a ser verificada no início
|
|
44
|
+
* @returns true se a string começa com a substring, false caso contrário
|
|
45
|
+
* @example
|
|
46
|
+
* new MyStringEdge("hello world").startsWith("hello") // true
|
|
47
|
+
* new MyStringEdge("hello world").startsWith("world") // false
|
|
48
|
+
*/
|
|
49
|
+
startsWith(value) {
|
|
50
|
+
return this.value.startsWith(value);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Verifica se a string termina com uma substring específica.
|
|
54
|
+
* @param value - Substring a ser verificada no final
|
|
55
|
+
* @returns true se a string termina com a substring, false caso contrário
|
|
56
|
+
* @example
|
|
57
|
+
* new MyStringEdge("hello world").endsWith("world") // true
|
|
58
|
+
* new MyStringEdge("hello world").endsWith("hello") // false
|
|
59
|
+
*/
|
|
60
|
+
endsWith(value) {
|
|
61
|
+
return this.value.endsWith(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Verifica se a string é igual a outra (case-sensitive).
|
|
65
|
+
* @param value - String para comparação
|
|
66
|
+
* @returns true se as strings são iguais, false caso contrário
|
|
67
|
+
* @example
|
|
68
|
+
* new MyStringEdge("hello").isEqual("hello") // true
|
|
69
|
+
* new MyStringEdge("hello").isEqual("Hello") // false
|
|
70
|
+
*/
|
|
71
|
+
isEqual(value) {
|
|
72
|
+
return this.value === value;
|
|
15
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Verifica se a string é igual a outra ignorando maiúsculas/minúsculas.
|
|
76
|
+
* @param value - String para comparação
|
|
77
|
+
* @returns true se as strings são iguais (case-insensitive), false caso contrário
|
|
78
|
+
* @example
|
|
79
|
+
* new MyStringEdge("hello").isEqualIgnoreCase("HELLO") // true
|
|
80
|
+
* new MyStringEdge("hello").isEqualIgnoreCase("world") // false
|
|
81
|
+
*/
|
|
82
|
+
isEqualIgnoreCase(value) {
|
|
83
|
+
return this.value.toLowerCase() === value.toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
// ==================== Extração ====================
|
|
86
|
+
/**
|
|
87
|
+
* Extrai uma substring entre dois delimitadores (exclusivo).
|
|
88
|
+
* @param start - Delimitador de início (não incluído no resultado)
|
|
89
|
+
* @param end - Delimitador de fim (não incluído no resultado)
|
|
90
|
+
* @returns Substring entre os delimitadores
|
|
91
|
+
* @example
|
|
92
|
+
* new MyStringEdge("[hello]").extract("[", "]") // "hello"
|
|
93
|
+
* new MyStringEdge("(foo bar)").extract("(", ")") // "foo bar"
|
|
94
|
+
*/
|
|
16
95
|
extract(start, end) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
return this.value.substring(
|
|
96
|
+
const indexStart = this.value.indexOf(start) + start.length; // 🐛 fix: incluir tamanho do delimitador
|
|
97
|
+
const indexEnd = this.value.lastIndexOf(end); // 🐛 fix: remover + 1 que incluía o char final
|
|
98
|
+
return this.value.substring(indexStart, indexEnd);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Retorna uma fatia da string entre dois índices.
|
|
102
|
+
* @param start - Índice inicial (inclusivo)
|
|
103
|
+
* @param end - Índice final (exclusivo, opcional)
|
|
104
|
+
* @returns Substring entre os índices fornecidos
|
|
105
|
+
* @example
|
|
106
|
+
* new MyStringEdge("hello world").slice(0, 5) // "hello"
|
|
107
|
+
* new MyStringEdge("hello world").slice(6) // "world"
|
|
108
|
+
*/
|
|
109
|
+
slice(start, end) {
|
|
110
|
+
return this.value.slice(start, end);
|
|
20
111
|
}
|
|
112
|
+
// ==================== Transformação ====================
|
|
113
|
+
/**
|
|
114
|
+
* Remove todas as ocorrências das substrings fornecidas.
|
|
115
|
+
* @param substrings - Array de substrings a serem removidas
|
|
116
|
+
* @returns Nova string sem as substrings fornecidas
|
|
117
|
+
* @example
|
|
118
|
+
* new MyStringEdge("hello world").remove(["hello", " "]) // "world"
|
|
119
|
+
* new MyStringEdge("foo-bar_baz").remove(["-", "_"]) // "foobarbaz"
|
|
120
|
+
*/
|
|
21
121
|
remove(substrings) {
|
|
22
|
-
|
|
23
|
-
|
|
122
|
+
return substrings.reduce(
|
|
123
|
+
// 🐛 fix: regex com [...] quebra para substrings com mais de 1 char
|
|
124
|
+
(acc, substring) => acc.split(substring).join(""), this.value);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Substitui a primeira ocorrência de uma substring por outra.
|
|
128
|
+
* @param search - Substring a ser substituída
|
|
129
|
+
* @param replacement - Substring substituta
|
|
130
|
+
* @returns Nova string com a primeira ocorrência substituída
|
|
131
|
+
* @example
|
|
132
|
+
* new MyStringEdge("foo bar foo").replace("foo", "baz") // "baz bar foo"
|
|
133
|
+
*/
|
|
134
|
+
replace(search, replacement) {
|
|
135
|
+
return this.value.replace(search, replacement);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Substitui todas as ocorrências de uma substring por outra.
|
|
139
|
+
* @param search - Substring a ser substituída
|
|
140
|
+
* @param replacement - Substring substituta
|
|
141
|
+
* @returns Nova string com todas as ocorrências substituídas
|
|
142
|
+
* @example
|
|
143
|
+
* new MyStringEdge("foo bar foo").replaceAll("foo", "baz") // "baz bar baz"
|
|
144
|
+
*/
|
|
145
|
+
replaceAll(search, replacement) {
|
|
146
|
+
return this.value.split(search).join(replacement);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Converte a string para letras maiúsculas.
|
|
150
|
+
* @returns String em maiúsculas
|
|
151
|
+
* @example
|
|
152
|
+
* new MyStringEdge("hello").toUpperCase() // "HELLO"
|
|
153
|
+
*/
|
|
154
|
+
toUpperCase() {
|
|
155
|
+
return this.value.toUpperCase();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Converte a string para letras minúsculas.
|
|
159
|
+
* @returns String em minúsculas
|
|
160
|
+
* @example
|
|
161
|
+
* new MyStringEdge("HELLO").toLowerCase() // "hello"
|
|
162
|
+
*/
|
|
163
|
+
toLowerCase() {
|
|
164
|
+
return this.value.toLowerCase();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Reverte os caracteres da string.
|
|
168
|
+
* @returns String com os caracteres em ordem inversa
|
|
169
|
+
* @example
|
|
170
|
+
* new MyStringEdge("hello").reverse() // "olleh"
|
|
171
|
+
*/
|
|
172
|
+
reverse() {
|
|
173
|
+
return this.value.split("").reverse().join("");
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Trunca a string para um comprimento máximo, adicionando "..." ao final.
|
|
177
|
+
* Se a string já for menor ou igual ao comprimento, retorna sem alteração.
|
|
178
|
+
* @param length - Comprimento máximo da string resultante (incluindo "...")
|
|
179
|
+
* @returns String truncada com "..." se necessário
|
|
180
|
+
* @example
|
|
181
|
+
* new MyStringEdge("Hello World").truncate(8) // "Hello..."
|
|
182
|
+
* new MyStringEdge("Hi").truncate(8) // "Hi"
|
|
183
|
+
*/
|
|
184
|
+
truncate(length) {
|
|
185
|
+
if (this.value.length <= length)
|
|
186
|
+
return this.value;
|
|
187
|
+
return `${this.value.substring(0, length - 3)}...`;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Conta o número de ocorrências de uma substring na string.
|
|
191
|
+
* @param substring - Substring a ser contada
|
|
192
|
+
* @returns Número de ocorrências encontradas
|
|
193
|
+
* @example
|
|
194
|
+
* new MyStringEdge("hello world hello").countOccurrences("hello") // 2
|
|
195
|
+
*/
|
|
196
|
+
countOccurrences(substring) {
|
|
197
|
+
if (substring.length === 0)
|
|
198
|
+
return 0;
|
|
199
|
+
return this.value.split(substring).length - 1;
|
|
24
200
|
}
|
|
201
|
+
// ==================== Privados ====================
|
|
202
|
+
/**
|
|
203
|
+
* Remove espaços extras no início e no fim da string.
|
|
204
|
+
*/
|
|
25
205
|
sanitize() {
|
|
26
206
|
this.value = this.value.trim();
|
|
27
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Valida se a string não está vazia após o sanitize.
|
|
210
|
+
* @throws {TypeError} Se a string estiver vazia
|
|
211
|
+
*/
|
|
28
212
|
validate() {
|
|
29
213
|
if (this.value.length <= 0) {
|
|
30
|
-
throw TypeError(`${this.constructor.name} should not be empty.`);
|
|
214
|
+
throw new TypeError(`${this.constructor.name} should not be empty.`);
|
|
31
215
|
}
|
|
32
216
|
}
|
|
33
217
|
}
|
|
@@ -6,11 +6,205 @@ import { TimeEdge } from "../time/time.edge";
|
|
|
6
6
|
export declare class ScheduleEdge {
|
|
7
7
|
protected _moment: CronExpressionEdge | DatetimeEdge;
|
|
8
8
|
constructor(_moment: CronExpressionEdge | DatetimeEdge);
|
|
9
|
+
/**
|
|
10
|
+
* Verifica se o agendamento é recorrente (baseado em expressão cron).
|
|
11
|
+
* @returns true se o agendamento é recorrente, false se é um datetime fixo
|
|
12
|
+
* @example
|
|
13
|
+
* new ScheduleEdge(new CronExpressionEdge("0 8 * * *")).isRecurrent() // true
|
|
14
|
+
* new ScheduleEdge(new DatetimeEdge(new Date())).isRecurrent() // false
|
|
15
|
+
*/
|
|
9
16
|
isRecurrent(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Verifica se o agendamento é um evento único (baseado em DatetimeEdge).
|
|
19
|
+
* @returns true se o agendamento é um evento único, false se é recorrente
|
|
20
|
+
* @example
|
|
21
|
+
* new ScheduleEdge(new DatetimeEdge(new Date())).isOneTime() // true
|
|
22
|
+
* new ScheduleEdge(new CronExpressionEdge("0 8 * * *")).isOneTime() // false
|
|
23
|
+
*/
|
|
24
|
+
isOneTime(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Verifica se o agendamento já passou em relação à data/hora atual.
|
|
27
|
+
* Para agendamentos recorrentes, sempre retorna false.
|
|
28
|
+
* @returns true se a data do agendamento é anterior ao momento atual
|
|
29
|
+
* @example
|
|
30
|
+
* new ScheduleEdge(new DatetimeEdge(new Date("2020-01-01"))).isPast() // true
|
|
31
|
+
* new ScheduleEdge(new DatetimeEdge(new Date("2099-01-01"))).isPast() // false
|
|
32
|
+
*/
|
|
33
|
+
isPast(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Verifica se o agendamento ainda está no futuro em relação à data/hora atual.
|
|
36
|
+
* Para agendamentos recorrentes, sempre retorna true.
|
|
37
|
+
* @returns true se a data do agendamento é posterior ao momento atual
|
|
38
|
+
* @example
|
|
39
|
+
* new ScheduleEdge(new DatetimeEdge(new Date("2099-01-01"))).isFuture() // true
|
|
40
|
+
* new ScheduleEdge(new DatetimeEdge(new Date("2020-01-01"))).isFuture() // false
|
|
41
|
+
*/
|
|
42
|
+
isFuture(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Verifica se o agendamento ocorre hoje.
|
|
45
|
+
* Para agendamentos recorrentes, verifica se há uma ocorrência hoje.
|
|
46
|
+
* @returns true se há uma ocorrência hoje, false caso contrário
|
|
47
|
+
* @example
|
|
48
|
+
* new ScheduleEdge(new DatetimeEdge(new Date())).isToday() // true
|
|
49
|
+
*/
|
|
50
|
+
isToday(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Retorna a próxima ocorrência de um agendamento recorrente.
|
|
53
|
+
* @returns Success com a próxima ocorrência ou Failure se o agendamento não for recorrente
|
|
54
|
+
* @example
|
|
55
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
56
|
+
* schedule.nextOccurrence() // Success(DatetimeEdge com a próxima ocorrência às 8h)
|
|
57
|
+
*/
|
|
10
58
|
nextOccurrence(): Return<DatetimeEdge, FailureAbstract>;
|
|
59
|
+
/**
|
|
60
|
+
* Retorna as próximas N ocorrências de um agendamento recorrente.
|
|
61
|
+
* @param quantity - Número de ocorrências a retornar
|
|
62
|
+
* @returns Success com array das próximas ocorrências ou Failure se não for recorrente
|
|
63
|
+
* @example
|
|
64
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
65
|
+
* schedule.nextOccurrences(3) // Success([DatetimeEdge, DatetimeEdge, DatetimeEdge])
|
|
66
|
+
*/
|
|
11
67
|
nextOccurrences(quantity: number): Return<DatetimeEdge[], FailureAbstract>;
|
|
68
|
+
/**
|
|
69
|
+
* Retorna a ocorrência anterior de um agendamento recorrente.
|
|
70
|
+
* @returns Success com a ocorrência anterior ou Failure se o agendamento não for recorrente
|
|
71
|
+
* @example
|
|
72
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
73
|
+
* schedule.previousOccurrence() // Success(DatetimeEdge com a última ocorrência às 8h)
|
|
74
|
+
*/
|
|
12
75
|
previousOccurrence(): Return<DatetimeEdge, FailureAbstract>;
|
|
76
|
+
/**
|
|
77
|
+
* Retorna as N ocorrências anteriores de um agendamento recorrente.
|
|
78
|
+
* @param quantity - Número de ocorrências a retornar
|
|
79
|
+
* @returns Success com array das ocorrências anteriores ou Failure se não for recorrente
|
|
80
|
+
* @example
|
|
81
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
82
|
+
* schedule.previousOccurrences(3) // Success([DatetimeEdge, DatetimeEdge, DatetimeEdge])
|
|
83
|
+
*/
|
|
13
84
|
previousOccurrences(quantity: number): Return<DatetimeEdge[], FailureAbstract>;
|
|
85
|
+
/**
|
|
86
|
+
* Retorna todas as ocorrências dentro de um intervalo de datas.
|
|
87
|
+
* @param start - Data de início do intervalo
|
|
88
|
+
* @param end - Data de fim do intervalo
|
|
89
|
+
* @returns Success com array das ocorrências no intervalo ou Failure se não for recorrente
|
|
90
|
+
* @example
|
|
91
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
92
|
+
* schedule.occurrencesBetween(startDate, endDate)
|
|
93
|
+
* // Success([DatetimeEdge, DatetimeEdge, ...])
|
|
94
|
+
*/
|
|
95
|
+
occurrencesBetween(start: DatetimeEdge, end: DatetimeEdge): Return<DatetimeEdge[], FailureAbstract>;
|
|
96
|
+
/**
|
|
97
|
+
* Conta quantas ocorrências existem dentro de um intervalo de datas.
|
|
98
|
+
* @param start - Data de início do intervalo
|
|
99
|
+
* @param end - Data de fim do intervalo
|
|
100
|
+
* @returns Success com o número de ocorrências ou Failure se não for recorrente
|
|
101
|
+
* @example
|
|
102
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * 1-5"));
|
|
103
|
+
* schedule.countOccurrencesBetween(startDate, endDate) // Success(5) em uma semana
|
|
104
|
+
*/
|
|
105
|
+
countOccurrencesBetween(start: DatetimeEdge, end: DatetimeEdge): Return<number, FailureAbstract>;
|
|
106
|
+
/**
|
|
107
|
+
* Retorna o horário do agendamento como um TimeEdge.
|
|
108
|
+
* @returns TimeEdge com hora e minuto do agendamento
|
|
109
|
+
* @example
|
|
110
|
+
* new ScheduleEdge(new CronExpressionEdge("0 8 * * *")).getTime()
|
|
111
|
+
* // TimeEdge("08:00")
|
|
112
|
+
*/
|
|
14
113
|
getTime(): TimeEdge;
|
|
114
|
+
/**
|
|
115
|
+
* Retorna o momento interno do agendamento (CronExpressionEdge ou DatetimeEdge).
|
|
116
|
+
* @returns Instância de CronExpressionEdge ou DatetimeEdge
|
|
117
|
+
* @example
|
|
118
|
+
* new ScheduleEdge(new CronExpressionEdge("0 8 * * *")).getMoment()
|
|
119
|
+
* // CronExpressionEdge("0 8 * * *")
|
|
120
|
+
*/
|
|
121
|
+
getMoment(): CronExpressionEdge | DatetimeEdge;
|
|
122
|
+
/**
|
|
123
|
+
* Retorna o DatetimeEdge do agendamento se for um evento único.
|
|
124
|
+
* @returns Success com o DatetimeEdge ou Failure se o agendamento for recorrente
|
|
125
|
+
* @example
|
|
126
|
+
* const date = new DatetimeEdge(new Date());
|
|
127
|
+
* new ScheduleEdge(date).getDatetime() // Success(DatetimeEdge)
|
|
128
|
+
*/
|
|
129
|
+
getDatetime(): Return<DatetimeEdge, FailureAbstract>;
|
|
130
|
+
/**
|
|
131
|
+
* Retorna a CronExpressionEdge do agendamento se for recorrente.
|
|
132
|
+
* @returns Success com a CronExpressionEdge ou Failure se for evento único
|
|
133
|
+
* @example
|
|
134
|
+
* const cron = new CronExpressionEdge("0 8 * * *");
|
|
135
|
+
* new ScheduleEdge(cron).getCronExpression() // Success(CronExpressionEdge)
|
|
136
|
+
*/
|
|
137
|
+
getCronExpression(): Return<CronExpressionEdge, FailureAbstract>;
|
|
138
|
+
/**
|
|
139
|
+
* Cria uma cópia independente desta instância de ScheduleEdge.
|
|
140
|
+
* @returns Nova instância com o mesmo momento interno
|
|
141
|
+
* @example
|
|
142
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
143
|
+
* const clone = schedule.clone(); // instância independente
|
|
144
|
+
*/
|
|
145
|
+
clone(): ScheduleEdge;
|
|
146
|
+
/**
|
|
147
|
+
* Retorna uma nova instância com o momento alterado.
|
|
148
|
+
* @param moment - Novo momento (CronExpressionEdge ou DatetimeEdge)
|
|
149
|
+
* @returns Nova instância com o momento alterado
|
|
150
|
+
* @example
|
|
151
|
+
* const schedule = new ScheduleEdge(new CronExpressionEdge("0 8 * * *"));
|
|
152
|
+
* const updated = schedule.withMoment(new CronExpressionEdge("0 10 * * *"));
|
|
153
|
+
*/
|
|
154
|
+
withMoment(moment: CronExpressionEdge | DatetimeEdge): ScheduleEdge;
|
|
155
|
+
/**
|
|
156
|
+
* Retorna a representação em string do momento do agendamento.
|
|
157
|
+
* Para cron, retorna a expressão cron. Para datetime, retorna a ISO string.
|
|
158
|
+
* @returns String representando o agendamento
|
|
159
|
+
* @example
|
|
160
|
+
* new ScheduleEdge(new CronExpressionEdge("0 8 * * *")).toString() // "0 8 * * *"
|
|
161
|
+
* new ScheduleEdge(new DatetimeEdge(new Date())).toString() // "2026-03-12T14:00:00.000Z"
|
|
162
|
+
*/
|
|
15
163
|
toString(): string;
|
|
164
|
+
/**
|
|
165
|
+
* Cria um ScheduleEdge recorrente a partir de uma expressão cron.
|
|
166
|
+
* @param expression - Expressão cron válida
|
|
167
|
+
* @returns Nova instância de ScheduleEdge recorrente
|
|
168
|
+
* @example
|
|
169
|
+
* ScheduleEdge.fromCron("0 8 * * *") // agendamento diário às 8h
|
|
170
|
+
* ScheduleEdge.fromCron("0 8 * * 1-5") // agendamento de segunda a sexta às 8h
|
|
171
|
+
*/
|
|
172
|
+
static fromCron(expression: string): ScheduleEdge;
|
|
173
|
+
/**
|
|
174
|
+
* Cria um ScheduleEdge de evento único a partir de um objeto Date.
|
|
175
|
+
* @param date - Data e hora do evento único
|
|
176
|
+
* @returns Nova instância de ScheduleEdge para evento único
|
|
177
|
+
* @example
|
|
178
|
+
* ScheduleEdge.fromDate(new Date("2026-12-25T08:00:00"))
|
|
179
|
+
* // agendamento para o Natal de 2026 às 8h
|
|
180
|
+
*/
|
|
181
|
+
static fromDate(date: Date): ScheduleEdge;
|
|
182
|
+
/**
|
|
183
|
+
* Cria um ScheduleEdge para agendamentos diários em um horário específico.
|
|
184
|
+
* @param time - Horário do agendamento no formato TimeEdge
|
|
185
|
+
* @returns Nova instância de ScheduleEdge com recorrência diária
|
|
186
|
+
* @example
|
|
187
|
+
* ScheduleEdge.daily(new TimeEdge("08:00")) // todos os dias às 8h -> "0 8 * * *"
|
|
188
|
+
*/
|
|
189
|
+
static daily(time: TimeEdge): ScheduleEdge;
|
|
190
|
+
/**
|
|
191
|
+
* Cria um ScheduleEdge para agendamentos semanais em um dia e horário específico.
|
|
192
|
+
* @param dayOfWeek - Dia da semana (0=domingo, 1=segunda, ..., 6=sábado)
|
|
193
|
+
* @param time - Horário do agendamento no formato TimeEdge
|
|
194
|
+
* @returns Nova instância de ScheduleEdge com recorrência semanal
|
|
195
|
+
* @example
|
|
196
|
+
* ScheduleEdge.weekly(1, new TimeEdge("08:00"))
|
|
197
|
+
* // toda segunda-feira às 8h -> "0 8 * * 1"
|
|
198
|
+
*/
|
|
199
|
+
static weekly(dayOfWeek: number, time: TimeEdge): ScheduleEdge;
|
|
200
|
+
/**
|
|
201
|
+
* Cria um ScheduleEdge para agendamentos mensais em um dia e horário específico.
|
|
202
|
+
* @param dayOfMonth - Dia do mês (1-31)
|
|
203
|
+
* @param time - Horário do agendamento no formato TimeEdge
|
|
204
|
+
* @returns Nova instância de ScheduleEdge com recorrência mensal
|
|
205
|
+
* @example
|
|
206
|
+
* ScheduleEdge.monthly(15, new TimeEdge("08:00"))
|
|
207
|
+
* // todo dia 15 de cada mês às 8h -> "0 8 15 * *"
|
|
208
|
+
*/
|
|
209
|
+
static monthly(dayOfMonth: number, time: TimeEdge): ScheduleEdge;
|
|
16
210
|
}
|