tyforge 0.1.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.
Potentially problematic release.
This version of tyforge might be problematic. Click here for more details.
- package/dist/constants/http-status.constants.d.ts +26 -0
- package/dist/constants/http-status.constants.d.ts.map +1 -0
- package/dist/constants/http-status.constants.js +27 -0
- package/dist/constants/http-status.constants.js.map +1 -0
- package/dist/domain-models/agreggate.base.d.ts +10 -0
- package/dist/domain-models/agreggate.base.d.ts.map +1 -0
- package/dist/domain-models/agreggate.base.js +21 -0
- package/dist/domain-models/agreggate.base.js.map +1 -0
- package/dist/domain-models/base-repository.interface.d.ts +14 -0
- package/dist/domain-models/base-repository.interface.d.ts.map +1 -0
- package/dist/domain-models/base-repository.interface.js +3 -0
- package/dist/domain-models/base-repository.interface.js.map +1 -0
- package/dist/domain-models/class-domain-models.base.d.ts +19 -0
- package/dist/domain-models/class-domain-models.base.d.ts.map +1 -0
- package/dist/domain-models/class-domain-models.base.js +78 -0
- package/dist/domain-models/class-domain-models.base.js.map +1 -0
- package/dist/domain-models/class.base.d.ts +10 -0
- package/dist/domain-models/class.base.d.ts.map +1 -0
- package/dist/domain-models/class.base.js +10 -0
- package/dist/domain-models/class.base.js.map +1 -0
- package/dist/domain-models/domain-event.base.d.ts +19 -0
- package/dist/domain-models/domain-event.base.d.ts.map +1 -0
- package/dist/domain-models/domain-event.base.js +29 -0
- package/dist/domain-models/domain-event.base.js.map +1 -0
- package/dist/domain-models/dto-out-generic.d.ts +33 -0
- package/dist/domain-models/dto-out-generic.d.ts.map +1 -0
- package/dist/domain-models/dto-out-generic.js +55 -0
- package/dist/domain-models/dto-out-generic.js.map +1 -0
- package/dist/domain-models/dto-out.base.d.ts +21 -0
- package/dist/domain-models/dto-out.base.d.ts.map +1 -0
- package/dist/domain-models/dto-out.base.js +11 -0
- package/dist/domain-models/dto-out.base.js.map +1 -0
- package/dist/domain-models/dto.base.d.ts +23 -0
- package/dist/domain-models/dto.base.d.ts.map +1 -0
- package/dist/domain-models/dto.base.js +11 -0
- package/dist/domain-models/dto.base.js.map +1 -0
- package/dist/domain-models/entity.base.d.ts +11 -0
- package/dist/domain-models/entity.base.d.ts.map +1 -0
- package/dist/domain-models/entity.base.js +20 -0
- package/dist/domain-models/entity.base.js.map +1 -0
- package/dist/domain-models/value-object.base.d.ts +5 -0
- package/dist/domain-models/value-object.base.d.ts.map +1 -0
- package/dist/domain-models/value-object.base.js +13 -0
- package/dist/domain-models/value-object.base.js.map +1 -0
- package/dist/exceptions/auth.exception.d.ts +30 -0
- package/dist/exceptions/auth.exception.d.ts.map +1 -0
- package/dist/exceptions/auth.exception.js +290 -0
- package/dist/exceptions/auth.exception.js.map +1 -0
- package/dist/exceptions/base.exceptions.d.ts +36 -0
- package/dist/exceptions/base.exceptions.d.ts.map +1 -0
- package/dist/exceptions/base.exceptions.js +60 -0
- package/dist/exceptions/base.exceptions.js.map +1 -0
- package/dist/exceptions/boolean.exception.d.ts +7 -0
- package/dist/exceptions/boolean.exception.d.ts.map +1 -0
- package/dist/exceptions/boolean.exception.js +25 -0
- package/dist/exceptions/boolean.exception.js.map +1 -0
- package/dist/exceptions/business.exception.d.ts +13 -0
- package/dist/exceptions/business.exception.d.ts.map +1 -0
- package/dist/exceptions/business.exception.js +107 -0
- package/dist/exceptions/business.exception.js.map +1 -0
- package/dist/exceptions/date.exception.d.ts +8 -0
- package/dist/exceptions/date.exception.d.ts.map +1 -0
- package/dist/exceptions/date.exception.js +32 -0
- package/dist/exceptions/date.exception.js.map +1 -0
- package/dist/exceptions/db.exception.d.ts +13 -0
- package/dist/exceptions/db.exception.d.ts.map +1 -0
- package/dist/exceptions/db.exception.js +104 -0
- package/dist/exceptions/db.exception.js.map +1 -0
- package/dist/exceptions/generic.exception.d.ts +9 -0
- package/dist/exceptions/generic.exception.d.ts.map +1 -0
- package/dist/exceptions/generic.exception.js +25 -0
- package/dist/exceptions/generic.exception.js.map +1 -0
- package/dist/exceptions/id.exception.d.ts +8 -0
- package/dist/exceptions/id.exception.d.ts.map +1 -0
- package/dist/exceptions/id.exception.js +32 -0
- package/dist/exceptions/id.exception.js.map +1 -0
- package/dist/exceptions/implementation.exception.d.ts +13 -0
- package/dist/exceptions/implementation.exception.d.ts.map +1 -0
- package/dist/exceptions/implementation.exception.js +39 -0
- package/dist/exceptions/implementation.exception.js.map +1 -0
- package/dist/exceptions/index.d.ts +18 -0
- package/dist/exceptions/index.d.ts.map +1 -0
- package/dist/exceptions/index.js +41 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/int.exception.d.ts +7 -0
- package/dist/exceptions/int.exception.d.ts.map +1 -0
- package/dist/exceptions/int.exception.js +25 -0
- package/dist/exceptions/int.exception.js.map +1 -0
- package/dist/exceptions/interface.exception.d.ts +9 -0
- package/dist/exceptions/interface.exception.d.ts.map +1 -0
- package/dist/exceptions/interface.exception.js +27 -0
- package/dist/exceptions/interface.exception.js.map +1 -0
- package/dist/exceptions/json.exception.d.ts +8 -0
- package/dist/exceptions/json.exception.d.ts.map +1 -0
- package/dist/exceptions/json.exception.js +32 -0
- package/dist/exceptions/json.exception.js.map +1 -0
- package/dist/exceptions/not-found.exception.d.ts +9 -0
- package/dist/exceptions/not-found.exception.d.ts.map +1 -0
- package/dist/exceptions/not-found.exception.js +36 -0
- package/dist/exceptions/not-found.exception.js.map +1 -0
- package/dist/exceptions/string.exception.d.ts +8 -0
- package/dist/exceptions/string.exception.d.ts.map +1 -0
- package/dist/exceptions/string.exception.js +32 -0
- package/dist/exceptions/string.exception.js.map +1 -0
- package/dist/exceptions/text.exception.d.ts +8 -0
- package/dist/exceptions/text.exception.d.ts.map +1 -0
- package/dist/exceptions/text.exception.js +32 -0
- package/dist/exceptions/text.exception.js.map +1 -0
- package/dist/exceptions/unexpected.d.ts +17 -0
- package/dist/exceptions/unexpected.d.ts.map +1 -0
- package/dist/exceptions/unexpected.js +29 -0
- package/dist/exceptions/unexpected.js.map +1 -0
- package/dist/exceptions/validation.exception.d.ts +7 -0
- package/dist/exceptions/validation.exception.d.ts.map +1 -0
- package/dist/exceptions/validation.exception.js +24 -0
- package/dist/exceptions/validation.exception.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/native-bridge.d.ts +12 -0
- package/dist/native-bridge.d.ts.map +1 -0
- package/dist/native-bridge.js +26 -0
- package/dist/native-bridge.js.map +1 -0
- package/dist/result/index.d.ts +2 -0
- package/dist/result/index.d.ts.map +1 -0
- package/dist/result/index.js +18 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/result.d.ts +29 -0
- package/dist/result/result.d.ts.map +1 -0
- package/dist/result/result.js +60 -0
- package/dist/result/result.js.map +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +19 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schema-build.d.ts +20 -0
- package/dist/schema/schema-build.d.ts.map +1 -0
- package/dist/schema/schema-build.js +281 -0
- package/dist/schema/schema-build.js.map +1 -0
- package/dist/schema/schema-types.d.ts +90 -0
- package/dist/schema/schema-types.d.ts.map +1 -0
- package/dist/schema/schema-types.js +3 -0
- package/dist/schema/schema-types.js.map +1 -0
- package/dist/tools/formatting/date/date-formatting.tool.d.ts +45 -0
- package/dist/tools/formatting/date/date-formatting.tool.d.ts.map +1 -0
- package/dist/tools/formatting/date/date-formatting.tool.js +102 -0
- package/dist/tools/formatting/date/date-formatting.tool.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +25 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/parse/date/parse-date-ISO8601.tool.d.ts +61 -0
- package/dist/tools/parse/date/parse-date-ISO8601.tool.d.ts.map +1 -0
- package/dist/tools/parse/date/parse-date-ISO8601.tool.js +208 -0
- package/dist/tools/parse/date/parse-date-ISO8601.tool.js.map +1 -0
- package/dist/tools/parse/parse.tool.d.ts +5 -0
- package/dist/tools/parse/parse.tool.d.ts.map +1 -0
- package/dist/tools/parse/parse.tool.js +9 -0
- package/dist/tools/parse/parse.tool.js.map +1 -0
- package/dist/tools/type_guard.d.ts +28 -0
- package/dist/tools/type_guard.d.ts.map +1 -0
- package/dist/tools/type_guard.js +158 -0
- package/dist/tools/type_guard.js.map +1 -0
- package/dist/type-fields/api-key.format_vo.d.ts +23 -0
- package/dist/type-fields/api-key.format_vo.d.ts.map +1 -0
- package/dist/type-fields/api-key.format_vo.js +75 -0
- package/dist/type-fields/api-key.format_vo.js.map +1 -0
- package/dist/type-fields/bearer.format_vo.d.ts +20 -0
- package/dist/type-fields/bearer.format_vo.d.ts.map +1 -0
- package/dist/type-fields/bearer.format_vo.js +65 -0
- package/dist/type-fields/bearer.format_vo.js.map +1 -0
- package/dist/type-fields/bool-int.format_vo.d.ts +24 -0
- package/dist/type-fields/bool-int.format_vo.d.ts.map +1 -0
- package/dist/type-fields/bool-int.format_vo.js +58 -0
- package/dist/type-fields/bool-int.format_vo.js.map +1 -0
- package/dist/type-fields/boolean.format_vo.d.ts +19 -0
- package/dist/type-fields/boolean.format_vo.d.ts.map +1 -0
- package/dist/type-fields/boolean.format_vo.js +69 -0
- package/dist/type-fields/boolean.format_vo.js.map +1 -0
- package/dist/type-fields/date.format_vo.d.ts +67 -0
- package/dist/type-fields/date.format_vo.d.ts.map +1 -0
- package/dist/type-fields/date.format_vo.js +209 -0
- package/dist/type-fields/date.format_vo.js.map +1 -0
- package/dist/type-fields/descricao.format_vo.d.ts +19 -0
- package/dist/type-fields/descricao.format_vo.d.ts.map +1 -0
- package/dist/type-fields/descricao.format_vo.js +50 -0
- package/dist/type-fields/descricao.format_vo.js.map +1 -0
- package/dist/type-fields/email.format_vo.d.ts +20 -0
- package/dist/type-fields/email.format_vo.d.ts.map +1 -0
- package/dist/type-fields/email.format_vo.js +58 -0
- package/dist/type-fields/email.format_vo.js.map +1 -0
- package/dist/type-fields/http-status.format_vo.d.ts +20 -0
- package/dist/type-fields/http-status.format_vo.d.ts.map +1 -0
- package/dist/type-fields/http-status.format_vo.js +56 -0
- package/dist/type-fields/http-status.format_vo.js.map +1 -0
- package/dist/type-fields/id-req.format_vo.d.ts +19 -0
- package/dist/type-fields/id-req.format_vo.d.ts.map +1 -0
- package/dist/type-fields/id-req.format_vo.js +50 -0
- package/dist/type-fields/id-req.format_vo.js.map +1 -0
- package/dist/type-fields/id.format_vo.d.ts +21 -0
- package/dist/type-fields/id.format_vo.d.ts.map +1 -0
- package/dist/type-fields/id.format_vo.js +68 -0
- package/dist/type-fields/id.format_vo.js.map +1 -0
- package/dist/type-fields/index.d.ts +26 -0
- package/dist/type-fields/index.d.ts.map +1 -0
- package/dist/type-fields/index.js +59 -0
- package/dist/type-fields/index.js.map +1 -0
- package/dist/type-fields/int.format_vo.d.ts +19 -0
- package/dist/type-fields/int.format_vo.d.ts.map +1 -0
- package/dist/type-fields/int.format_vo.js +58 -0
- package/dist/type-fields/int.format_vo.js.map +1 -0
- package/dist/type-fields/json.format_vo.d.ts +25 -0
- package/dist/type-fields/json.format_vo.d.ts.map +1 -0
- package/dist/type-fields/json.format_vo.js +84 -0
- package/dist/type-fields/json.format_vo.js.map +1 -0
- package/dist/type-fields/nome-completo.format_vo.d.ts +19 -0
- package/dist/type-fields/nome-completo.format_vo.d.ts.map +1 -0
- package/dist/type-fields/nome-completo.format_vo.js +50 -0
- package/dist/type-fields/nome-completo.format_vo.js.map +1 -0
- package/dist/type-fields/page-number.format_vo.d.ts +19 -0
- package/dist/type-fields/page-number.format_vo.d.ts.map +1 -0
- package/dist/type-fields/page-number.format_vo.js +61 -0
- package/dist/type-fields/page-number.format_vo.js.map +1 -0
- package/dist/type-fields/page-size.format_vo.d.ts +19 -0
- package/dist/type-fields/page-size.format_vo.d.ts.map +1 -0
- package/dist/type-fields/page-size.format_vo.js +64 -0
- package/dist/type-fields/page-size.format_vo.js.map +1 -0
- package/dist/type-fields/password.format_vo.d.ts +23 -0
- package/dist/type-fields/password.format_vo.d.ts.map +1 -0
- package/dist/type-fields/password.format_vo.js +66 -0
- package/dist/type-fields/password.format_vo.js.map +1 -0
- package/dist/type-fields/public-key-pem.format_vo.d.ts +22 -0
- package/dist/type-fields/public-key-pem.format_vo.d.ts.map +1 -0
- package/dist/type-fields/public-key-pem.format_vo.js +70 -0
- package/dist/type-fields/public-key-pem.format_vo.js.map +1 -0
- package/dist/type-fields/signature.format_vo.d.ts +20 -0
- package/dist/type-fields/signature.format_vo.d.ts.map +1 -0
- package/dist/type-fields/signature.format_vo.js +61 -0
- package/dist/type-fields/signature.format_vo.js.map +1 -0
- package/dist/type-fields/status-aplicacao.format_vo.d.ts +27 -0
- package/dist/type-fields/status-aplicacao.format_vo.d.ts.map +1 -0
- package/dist/type-fields/status-aplicacao.format_vo.js +69 -0
- package/dist/type-fields/status-aplicacao.format_vo.js.map +1 -0
- package/dist/type-fields/string.format_vo.d.ts +19 -0
- package/dist/type-fields/string.format_vo.d.ts.map +1 -0
- package/dist/type-fields/string.format_vo.js +50 -0
- package/dist/type-fields/string.format_vo.js.map +1 -0
- package/dist/type-fields/text.format_vo.d.ts +19 -0
- package/dist/type-fields/text.format_vo.d.ts.map +1 -0
- package/dist/type-fields/text.format_vo.js +50 -0
- package/dist/type-fields/text.format_vo.js.map +1 -0
- package/dist/type-fields/trace-id.format_vo.d.ts +118 -0
- package/dist/type-fields/trace-id.format_vo.d.ts.map +1 -0
- package/dist/type-fields/trace-id.format_vo.js +120 -0
- package/dist/type-fields/trace-id.format_vo.js.map +1 -0
- package/dist/type-fields/type-field.base.d.ts +37 -0
- package/dist/type-fields/type-field.base.d.ts.map +1 -0
- package/dist/type-fields/type-field.base.js +108 -0
- package/dist/type-fields/type-field.base.js.map +1 -0
- package/dist/type-fields/type-field.config.d.ts +44 -0
- package/dist/type-fields/type-field.config.d.ts.map +1 -0
- package/dist/type-fields/type-field.config.js +3 -0
- package/dist/type-fields/type-field.config.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ExceptionDate } from "../../../exceptions/date.exception";
|
|
2
|
+
import { Result } from "../../../result/result";
|
|
3
|
+
export declare class ToolParseDateISO8601 {
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a Date object represents a valid date.
|
|
6
|
+
* @param date The Date object to check.
|
|
7
|
+
* @returns `true` if the date is valid, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
static isValidDate(date: Date): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Helper to create the specific date invalid exception.
|
|
12
|
+
* @returns An instance of ExceptionDate.
|
|
13
|
+
*/
|
|
14
|
+
private static createError;
|
|
15
|
+
/**
|
|
16
|
+
* Faz o parse de um datetime no formato ISO8601 com UTC obrigatório (sufixo "Z").
|
|
17
|
+
* Exemplo válido: "2025-03-24T15:30:45Z"
|
|
18
|
+
*/
|
|
19
|
+
static parseDateTimeUTC(value: unknown): Result<Date, ExceptionDate>;
|
|
20
|
+
/**
|
|
21
|
+
* Parses a string potentially representing a full ISO 8601 DateTime (like '2025-03-24T15:30:45' or '2025-03-24T15:30:45Z').
|
|
22
|
+
* Also accepts existing Date objects. Relies on the Date constructor's parsing and validates the result.
|
|
23
|
+
* @param value The input value (string, Date, or other).
|
|
24
|
+
* @returns Result<Date, ExceptionDate>
|
|
25
|
+
*/
|
|
26
|
+
static parseDateTime(value: unknown): Result<Date, ExceptionDate>;
|
|
27
|
+
/**
|
|
28
|
+
* Parses a string potentially representing an ISO 8601 Date only (like '2025-03-24').
|
|
29
|
+
* Also accepts existing Date objects (normalizes time to UTC midnight).
|
|
30
|
+
* @param value The input value (string, Date, or other).
|
|
31
|
+
* @returns Result<Date, ExceptionDate>
|
|
32
|
+
*/
|
|
33
|
+
static parseDate(value: unknown): Result<Date, ExceptionDate>;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a compact ISO 8601 Date string (like '20250324').
|
|
36
|
+
* Also accepts existing Date objects (normalizes time to UTC midnight).
|
|
37
|
+
* @param value The input value (string, Date, or other).
|
|
38
|
+
* @returns Result<Date, ExceptionDate>
|
|
39
|
+
*/
|
|
40
|
+
static parseDateCompact(value: unknown): Result<Date, ExceptionDate>;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a compact ISO 8601 DateTime string where date is compact but time has separators (like '20250324T15:30:45').
|
|
43
|
+
* Also accepts existing Date objects.
|
|
44
|
+
* @param value The input value (string, Date, or other).
|
|
45
|
+
* @returns Result<Date, ExceptionDate>
|
|
46
|
+
*/
|
|
47
|
+
static parseDateTimeCompactWithT(value: unknown): Result<Date, ExceptionDate>;
|
|
48
|
+
/**
|
|
49
|
+
* Parses a fully compact ISO 8601 DateTime string (like '20250324153045').
|
|
50
|
+
* Also accepts existing Date objects.
|
|
51
|
+
* @param value The input value (string, Date, or other).
|
|
52
|
+
* @returns Result<Date, ExceptionDate>
|
|
53
|
+
*/
|
|
54
|
+
static parseDateTimeFullCompact(value: unknown): Result<Date, ExceptionDate>;
|
|
55
|
+
/**
|
|
56
|
+
* Faz o parse de um datetime ISO8601 com milissegundos e UTC (sufixo 'Z').
|
|
57
|
+
* Exemplo válido: "2025-03-24T15:30:45.123Z"
|
|
58
|
+
*/
|
|
59
|
+
static parseDateTimeZuluWithMillis(value: unknown): Result<Date, ExceptionDate>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=parse-date-ISO8601.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-date-ISO8601.tool.d.ts","sourceRoot":"","sources":["../../../../src/tools/parse/date/parse-date-ISO8601.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAW,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,oBAAoB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAKvC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAG1B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IAwBpE;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IAkBjE;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IAyB7D;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IAiCpE;;;;;OAKG;IACH,MAAM,CAAC,yBAAyB,CAC9B,KAAK,EAAE,OAAO,GACb,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IA2B9B;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IA4B5E;;;OAGG;IACH,MAAM,CAAC,2BAA2B,CAChC,KAAK,EAAE,OAAO,GACb,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;CAkB/B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolParseDateISO8601 = void 0;
|
|
4
|
+
const date_exception_1 = require("../../../exceptions/date.exception");
|
|
5
|
+
const result_1 = require("../../../result/result");
|
|
6
|
+
class ToolParseDateISO8601 {
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a Date object represents a valid date.
|
|
9
|
+
* @param date The Date object to check.
|
|
10
|
+
* @returns `true` if the date is valid, `false` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
static isValidDate(date) {
|
|
13
|
+
// Check for invalid date objects (e.g., from new Date('invalid string'))
|
|
14
|
+
return !isNaN(date.getTime());
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper to create the specific date invalid exception.
|
|
18
|
+
* @returns An instance of ExceptionDate.
|
|
19
|
+
*/
|
|
20
|
+
static createError() {
|
|
21
|
+
return date_exception_1.ExceptionDate.invalid("data");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Faz o parse de um datetime no formato ISO8601 com UTC obrigatório (sufixo "Z").
|
|
25
|
+
* Exemplo válido: "2025-03-24T15:30:45Z"
|
|
26
|
+
*/
|
|
27
|
+
static parseDateTimeUTC(value) {
|
|
28
|
+
if (value instanceof Date) {
|
|
29
|
+
return this.isValidDate(value) ? (0, result_1.ok)(value) : (0, result_1.err)(this.createError());
|
|
30
|
+
}
|
|
31
|
+
if (typeof value !== "string") {
|
|
32
|
+
return (0, result_1.err)(this.createError());
|
|
33
|
+
}
|
|
34
|
+
// Valida se termina com 'Z' para garantir que é UTC
|
|
35
|
+
if (!value.endsWith("Z")) {
|
|
36
|
+
return (0, result_1.err)(this.createError());
|
|
37
|
+
}
|
|
38
|
+
// Regex opcional (se quiser reforçar o padrão)
|
|
39
|
+
const regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
40
|
+
if (!regex.test(value)) {
|
|
41
|
+
return (0, result_1.err)(this.createError());
|
|
42
|
+
}
|
|
43
|
+
const date = new Date(value);
|
|
44
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parses a string potentially representing a full ISO 8601 DateTime (like '2025-03-24T15:30:45' or '2025-03-24T15:30:45Z').
|
|
48
|
+
* Also accepts existing Date objects. Relies on the Date constructor's parsing and validates the result.
|
|
49
|
+
* @param value The input value (string, Date, or other).
|
|
50
|
+
* @returns Result<Date, ExceptionDate>
|
|
51
|
+
*/
|
|
52
|
+
static parseDateTime(value) {
|
|
53
|
+
if (value instanceof Date) {
|
|
54
|
+
// If it's already a Date object, just validate it
|
|
55
|
+
return this.isValidDate(value) ? (0, result_1.ok)(value) : (0, result_1.err)(this.createError());
|
|
56
|
+
}
|
|
57
|
+
// Expect a string for parsing
|
|
58
|
+
if (typeof value !== "string") {
|
|
59
|
+
return (0, result_1.err)(this.createError());
|
|
60
|
+
}
|
|
61
|
+
// Attempt to parse the string using the built-in Date constructor
|
|
62
|
+
const date = new Date(value);
|
|
63
|
+
// Check if the resulting Date object is valid (handles 'Invalid Date')
|
|
64
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parses a string potentially representing an ISO 8601 Date only (like '2025-03-24').
|
|
68
|
+
* Also accepts existing Date objects (normalizes time to UTC midnight).
|
|
69
|
+
* @param value The input value (string, Date, or other).
|
|
70
|
+
* @returns Result<Date, ExceptionDate>
|
|
71
|
+
*/
|
|
72
|
+
static parseDate(value) {
|
|
73
|
+
if (value instanceof Date) {
|
|
74
|
+
// Normalize existing Date objects to UTC midnight for consistency
|
|
75
|
+
if (!this.isValidDate(value))
|
|
76
|
+
return (0, result_1.err)(this.createError());
|
|
77
|
+
const dateOnly = new Date(value);
|
|
78
|
+
dateOnly.setUTCHours(0, 0, 0, 0); // Set time components to zero UTC
|
|
79
|
+
return (0, result_1.ok)(dateOnly);
|
|
80
|
+
}
|
|
81
|
+
if (typeof value !== "string") {
|
|
82
|
+
return (0, result_1.err)(this.createError());
|
|
83
|
+
}
|
|
84
|
+
// Basic format check for YYYY-MM-DD
|
|
85
|
+
const regex = /^\d{4}-\d{2}-\d{2}$/;
|
|
86
|
+
if (!regex.test(value)) {
|
|
87
|
+
return (0, result_1.err)(this.createError());
|
|
88
|
+
}
|
|
89
|
+
// Append time and 'Z' (UTC indicator) for reliable parsing to UTC midnight
|
|
90
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
91
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parses a compact ISO 8601 Date string (like '20250324').
|
|
95
|
+
* Also accepts existing Date objects (normalizes time to UTC midnight).
|
|
96
|
+
* @param value The input value (string, Date, or other).
|
|
97
|
+
* @returns Result<Date, ExceptionDate>
|
|
98
|
+
*/
|
|
99
|
+
static parseDateCompact(value) {
|
|
100
|
+
try {
|
|
101
|
+
if (value instanceof Date) {
|
|
102
|
+
// Normalize existing Date objects to UTC midnight
|
|
103
|
+
if (!this.isValidDate(value))
|
|
104
|
+
return (0, result_1.err)(this.createError());
|
|
105
|
+
const dateOnly = new Date(value);
|
|
106
|
+
dateOnly.setUTCHours(0, 0, 0, 0);
|
|
107
|
+
return (0, result_1.ok)(dateOnly);
|
|
108
|
+
}
|
|
109
|
+
if (typeof value !== "string") {
|
|
110
|
+
return (0, result_1.err)(this.createError());
|
|
111
|
+
}
|
|
112
|
+
// Check for exactly 8 digits
|
|
113
|
+
const regex = /^\d{8}$/;
|
|
114
|
+
if (!regex.test(value)) {
|
|
115
|
+
return (0, result_1.err)(this.createError());
|
|
116
|
+
}
|
|
117
|
+
// Extract parts and reconstruct standard ISO string with UTC time
|
|
118
|
+
const year = value.substring(0, 4);
|
|
119
|
+
const month = value.substring(4, 6);
|
|
120
|
+
const day = value.substring(6, 8);
|
|
121
|
+
const isoString = `${year}-${month}-${day}T00:00:00Z`; // Use Z for UTC
|
|
122
|
+
const date = new Date(isoString);
|
|
123
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return (0, result_1.err)(this.createError());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Parses a compact ISO 8601 DateTime string where date is compact but time has separators (like '20250324T15:30:45').
|
|
131
|
+
* Also accepts existing Date objects.
|
|
132
|
+
* @param value The input value (string, Date, or other).
|
|
133
|
+
* @returns Result<Date, ExceptionDate>
|
|
134
|
+
*/
|
|
135
|
+
static parseDateTimeCompactWithT(value) {
|
|
136
|
+
if (value instanceof Date) {
|
|
137
|
+
return this.isValidDate(value) ? (0, result_1.ok)(value) : (0, result_1.err)(this.createError());
|
|
138
|
+
}
|
|
139
|
+
if (typeof value !== "string") {
|
|
140
|
+
return (0, result_1.err)(this.createError());
|
|
141
|
+
}
|
|
142
|
+
// Check for format YYYYMMDDTHH:MM:SS
|
|
143
|
+
const regex = /^\d{8}T\d{2}:\d{2}:\d{2}$/;
|
|
144
|
+
if (!regex.test(value)) {
|
|
145
|
+
return (0, result_1.err)(this.createError());
|
|
146
|
+
}
|
|
147
|
+
// Extract parts and reconstruct standard ISO string for reliable parsing
|
|
148
|
+
const year = value.substring(0, 4);
|
|
149
|
+
const month = value.substring(4, 6);
|
|
150
|
+
const day = value.substring(6, 8);
|
|
151
|
+
const time = value.substring(9); // e.g., 15:30:45
|
|
152
|
+
// NOTE: Creates date in local timezone unless input implies otherwise (e.g., if T time was Z or offset)
|
|
153
|
+
const isoString = `${year}-${month}-${day}T${time}`;
|
|
154
|
+
const date = new Date(isoString);
|
|
155
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Parses a fully compact ISO 8601 DateTime string (like '20250324153045').
|
|
159
|
+
* Also accepts existing Date objects.
|
|
160
|
+
* @param value The input value (string, Date, or other).
|
|
161
|
+
* @returns Result<Date, ExceptionDate>
|
|
162
|
+
*/
|
|
163
|
+
static parseDateTimeFullCompact(value) {
|
|
164
|
+
if (value instanceof Date) {
|
|
165
|
+
return this.isValidDate(value) ? (0, result_1.ok)(value) : (0, result_1.err)(this.createError());
|
|
166
|
+
}
|
|
167
|
+
if (typeof value !== "string") {
|
|
168
|
+
return (0, result_1.err)(this.createError());
|
|
169
|
+
}
|
|
170
|
+
// Check for exactly 14 digits
|
|
171
|
+
const regex = /^\d{14}$/;
|
|
172
|
+
if (!regex.test(value)) {
|
|
173
|
+
return (0, result_1.err)(this.createError());
|
|
174
|
+
}
|
|
175
|
+
// Extract parts and reconstruct standard ISO string
|
|
176
|
+
const year = value.substring(0, 4);
|
|
177
|
+
const month = value.substring(4, 6);
|
|
178
|
+
const day = value.substring(6, 8);
|
|
179
|
+
const hours = value.substring(8, 10);
|
|
180
|
+
const minutes = value.substring(10, 12);
|
|
181
|
+
const seconds = value.substring(12, 14);
|
|
182
|
+
// NOTE: Creates date in local timezone. Append 'Z' if input implies UTC.
|
|
183
|
+
const isoString = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
|
|
184
|
+
const date = new Date(isoString);
|
|
185
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Faz o parse de um datetime ISO8601 com milissegundos e UTC (sufixo 'Z').
|
|
189
|
+
* Exemplo válido: "2025-03-24T15:30:45.123Z"
|
|
190
|
+
*/
|
|
191
|
+
static parseDateTimeZuluWithMillis(value) {
|
|
192
|
+
if (value instanceof Date) {
|
|
193
|
+
return this.isValidDate(value) ? (0, result_1.ok)(value) : (0, result_1.err)(this.createError());
|
|
194
|
+
}
|
|
195
|
+
if (typeof value !== "string") {
|
|
196
|
+
return (0, result_1.err)(this.createError());
|
|
197
|
+
}
|
|
198
|
+
// Regex para validar formato: YYYY-MM-DDTHH:mm:ss.sssZ
|
|
199
|
+
const regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
200
|
+
if (!regex.test(value)) {
|
|
201
|
+
return (0, result_1.err)(this.createError());
|
|
202
|
+
}
|
|
203
|
+
const date = new Date(value);
|
|
204
|
+
return this.isValidDate(date) ? (0, result_1.ok)(date) : (0, result_1.err)(this.createError());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.ToolParseDateISO8601 = ToolParseDateISO8601;
|
|
208
|
+
//# sourceMappingURL=parse-date-ISO8601.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-date-ISO8601.tool.js","sourceRoot":"","sources":["../../../../src/tools/parse/date/parse-date-ISO8601.tool.ts"],"names":[],"mappings":";;;AAAA,uEAAmE;AACnE,mDAAyD;AAEzD,MAAa,oBAAoB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,IAAU;QAC3B,yEAAyE;QACzE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,WAAW;QACxB,OAAO,8BAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAc;QACpC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,WAAE,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACjC,CAAC;QAED,oDAAoD;QACpD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACjC,CAAC;QAED,+CAA+C;QAC/C,MAAM,KAAK,GAAG,gDAAgD,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,OA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
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolParse = void 0;
|
|
4
|
+
const parse_date_ISO8601_tool_1 = require("./date/parse-date-ISO8601.tool");
|
|
5
|
+
class ToolParse {
|
|
6
|
+
static dateISO8601 = parse_date_ISO8601_tool_1.ToolParseDateISO8601;
|
|
7
|
+
}
|
|
8
|
+
exports.ToolParse = ToolParse;
|
|
9
|
+
//# sourceMappingURL=parse.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.tool.js","sourceRoot":"","sources":["../../../src/tools/parse/parse.tool.ts"],"names":[],"mappings":";;;AAAA,4EAAsE;AAEtE,MAAa,SAAS;IACb,MAAM,CAAC,WAAW,GAAG,8CAAoB,CAAC;;AADnD,8BAEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Result } from "../result/result";
|
|
2
|
+
import { ExceptionValidation } from "../exceptions/validation.exception";
|
|
3
|
+
export declare class TypeGuard {
|
|
4
|
+
static isEnumKey<T extends object>(enumObj: T, value: string | number, fieldPath: string): Result<true, ExceptionValidation>;
|
|
5
|
+
static isEnumValue<T extends object>(enumObj: T, value: string | number, fieldPath: string): Result<true, ExceptionValidation>;
|
|
6
|
+
static isHex(value: unknown, fieldPath: string, length?: number): Result<true, ExceptionValidation>;
|
|
7
|
+
static isEmpty(value: unknown): boolean;
|
|
8
|
+
static isPositiveInteger(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
9
|
+
static isNegativeInteger(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
10
|
+
static isPositiveNumber(value: unknown, fieldPath: string, decimalPrecision?: number): Result<true, ExceptionValidation>;
|
|
11
|
+
static isNegativeNumber(value: unknown, fieldPath: string, decimalPrecision?: number): Result<true, ExceptionValidation>;
|
|
12
|
+
static isString(value: unknown, fieldPath: string, min?: number, max?: number): Result<true, ExceptionValidation>;
|
|
13
|
+
static isNumber(value: unknown, fieldPath: string, min?: number, max?: number, decimalPrecision?: number): Result<true, ExceptionValidation>;
|
|
14
|
+
static isInteger(value: unknown, fieldPath: string, min?: number, max?: number): Result<true, ExceptionValidation>;
|
|
15
|
+
static isArray(value: unknown, fieldPath: string, min?: number, max?: number): Result<true, ExceptionValidation>;
|
|
16
|
+
static isBoolean(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
17
|
+
static isObject(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
18
|
+
static isFunction(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
19
|
+
static isNull(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
20
|
+
static isUndefined(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
21
|
+
static isDate(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
22
|
+
static isRegExp(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
23
|
+
static isSymbol(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
24
|
+
static isBigInt(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
25
|
+
static isSet(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
26
|
+
static isMap(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=type_guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_guard.d.ts","sourceRoot":"","sources":["../../src/tools/type_guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,qBAAa,SAAS;IACpB,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,MAAM,EAC/B,OAAO,EAAE,CAAC,EACV,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,IAAI,EAAE,mBAAm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I,EAAE,mBAAmB,CAAC;IAQpC,MAAM,CAAC,QAAQ,CACb,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAQpC,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAMpC,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC;CAKrC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeGuard = void 0;
|
|
4
|
+
const result_1 = require("../result/result");
|
|
5
|
+
const validation_exception_1 = require("../exceptions/validation.exception");
|
|
6
|
+
class TypeGuard {
|
|
7
|
+
static isEnumKey(enumObj, value, fieldPath) {
|
|
8
|
+
return Object.keys(enumObj).includes(value.toString())
|
|
9
|
+
? result_1.OK_TRUE
|
|
10
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O valor '${value}' não é uma chave válida do enum.`));
|
|
11
|
+
}
|
|
12
|
+
static isEnumValue(enumObj, value, fieldPath) {
|
|
13
|
+
return Object.values(enumObj).includes(value)
|
|
14
|
+
? result_1.OK_TRUE
|
|
15
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O valor '${value}' não é um valor válido do enum.`));
|
|
16
|
+
}
|
|
17
|
+
static isHex(value, fieldPath, length) {
|
|
18
|
+
const val = String(value).toLowerCase();
|
|
19
|
+
const isValid = /^0x[a-f0-9]+$/.test(val);
|
|
20
|
+
if (!isValid) {
|
|
21
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um hexadecimal iniciado por 0x."));
|
|
22
|
+
}
|
|
23
|
+
if (length && val.length !== length + 2) {
|
|
24
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `Hexadecimal deve conter ${length} dígitos úteis (sem contar o '0x').`));
|
|
25
|
+
}
|
|
26
|
+
return result_1.OK_TRUE;
|
|
27
|
+
}
|
|
28
|
+
static isEmpty(value) {
|
|
29
|
+
if (value === null || value === undefined)
|
|
30
|
+
return true;
|
|
31
|
+
if (typeof value === "string")
|
|
32
|
+
return value.trim() === "";
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value.length === 0;
|
|
35
|
+
if (value instanceof Set || value instanceof Map)
|
|
36
|
+
return value.size === 0;
|
|
37
|
+
if (typeof value === "object")
|
|
38
|
+
return Object.keys(value).length === 0;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// Variações de inteiros e números
|
|
42
|
+
static isPositiveInteger(value, fieldPath) {
|
|
43
|
+
return this.isInteger(value, fieldPath, 0);
|
|
44
|
+
}
|
|
45
|
+
static isNegativeInteger(value, fieldPath) {
|
|
46
|
+
return this.isInteger(value, fieldPath, Number.MIN_SAFE_INTEGER, -1);
|
|
47
|
+
}
|
|
48
|
+
static isPositiveNumber(value, fieldPath, decimalPrecision = Infinity) {
|
|
49
|
+
return this.isNumber(value, fieldPath, 0, Number.MAX_SAFE_INTEGER, decimalPrecision);
|
|
50
|
+
}
|
|
51
|
+
static isNegativeNumber(value, fieldPath, decimalPrecision = Infinity) {
|
|
52
|
+
return this.isNumber(value, fieldPath, Number.MIN_SAFE_INTEGER, -Number.MIN_VALUE, decimalPrecision);
|
|
53
|
+
}
|
|
54
|
+
static isString(value, fieldPath, min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
55
|
+
if (typeof value !== "string") {
|
|
56
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser uma string."));
|
|
57
|
+
}
|
|
58
|
+
const len = value.length;
|
|
59
|
+
if (len > max) {
|
|
60
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `A string deve conter no máximo ${max} caracteres.`));
|
|
61
|
+
}
|
|
62
|
+
if (len < min) {
|
|
63
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `A string deve conter no mínimo ${min} caracteres úteis.`));
|
|
64
|
+
}
|
|
65
|
+
return result_1.OK_TRUE;
|
|
66
|
+
}
|
|
67
|
+
static isNumber(value, fieldPath, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, decimalPrecision = Infinity) {
|
|
68
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
69
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um número válido."));
|
|
70
|
+
}
|
|
71
|
+
if (value < min) {
|
|
72
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O valor deve ser no mínimo ${min}.`));
|
|
73
|
+
}
|
|
74
|
+
if (value > max) {
|
|
75
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O valor deve ser no máximo ${max}.`));
|
|
76
|
+
}
|
|
77
|
+
const [, decimals] = value.toString().split(".");
|
|
78
|
+
if ((decimals?.length ?? 0) > decimalPrecision) {
|
|
79
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O valor deve ter no máximo ${decimalPrecision} casas decimais.`));
|
|
80
|
+
}
|
|
81
|
+
return result_1.OK_TRUE;
|
|
82
|
+
}
|
|
83
|
+
static isInteger(value, fieldPath, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
84
|
+
if (!Number.isInteger(value)) {
|
|
85
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O número deve ser um inteiro."));
|
|
86
|
+
}
|
|
87
|
+
return this.isNumber(value, fieldPath, min, max, 0);
|
|
88
|
+
}
|
|
89
|
+
static isArray(value, fieldPath, min = 0, max = Number.MAX_SAFE_INTEGER) {
|
|
90
|
+
if (!Array.isArray(value)) {
|
|
91
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um array."));
|
|
92
|
+
}
|
|
93
|
+
if (value.length < min) {
|
|
94
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O array deve conter no mínimo ${min} itens.`));
|
|
95
|
+
}
|
|
96
|
+
if (value.length > max) {
|
|
97
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, `O array deve conter no máximo ${max} itens.`));
|
|
98
|
+
}
|
|
99
|
+
return result_1.OK_TRUE;
|
|
100
|
+
}
|
|
101
|
+
static isBoolean(value, fieldPath) {
|
|
102
|
+
return typeof value === "boolean"
|
|
103
|
+
? result_1.OK_TRUE
|
|
104
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um booleano."));
|
|
105
|
+
}
|
|
106
|
+
static isObject(value, fieldPath) {
|
|
107
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
108
|
+
? result_1.OK_TRUE
|
|
109
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um objeto válido."));
|
|
110
|
+
}
|
|
111
|
+
static isFunction(value, fieldPath) {
|
|
112
|
+
return typeof value === "function"
|
|
113
|
+
? result_1.OK_TRUE
|
|
114
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser uma função."));
|
|
115
|
+
}
|
|
116
|
+
static isNull(value, fieldPath) {
|
|
117
|
+
return value === null
|
|
118
|
+
? result_1.OK_TRUE
|
|
119
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser null."));
|
|
120
|
+
}
|
|
121
|
+
static isUndefined(value, fieldPath) {
|
|
122
|
+
return typeof value === "undefined"
|
|
123
|
+
? result_1.OK_TRUE
|
|
124
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser undefined."));
|
|
125
|
+
}
|
|
126
|
+
static isDate(value, fieldPath) {
|
|
127
|
+
return value instanceof Date && !isNaN(value.getTime())
|
|
128
|
+
? result_1.OK_TRUE
|
|
129
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser uma data válida."));
|
|
130
|
+
}
|
|
131
|
+
static isRegExp(value, fieldPath) {
|
|
132
|
+
return value instanceof RegExp
|
|
133
|
+
? result_1.OK_TRUE
|
|
134
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser uma expressão regular."));
|
|
135
|
+
}
|
|
136
|
+
static isSymbol(value, fieldPath) {
|
|
137
|
+
return typeof value === "symbol"
|
|
138
|
+
? result_1.OK_TRUE
|
|
139
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um símbolo."));
|
|
140
|
+
}
|
|
141
|
+
static isBigInt(value, fieldPath) {
|
|
142
|
+
return typeof value === "bigint"
|
|
143
|
+
? result_1.OK_TRUE
|
|
144
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um bigint."));
|
|
145
|
+
}
|
|
146
|
+
static isSet(value, fieldPath) {
|
|
147
|
+
return value instanceof Set
|
|
148
|
+
? result_1.OK_TRUE
|
|
149
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um Set."));
|
|
150
|
+
}
|
|
151
|
+
static isMap(value, fieldPath) {
|
|
152
|
+
return value instanceof Map
|
|
153
|
+
? result_1.OK_TRUE
|
|
154
|
+
: (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "O valor deve ser um Map."));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.TypeGuard = TypeGuard;
|
|
158
|
+
//# sourceMappingURL=type_guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_guard.js","sourceRoot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C,KAAK,CACV,KAAc,EACd,SAAiB;QAEjB,OAAO,KAAK,YAAY,GAAG;YACzB,CAAC,CAAC,gBAAO;YACT,CAAC,CAAC,IAAA,YAAG,EAAC,0CAAmB,CAAC,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,KAAK,CACV,KAAc,EACd,SAAiB;QAEjB,OAAO,KAAK,YAAY,GAAG;YACzB,CAAC,CAAC,gBAAO;YACT,CAAC,CAAC,IAAA,YAAG,EAAC,0CAAmB,CAAC,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAjWD,8BAiWC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TypeField } from "../type-fields/type-field.base";
|
|
2
|
+
import { ITypeFieldConfig } from "../type-fields/type-field.config";
|
|
3
|
+
import { Result } from "../result";
|
|
4
|
+
import { ExceptionValidation } from "../exceptions/validation.exception";
|
|
5
|
+
export type TApiKey = string;
|
|
6
|
+
export declare class FApiKey extends TypeField<TApiKey> {
|
|
7
|
+
readonly typeInference = "FApiKey";
|
|
8
|
+
readonly config: ITypeFieldConfig<TApiKey>;
|
|
9
|
+
private constructor();
|
|
10
|
+
static validateRaw(value: unknown, fieldPath: string): Result<true, ExceptionValidation>;
|
|
11
|
+
static create(raw: TApiKey, fieldPath?: string): Result<FApiKey, ExceptionValidation>;
|
|
12
|
+
static createOrThrow(raw: TApiKey, fieldPath?: string): FApiKey;
|
|
13
|
+
static generate(): FApiKey;
|
|
14
|
+
static generateString(): string;
|
|
15
|
+
static isValid(value: string): boolean;
|
|
16
|
+
validate(value: TApiKey, fieldPath: string): Result<true, ExceptionValidation>;
|
|
17
|
+
toSafeDisplay(): string;
|
|
18
|
+
toString(): string;
|
|
19
|
+
formatted(): string;
|
|
20
|
+
getDescription(): string;
|
|
21
|
+
getShortDescription(): string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMapping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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FApiKey = void 0;
|
|
4
|
+
const type_field_base_1 = require("../type-fields/type-field.base");
|
|
5
|
+
const result_1 = require("../result");
|
|
6
|
+
const validation_exception_1 = require("../exceptions/validation.exception");
|
|
7
|
+
const type_guard_1 = require("../tools/type_guard");
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
class FApiKey extends type_field_base_1.TypeField {
|
|
10
|
+
typeInference = "FApiKey";
|
|
11
|
+
config = {
|
|
12
|
+
jsonSchemaType: "string",
|
|
13
|
+
minLength: 36,
|
|
14
|
+
maxLength: 36,
|
|
15
|
+
serializeAsString: false,
|
|
16
|
+
};
|
|
17
|
+
constructor(value, fieldPath) {
|
|
18
|
+
super(value, fieldPath);
|
|
19
|
+
}
|
|
20
|
+
static validateRaw(value, fieldPath) {
|
|
21
|
+
const base = type_guard_1.TypeGuard.isString(value, fieldPath, 36, 36);
|
|
22
|
+
if (!base.success)
|
|
23
|
+
return base;
|
|
24
|
+
if (!(0, uuid_1.validate)(value)) {
|
|
25
|
+
return (0, result_1.err)(validation_exception_1.ExceptionValidation.create(fieldPath, "ApiKey deve ser UUID valido"));
|
|
26
|
+
}
|
|
27
|
+
return result_1.OK_TRUE;
|
|
28
|
+
}
|
|
29
|
+
static create(raw, fieldPath = "ApiKey") {
|
|
30
|
+
const validation = FApiKey.validateRaw(raw, fieldPath);
|
|
31
|
+
if (!validation.success)
|
|
32
|
+
return (0, result_1.err)(validation.error);
|
|
33
|
+
return (0, result_1.ok)(new FApiKey(raw, fieldPath));
|
|
34
|
+
}
|
|
35
|
+
static createOrThrow(raw, fieldPath = "ApiKey") {
|
|
36
|
+
const result = this.create(raw, fieldPath);
|
|
37
|
+
if ((0, result_1.isFailure)(result))
|
|
38
|
+
throw result.error;
|
|
39
|
+
return result.value;
|
|
40
|
+
}
|
|
41
|
+
static generate() {
|
|
42
|
+
return FApiKey.createOrThrow((0, uuid_1.v4)(), "ApiKey");
|
|
43
|
+
}
|
|
44
|
+
static generateString() {
|
|
45
|
+
return (0, uuid_1.v4)();
|
|
46
|
+
}
|
|
47
|
+
static isValid(value) {
|
|
48
|
+
return (0, uuid_1.validate)(value) && (0, uuid_1.version)(value) === 4;
|
|
49
|
+
}
|
|
50
|
+
validate(value, fieldPath) {
|
|
51
|
+
return FApiKey.validateRaw(value, fieldPath);
|
|
52
|
+
}
|
|
53
|
+
toSafeDisplay() {
|
|
54
|
+
const value = this.getValue();
|
|
55
|
+
const segments = value.split("-");
|
|
56
|
+
if (segments.length !== 5) {
|
|
57
|
+
return "****-****-****-****-************";
|
|
58
|
+
}
|
|
59
|
+
return `${segments[0]}-****-****-****-${segments[4]}`;
|
|
60
|
+
}
|
|
61
|
+
toString() {
|
|
62
|
+
return String(this.getValue());
|
|
63
|
+
}
|
|
64
|
+
formatted() {
|
|
65
|
+
return String(this.getValue());
|
|
66
|
+
}
|
|
67
|
+
getDescription() {
|
|
68
|
+
return "Chave de API no formato UUID v4 para autenticacao de aplicacoes cliente.";
|
|
69
|
+
}
|
|
70
|
+
getShortDescription() {
|
|
71
|
+
return "API Key (UUID v4)";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.FApiKey = FApiKey;
|
|
75
|
+
//# sourceMappingURL=api-key.format_vo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.format_vo.js","sourceRoot":"","sources":["../../src/type-fields/api-key.format_vo.ts"],"names":[],"mappings":";;;AAAA,0EAAiE;AAEjE,4CAAsE;AACtE,mFAA+E;AAC/E,0DAAsD;AACtD,+BAAuD;AAIvD,MAAa,OAAQ,SAAQ,2BAAkB;IAC3B,aAAa,GAAG,SAAS,CAAC;IAE1B,MAAM,GAA8B;QACpD,cAAc,EAAE,QAAQ;QACxB,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,iBAAiB,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