@mionjs/type-formats 0.8.0-alpha.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/.dist/cjs/BigintFormats.cjs +14 -0
- package/.dist/cjs/BigintFormats.cjs.map +1 -0
- package/.dist/cjs/BigintFormats.d.ts +2 -0
- package/.dist/cjs/NumberFormats.cjs +20 -0
- package/.dist/cjs/NumberFormats.cjs.map +1 -0
- package/.dist/cjs/NumberFormats.d.ts +2 -0
- package/.dist/cjs/StringFormats.cjs +120 -0
- package/.dist/cjs/StringFormats.cjs.map +1 -0
- package/.dist/cjs/StringFormats.d.ts +11 -0
- package/.dist/cjs/constants.d.ts +1 -0
- package/.dist/cjs/package.json +1 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.cjs +152 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.cjs +16 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.cjs.map +1 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.d.ts +29 -0
- package/.dist/cjs/src/constants.cjs +34 -0
- package/.dist/cjs/src/constants.cjs.map +1 -0
- package/.dist/cjs/src/constants.d.ts +15 -0
- package/.dist/cjs/src/constants.mock.cjs +111 -0
- package/.dist/cjs/src/constants.mock.cjs.map +1 -0
- package/.dist/cjs/src/constants.mock.d.ts +335 -0
- package/.dist/cjs/src/number/defaultNumberFormats.cjs +28 -0
- package/.dist/cjs/src/number/defaultNumberFormats.cjs.map +1 -0
- package/.dist/cjs/src/number/defaultNumberFormats.d.ts +63 -0
- package/.dist/cjs/src/number/numberFormat.runtype.cjs +214 -0
- package/.dist/cjs/src/number/numberFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/number/numberFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/date.runtype.cjs +88 -0
- package/.dist/cjs/src/string/date.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/date.runtype.d.ts +19 -0
- package/.dist/cjs/src/string/dateTime.runtype.cjs +83 -0
- package/.dist/cjs/src/string/dateTime.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/dateTime.runtype.d.ts +26 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.cjs +25 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.d.ts +45 -0
- package/.dist/cjs/src/string/domain.runtype.cjs +248 -0
- package/.dist/cjs/src/string/domain.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/domain.runtype.d.ts +72 -0
- package/.dist/cjs/src/string/email.runtype.cjs +159 -0
- package/.dist/cjs/src/string/email.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/email.runtype.d.ts +57 -0
- package/.dist/cjs/src/string/ip.runtype.cjs +72 -0
- package/.dist/cjs/src/string/ip.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/ip.runtype.d.ts +50 -0
- package/.dist/cjs/src/string/stringFormat.runtype.cjs +270 -0
- package/.dist/cjs/src/string/stringFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/stringFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/time.runtype.cjs +100 -0
- package/.dist/cjs/src/string/time.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/time.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/url.runtype.cjs +160 -0
- package/.dist/cjs/src/string/url.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/url.runtype.d.ts +81 -0
- package/.dist/cjs/src/string/uuid.runtype.cjs +44 -0
- package/.dist/cjs/src/string/uuid.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/uuid.runtype.d.ts +22 -0
- package/.dist/cjs/src/type-formats-pure-fns.cjs +390 -0
- package/.dist/cjs/src/type-formats-pure-fns.cjs.map +1 -0
- package/.dist/cjs/src/type-formats-pure-fns.d.ts +27 -0
- package/.dist/cjs/src/utils.cjs +14 -0
- package/.dist/cjs/src/utils.cjs.map +1 -0
- package/.dist/cjs/src/utils.d.ts +3 -0
- package/.dist/cjs/vitest.config.d.ts +2 -0
- package/.dist/esm/BigintFormats.d.ts +2 -0
- package/.dist/esm/BigintFormats.js +14 -0
- package/.dist/esm/BigintFormats.js.map +1 -0
- package/.dist/esm/NumberFormats.d.ts +2 -0
- package/.dist/esm/NumberFormats.js +20 -0
- package/.dist/esm/NumberFormats.js.map +1 -0
- package/.dist/esm/StringFormats.d.ts +11 -0
- package/.dist/esm/StringFormats.js +120 -0
- package/.dist/esm/StringFormats.js.map +1 -0
- package/.dist/esm/constants.d.ts +1 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.js +152 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.js.map +1 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.d.ts +29 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.js +16 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.js.map +1 -0
- package/.dist/esm/src/constants.d.ts +15 -0
- package/.dist/esm/src/constants.js +34 -0
- package/.dist/esm/src/constants.js.map +1 -0
- package/.dist/esm/src/constants.mock.d.ts +335 -0
- package/.dist/esm/src/constants.mock.js +111 -0
- package/.dist/esm/src/constants.mock.js.map +1 -0
- package/.dist/esm/src/number/defaultNumberFormats.d.ts +63 -0
- package/.dist/esm/src/number/defaultNumberFormats.js +28 -0
- package/.dist/esm/src/number/defaultNumberFormats.js.map +1 -0
- package/.dist/esm/src/number/numberFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/number/numberFormat.runtype.js +214 -0
- package/.dist/esm/src/number/numberFormat.runtype.js.map +1 -0
- package/.dist/esm/src/string/date.runtype.d.ts +19 -0
- package/.dist/esm/src/string/date.runtype.js +88 -0
- package/.dist/esm/src/string/date.runtype.js.map +1 -0
- package/.dist/esm/src/string/dateTime.runtype.d.ts +26 -0
- package/.dist/esm/src/string/dateTime.runtype.js +83 -0
- package/.dist/esm/src/string/dateTime.runtype.js.map +1 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.d.ts +45 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.js +25 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.js.map +1 -0
- package/.dist/esm/src/string/domain.runtype.d.ts +72 -0
- package/.dist/esm/src/string/domain.runtype.js +248 -0
- package/.dist/esm/src/string/domain.runtype.js.map +1 -0
- package/.dist/esm/src/string/email.runtype.d.ts +57 -0
- package/.dist/esm/src/string/email.runtype.js +159 -0
- package/.dist/esm/src/string/email.runtype.js.map +1 -0
- package/.dist/esm/src/string/ip.runtype.d.ts +50 -0
- package/.dist/esm/src/string/ip.runtype.js +72 -0
- package/.dist/esm/src/string/ip.runtype.js.map +1 -0
- package/.dist/esm/src/string/stringFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/string/stringFormat.runtype.js +270 -0
- package/.dist/esm/src/string/stringFormat.runtype.js.map +1 -0
- package/.dist/esm/src/string/time.runtype.d.ts +21 -0
- package/.dist/esm/src/string/time.runtype.js +100 -0
- package/.dist/esm/src/string/time.runtype.js.map +1 -0
- package/.dist/esm/src/string/url.runtype.d.ts +81 -0
- package/.dist/esm/src/string/url.runtype.js +160 -0
- package/.dist/esm/src/string/url.runtype.js.map +1 -0
- package/.dist/esm/src/string/uuid.runtype.d.ts +22 -0
- package/.dist/esm/src/string/uuid.runtype.js +44 -0
- package/.dist/esm/src/string/uuid.runtype.js.map +1 -0
- package/.dist/esm/src/type-formats-pure-fns.d.ts +27 -0
- package/.dist/esm/src/type-formats-pure-fns.js +390 -0
- package/.dist/esm/src/type-formats-pure-fns.js.map +1 -0
- package/.dist/esm/src/utils.d.ts +3 -0
- package/.dist/esm/src/utils.js +14 -0
- package/.dist/esm/src/utils.js.map +1 -0
- package/.dist/esm/vitest.config.d.ts +2 -0
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/package.json +80 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { registerFormatter, BaseRunTypeFormat, __ΩTypeFormat as ___TypeFormat } from "@mionjs/run-types";
|
|
2
|
+
import { ReflectionKind } from "@deepkit/type";
|
|
3
|
+
import { DateStringRunTypeFormat, __ΩDEFAULT_DATE_PARAMS as ___DEFAULT_DATE_PARAMS } from "./date.runtype.js";
|
|
4
|
+
import { TimeStringRunTypeFormat, __ΩDEFAULT_TIME_FORMAT_PARAMS as ___DEFAULT_TIME_FORMAT_PARAMS } from "./time.runtype.js";
|
|
5
|
+
import { stringIgnoreProps } from "./stringFormat.runtype.js";
|
|
6
|
+
import { paramVal } from "../utils.js";
|
|
7
|
+
class DateTimeRunTypeFormat extends BaseRunTypeFormat {
|
|
8
|
+
static id = "dateTime";
|
|
9
|
+
kind = ReflectionKind.string;
|
|
10
|
+
name = DateTimeRunTypeFormat.id;
|
|
11
|
+
dateFormatter;
|
|
12
|
+
timeFormatter;
|
|
13
|
+
constructor(parentPath) {
|
|
14
|
+
super(parentPath);
|
|
15
|
+
this.dateFormatter = new DateStringRunTypeFormat(this.getFormatPath("date"));
|
|
16
|
+
this.timeFormatter = new TimeStringRunTypeFormat(this.getFormatPath("time"));
|
|
17
|
+
}
|
|
18
|
+
getIgnoredProps() {
|
|
19
|
+
return stringIgnoreProps;
|
|
20
|
+
}
|
|
21
|
+
emitIsType(comp, rt) {
|
|
22
|
+
const params = this.getParams(rt);
|
|
23
|
+
const fnID = comp.fnID;
|
|
24
|
+
const fmtName = this.getFormatName();
|
|
25
|
+
const vλl = comp.vλl;
|
|
26
|
+
const splitChar = paramVal(params.splitChar);
|
|
27
|
+
const vDatePart = "datePart" + this.getFormatNestLevel();
|
|
28
|
+
const vTimePart = "timePart" + this.getFormatNestLevel();
|
|
29
|
+
const vSplitPos = "splitPos" + this.getFormatNestLevel();
|
|
30
|
+
const dateCode = this.dateFormatter.compileFormat(fnID, comp, rt, params.date, vDatePart, fmtName);
|
|
31
|
+
const timeCode = this.timeFormatter.compileFormat(fnID, comp, rt, params.time, vTimePart, fmtName);
|
|
32
|
+
const returnCode = this.isRootFormat() ? `return true;` : "";
|
|
33
|
+
const code = `
|
|
34
|
+
const ${vSplitPos} = ${vλl}.indexOf('${splitChar}');
|
|
35
|
+
if (${vSplitPos} === -1) return false;
|
|
36
|
+
const ${vDatePart} = ${vλl}.substring(0, ${vSplitPos});
|
|
37
|
+
const ${vTimePart} = ${vλl}.substring(${vSplitPos} + 1);
|
|
38
|
+
if (!(${dateCode.code})) return false;
|
|
39
|
+
if (!(${timeCode.code})) return false;
|
|
40
|
+
${returnCode}
|
|
41
|
+
`;
|
|
42
|
+
return { code, type: "S" };
|
|
43
|
+
}
|
|
44
|
+
emitIsTypeErrors(comp, rt) {
|
|
45
|
+
const params = this.getParams(rt);
|
|
46
|
+
const fnID = comp.fnID;
|
|
47
|
+
const fmtName = this.getFormatName();
|
|
48
|
+
const splitChar = paramVal(params.splitChar);
|
|
49
|
+
const errFn = this.getCallJitFormatErr(comp, rt, this, false);
|
|
50
|
+
const vλl = comp.vλl;
|
|
51
|
+
const vDatePart = "datePart";
|
|
52
|
+
const vTimePart = "timePart";
|
|
53
|
+
const vSplitPos = "splitPos";
|
|
54
|
+
const dateCode = this.dateFormatter.compileFormat(fnID, comp, rt, params.date, vDatePart, fmtName);
|
|
55
|
+
const timeCode = this.timeFormatter.compileFormat(fnID, comp, rt, params.time, vTimePart, fmtName);
|
|
56
|
+
const code = `
|
|
57
|
+
const ${vSplitPos} = ${vλl}.indexOf('${splitChar}');
|
|
58
|
+
if (${vSplitPos} === -1) ${errFn("splitChar", splitChar)};
|
|
59
|
+
const ${vDatePart} = ${vλl}.substring(0, ${vSplitPos});
|
|
60
|
+
const ${vTimePart} = ${vλl}.substring(${vSplitPos} + 1);
|
|
61
|
+
${dateCode.code ? `${dateCode.code};` : ""}
|
|
62
|
+
${timeCode.code ? `${timeCode.code};` : ""}
|
|
63
|
+
`;
|
|
64
|
+
return { code, type: "S" };
|
|
65
|
+
}
|
|
66
|
+
_mock(opts, rt) {
|
|
67
|
+
const params = this.getParams(rt);
|
|
68
|
+
const splitChar = paramVal(params.splitChar);
|
|
69
|
+
const datePart = this.dateFormatter.mock(opts, rt, params.date);
|
|
70
|
+
const timePart = this.timeFormatter.mock(opts, rt, params.time);
|
|
71
|
+
return `${datePart}${splitChar}${timePart}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const DATE_TIME_RUN_TYPE_FORMATTER = registerFormatter(new DateTimeRunTypeFormat());
|
|
75
|
+
const __ΩDEFAULT_DATE_TIME_PARAMS = [() => ___DEFAULT_DATE_PARAMS, "date", () => ___DEFAULT_TIME_FORMAT_PARAMS, "time", "T", "splitChar", "DEFAULT_DATE_TIME_PARAMS", `Pn!4"n#4$.%4&Mw'y`];
|
|
76
|
+
const __ΩFormatStringDateTime = ["P", () => ___TypeFormat, () => DateTimeRunTypeFormat.id, () => __ΩDEFAULT_DATE_TIME_PARAMS, "dateTime", "FormatStringDateTime", 'PMc!&i#Pn$e"!K.%o"%w&y'];
|
|
77
|
+
export {
|
|
78
|
+
DATE_TIME_RUN_TYPE_FORMATTER,
|
|
79
|
+
DateTimeRunTypeFormat,
|
|
80
|
+
__ΩDEFAULT_DATE_TIME_PARAMS,
|
|
81
|
+
__ΩFormatStringDateTime
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=dateTime.runtype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateTime.runtype.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FormatString } from './stringFormat.runtype.ts';
|
|
2
|
+
import { StringParams } from '@mionjs/core';
|
|
3
|
+
export declare const ALPHANUMERIC_REGEX: RegExp;
|
|
4
|
+
export declare const ALPHA_REGEX: RegExp;
|
|
5
|
+
export declare const NUMERIC_REGEX: RegExp;
|
|
6
|
+
type DEFAULT_ALPHA_NUM_PARAMS = {
|
|
7
|
+
pattern: {
|
|
8
|
+
val: typeof ALPHANUMERIC_REGEX;
|
|
9
|
+
mockSamples: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
10
|
+
errorMessage: 'only alphanumeric values are allowed';
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type DEFAULT_ALPHA_PARAMS = {
|
|
14
|
+
pattern: {
|
|
15
|
+
val: typeof ALPHA_REGEX;
|
|
16
|
+
mockSamples: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
17
|
+
errorMessage: 'only alphabetic values are allowed';
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type DEFAULT_NUMERIC_PARAMS = {
|
|
21
|
+
pattern: {
|
|
22
|
+
val: typeof NUMERIC_REGEX;
|
|
23
|
+
mockSamples: '0123456789';
|
|
24
|
+
errorMessage: 'only numeric values are allowed';
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type FormatAlphaNumeric<P extends StringParams = {}> = FormatString<P & DEFAULT_ALPHA_NUM_PARAMS>;
|
|
28
|
+
export type FormatAlpha<P extends StringParams = {}> = FormatString<P & DEFAULT_ALPHA_PARAMS>;
|
|
29
|
+
export type FormatNumeric<P extends StringParams = {}> = FormatString<P & DEFAULT_NUMERIC_PARAMS>;
|
|
30
|
+
export type FormatLowercase<P extends StringParams = {}> = FormatString<P & {
|
|
31
|
+
lowercase: true;
|
|
32
|
+
}>;
|
|
33
|
+
export type FormatUppercase<P extends StringParams = {}> = FormatString<P & {
|
|
34
|
+
uppercase: true;
|
|
35
|
+
}>;
|
|
36
|
+
export type FormatCapitalize<P extends StringParams = {}> = FormatString<P & {
|
|
37
|
+
capitalize: true;
|
|
38
|
+
}>;
|
|
39
|
+
export {};
|
|
40
|
+
export declare type __ΩFormatAlphaNumeric = any[];
|
|
41
|
+
export declare type __ΩFormatAlpha = any[];
|
|
42
|
+
export declare type __ΩFormatNumeric = any[];
|
|
43
|
+
export declare type __ΩFormatLowercase = any[];
|
|
44
|
+
export declare type __ΩFormatUppercase = any[];
|
|
45
|
+
export declare type __ΩFormatCapitalize = any[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __ΩFormatString as ___FormatString } from "./stringFormat.runtype.js";
|
|
2
|
+
const ALPHANUMERIC_REGEX = /^[\p{L}\p{N}]+$/u;
|
|
3
|
+
const ALPHA_REGEX = /^[\p{L}]+$/u;
|
|
4
|
+
const NUMERIC_REGEX = /^[\p{N}]+$/u;
|
|
5
|
+
const __ΩDEFAULT_ALPHA_NUM_PARAMS = [() => ALPHANUMERIC_REGEX, "val", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "mockSamples", "only alphanumeric values are allowed", "errorMessage", "pattern", "DEFAULT_ALPHA_NUM_PARAMS", `PPi!4".#4$.%4&M4'Mw(y`];
|
|
6
|
+
const __ΩDEFAULT_ALPHA_PARAMS = [() => ALPHA_REGEX, "val", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "mockSamples", "only alphabetic values are allowed", "errorMessage", "pattern", "DEFAULT_ALPHA_PARAMS", `PPi!4".#4$.%4&M4'Mw(y`];
|
|
7
|
+
const __ΩDEFAULT_NUMERIC_PARAMS = [() => NUMERIC_REGEX, "val", "0123456789", "mockSamples", "only numeric values are allowed", "errorMessage", "pattern", "DEFAULT_NUMERIC_PARAMS", `PPi!4".#4$.%4&M4'Mw(y`];
|
|
8
|
+
const __ΩFormatAlphaNumeric = ["P", () => ___FormatString, () => __ΩDEFAULT_ALPHA_NUM_PARAMS, "FormatAlphaNumeric", 'PMc!Pe"!n#Ko""w$y'];
|
|
9
|
+
const __ΩFormatAlpha = ["P", () => ___FormatString, () => __ΩDEFAULT_ALPHA_PARAMS, "FormatAlpha", 'PMc!Pe"!n#Ko""w$y'];
|
|
10
|
+
const __ΩFormatNumeric = ["P", () => ___FormatString, () => __ΩDEFAULT_NUMERIC_PARAMS, "FormatNumeric", 'PMc!Pe"!n#Ko""w$y'];
|
|
11
|
+
const __ΩFormatLowercase = ["P", () => ___FormatString, true, "lowercase", "FormatLowercase", 'PMc!Pe"!P.#4$MKo""w%y'];
|
|
12
|
+
const __ΩFormatUppercase = ["P", () => ___FormatString, true, "uppercase", "FormatUppercase", 'PMc!Pe"!P.#4$MKo""w%y'];
|
|
13
|
+
const __ΩFormatCapitalize = ["P", () => ___FormatString, true, "capitalize", "FormatCapitalize", 'PMc!Pe"!P.#4$MKo""w%y'];
|
|
14
|
+
export {
|
|
15
|
+
ALPHANUMERIC_REGEX,
|
|
16
|
+
ALPHA_REGEX,
|
|
17
|
+
NUMERIC_REGEX,
|
|
18
|
+
__ΩFormatAlpha,
|
|
19
|
+
__ΩFormatAlphaNumeric,
|
|
20
|
+
__ΩFormatCapitalize,
|
|
21
|
+
__ΩFormatLowercase,
|
|
22
|
+
__ΩFormatNumeric,
|
|
23
|
+
__ΩFormatUppercase
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=defaultStringFormats.runtype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultStringFormats.runtype.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode, JitFnID, StrNumber, BaseRunTypeFormat, RunTypeOptions, TypeFormat } from '@mionjs/run-types';
|
|
2
|
+
import { ReflectionKind } from '@deepkit/type';
|
|
3
|
+
import { FormatParams_Domain, Samples } from '@mionjs/core';
|
|
4
|
+
export declare const DOMAIN_PATTERN: RegExp;
|
|
5
|
+
export declare const DOMAIN_PATTERN_UNICODE: RegExp;
|
|
6
|
+
export declare const DOMAIN_PATTERN_PUNYCODE: RegExp;
|
|
7
|
+
export declare const DOMAIN_ALLOWED_CHARS_PATTERN: RegExp;
|
|
8
|
+
export declare const TLD_ALLOWED_CHARS_PATTERN: RegExp;
|
|
9
|
+
export declare class DomainRunTypeFormat extends BaseRunTypeFormat<FormatParams_Domain> {
|
|
10
|
+
static id: "domain";
|
|
11
|
+
kind: ReflectionKind;
|
|
12
|
+
name: "domain";
|
|
13
|
+
private rootFormatter;
|
|
14
|
+
private nameFormatter;
|
|
15
|
+
private tldFormatter;
|
|
16
|
+
constructor(parentPath?: StrNumber[]);
|
|
17
|
+
canEmbedFormatterCode(fnID: JitFnID, rt: BaseRunType, p?: FormatParams_Domain): boolean;
|
|
18
|
+
getIgnoredProps(): string[] | undefined;
|
|
19
|
+
emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode;
|
|
20
|
+
emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode;
|
|
21
|
+
_mock(opts: RunTypeOptions, rt: BaseRunType): string;
|
|
22
|
+
private hasNoConstrains;
|
|
23
|
+
private mockName;
|
|
24
|
+
private mockTld;
|
|
25
|
+
emitFormat(comp: JitFnCompiler): JitCode;
|
|
26
|
+
_formatMockedValue(opts: RunTypeOptions, _rt: BaseRunType, val: any): string;
|
|
27
|
+
validateParams(rt: BaseRunType, params: FormatParams_Domain): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const DOMAIN_RUN_TYPE_FORMATTER: DomainRunTypeFormat;
|
|
30
|
+
export type DEFAULT_DOMAIN_PARAMS<P extends RegExp = typeof DOMAIN_PATTERN, S extends Samples = ['ggle.com', 'mion.io', 'mionkit.io', 'yahuu.net', 'fbook.com', 'wiki.org', 'ms.net']> = {
|
|
31
|
+
maxLength: 253;
|
|
32
|
+
minLength: 5;
|
|
33
|
+
pattern: {
|
|
34
|
+
val: P;
|
|
35
|
+
mockSamples: S;
|
|
36
|
+
errorMessage: 'invalid domain';
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type DEFAULT_DMM_TLD_PARAMS<P extends RegExp = typeof TLD_ALLOWED_CHARS_PATTERN, S extends Samples = ['com', 'org', 'net', 'io', 'app', 'co', 'dev', 'tech', 'ai', 'mion', 'co.uk', 'com.au', 'com.br']> = {
|
|
40
|
+
maxLength: 12;
|
|
41
|
+
minLength: 2;
|
|
42
|
+
pattern: {
|
|
43
|
+
val: P;
|
|
44
|
+
mockSamples: S;
|
|
45
|
+
errorMessage: 'top level domain can only contain letters and dots';
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type DEFAULT_DOM_NAME_PARAMS<P extends RegExp = typeof DOMAIN_ALLOWED_CHARS_PATTERN, S extends Samples = ['domain', 'ggle', 'fbook', 'mion', 'prot', 'yahuu', 'hello', 'world', 'example', 'wiki', 'mionkit']> = {
|
|
49
|
+
maxLength: 63;
|
|
50
|
+
minLength: 2;
|
|
51
|
+
pattern: {
|
|
52
|
+
val: P;
|
|
53
|
+
mockSamples: S;
|
|
54
|
+
errorMessage: 'domain names can only contain letters, numbers and hyphens';
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type DEFAULT_STRICT_DOMAIN_PARAMS = {
|
|
58
|
+
maxParts: 6;
|
|
59
|
+
minParts: 2;
|
|
60
|
+
names: DEFAULT_DOM_NAME_PARAMS;
|
|
61
|
+
tld: DEFAULT_DMM_TLD_PARAMS;
|
|
62
|
+
maxLength: 253;
|
|
63
|
+
minLength: 5;
|
|
64
|
+
};
|
|
65
|
+
export type FormatDomain<DP extends FormatParams_Domain = DEFAULT_DOMAIN_PARAMS> = TypeFormat<string, 'domain', DP, 'domain'>;
|
|
66
|
+
export type FormatDomainStrict<D extends Partial<FormatParams_Domain> = {}> = FormatDomain<DEFAULT_STRICT_DOMAIN_PARAMS & D>;
|
|
67
|
+
export declare type __ΩDEFAULT_DOMAIN_PARAMS = any[];
|
|
68
|
+
export declare type __ΩDEFAULT_DMM_TLD_PARAMS = any[];
|
|
69
|
+
export declare type __ΩDEFAULT_DOM_NAME_PARAMS = any[];
|
|
70
|
+
export declare type __ΩDEFAULT_STRICT_DOMAIN_PARAMS = any[];
|
|
71
|
+
export declare type __ΩFormatDomain = any[];
|
|
72
|
+
export declare type __ΩFormatDomainStrict = any[];
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { registerFormatter, BaseRunTypeFormat, JitFunctions, random, randomItem, __ΩTypeFormat as ___TypeFormat } from "@mionjs/run-types";
|
|
2
|
+
import { ReflectionKind } from "@deepkit/type";
|
|
3
|
+
import { StringRunTypeFormat, stringIgnoreProps } from "./stringFormat.runtype.js";
|
|
4
|
+
import { NAME_SAMPLES, NAME_CHARS, TLD_SAMPLES, TLD_CHARS } from "../constants.mock.js";
|
|
5
|
+
import { paramVal } from "../utils.js";
|
|
6
|
+
const DOMAIN_PATTERN = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
|
|
7
|
+
const DOMAIN_PATTERN_UNICODE = /^(?:[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?\.)+[a-zA-Z]{2,63}$/u;
|
|
8
|
+
const DOMAIN_PATTERN_PUNYCODE = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9-]{2,63}$/;
|
|
9
|
+
const DOMAIN_ALLOWED_CHARS_PATTERN = /^[a-zA-Z0-9-]+$/;
|
|
10
|
+
const TLD_ALLOWED_CHARS_PATTERN = /^[a-zA-Z]+(\.[a-zA-Z]+)?$/;
|
|
11
|
+
const tldAllowedChars = {
|
|
12
|
+
val: TLD_CHARS,
|
|
13
|
+
errorMessage: "only alphabetical characters allowed"
|
|
14
|
+
};
|
|
15
|
+
const namesAllowedChars = {
|
|
16
|
+
val: NAME_CHARS,
|
|
17
|
+
errorMessage: "only alphabetical characters and hyphens allowed"
|
|
18
|
+
};
|
|
19
|
+
class DomainRunTypeFormat extends BaseRunTypeFormat {
|
|
20
|
+
static id = "domain";
|
|
21
|
+
kind = ReflectionKind.string;
|
|
22
|
+
name = DomainRunTypeFormat.id;
|
|
23
|
+
// Formatter instances as class variables
|
|
24
|
+
rootFormatter;
|
|
25
|
+
nameFormatter;
|
|
26
|
+
tldFormatter;
|
|
27
|
+
constructor(parentPath) {
|
|
28
|
+
super(parentPath);
|
|
29
|
+
const domainPath = this.getFormatPath();
|
|
30
|
+
const namePath = this.getFormatPath("names");
|
|
31
|
+
const tldPath = this.getFormatPath("tld");
|
|
32
|
+
this.rootFormatter = new StringRunTypeFormat(domainPath);
|
|
33
|
+
this.nameFormatter = new StringRunTypeFormat(namePath);
|
|
34
|
+
this.tldFormatter = new StringRunTypeFormat(tldPath);
|
|
35
|
+
}
|
|
36
|
+
canEmbedFormatterCode(fnID, rt, p) {
|
|
37
|
+
const params = p || this.getParams(rt);
|
|
38
|
+
if (fnID === JitFunctions.isType.id || fnID === JitFunctions.typeErrors.id)
|
|
39
|
+
return super.canEmbedFormatterCode(fnID, rt) && !!params.pattern;
|
|
40
|
+
return super.canEmbedFormatterCode(fnID, rt);
|
|
41
|
+
}
|
|
42
|
+
getIgnoredProps() {
|
|
43
|
+
return stringIgnoreProps;
|
|
44
|
+
}
|
|
45
|
+
emitIsType(comp, rt) {
|
|
46
|
+
const params = this.getParams(rt);
|
|
47
|
+
const fnID = comp.fnID;
|
|
48
|
+
const fmtName = this.getFormatName();
|
|
49
|
+
if (params.pattern)
|
|
50
|
+
return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);
|
|
51
|
+
const vλl = comp.vλl;
|
|
52
|
+
const vName = "name" + this.getFormatNestLevel();
|
|
53
|
+
const vTld = "tld" + this.getFormatNestLevel();
|
|
54
|
+
const vCount = "count" + this.getFormatNestLevel();
|
|
55
|
+
const vStart = "start" + this.getFormatNestLevel();
|
|
56
|
+
const vPos = "pos" + this.getFormatNestLevel();
|
|
57
|
+
const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);
|
|
58
|
+
const nameCode = this.nameFormatter.compileFormat(fnID, comp, rt, params.names, vName, fmtName);
|
|
59
|
+
const tldCode = this.tldFormatter.compileFormat(fnID, comp, rt, params.tld, vTld, fmtName);
|
|
60
|
+
const maxPartsCode = params.maxParts ? `if (${vCount} > ${params.maxParts}) return false;` : "";
|
|
61
|
+
const minPartsCode = params.minParts ? `if (${vCount} < ${params.minParts}) return false;` : "";
|
|
62
|
+
const rootSafeCode = rootCode.code ? `if (!(${rootCode.code})) return false;` : "";
|
|
63
|
+
const tldSafeCode = tldCode.code ? `const ${vTld} = ${vλl}.substring(${vStart}); if (!(${tldCode.code})) return false;` : "";
|
|
64
|
+
const returnCode = this.isRootFormat() ? `return true;` : "";
|
|
65
|
+
const skipCount = !maxPartsCode && !minPartsCode && !tldCode.code;
|
|
66
|
+
const code = `
|
|
67
|
+
${rootSafeCode}
|
|
68
|
+
let ${vCount} = 1; let ${vStart} = 0; let ${vPos}; let ${vName};
|
|
69
|
+
while ((${vPos} = ${vλl}.indexOf('.', ${vStart})) !== -1) {
|
|
70
|
+
${vName} = ${vλl}.substring(${vStart}, ${vPos});
|
|
71
|
+
${!params.names?.allowedValues ? `if (${vName}.startsWith('-') || ${vName}.endsWith('-')) return false;` : ""}
|
|
72
|
+
if (!(${nameCode.code})) return false;
|
|
73
|
+
${vStart} = ${vPos} + 1;
|
|
74
|
+
${!skipCount ? `${vCount}++;` : ""}
|
|
75
|
+
}
|
|
76
|
+
${maxPartsCode}
|
|
77
|
+
${minPartsCode}
|
|
78
|
+
${tldSafeCode}
|
|
79
|
+
${returnCode}
|
|
80
|
+
`;
|
|
81
|
+
return { code, type: "S" };
|
|
82
|
+
}
|
|
83
|
+
emitIsTypeErrors(comp, rt) {
|
|
84
|
+
const params = this.getParams(rt);
|
|
85
|
+
const fnID = comp.fnID;
|
|
86
|
+
const fmtName = this.getFormatName();
|
|
87
|
+
if (params.pattern)
|
|
88
|
+
return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);
|
|
89
|
+
const errFn = this.getCallJitFormatErr(comp, rt, this, false);
|
|
90
|
+
const vλl = comp.vλl;
|
|
91
|
+
const vName = "name" + this.getFormatNestLevel();
|
|
92
|
+
const vTld = "tld" + this.getFormatNestLevel();
|
|
93
|
+
const vCount = "count" + this.getFormatNestLevel();
|
|
94
|
+
const vStart = "start" + this.getFormatNestLevel();
|
|
95
|
+
const vPos = "pos" + this.getFormatNestLevel();
|
|
96
|
+
const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);
|
|
97
|
+
const nameCode = this.nameFormatter.compileFormat(fnID, comp, rt, params.names, vName, fmtName, vCount);
|
|
98
|
+
const tldCode = this.tldFormatter.compileFormat(fnID, comp, rt, params.tld, vTld, fmtName);
|
|
99
|
+
const maxPartsCode = params.maxParts ? `if (${vCount} > ${params.maxParts}) ${errFn("maxParts", paramVal(params.maxParts))};` : "";
|
|
100
|
+
const minPartsCode = params.minParts ? `if (${vCount} < ${params.minParts}) ${errFn("minParts", paramVal(params.minParts))};` : "";
|
|
101
|
+
const tldSafeCode = tldCode.code ? `const ${vTld} = ${vλl}.substring(${vStart}); ${tldCode.code};` : "";
|
|
102
|
+
const skipCount = !maxPartsCode && !minPartsCode && !tldCode.code;
|
|
103
|
+
const code = `
|
|
104
|
+
${rootCode.code};
|
|
105
|
+
let ${vCount} = 0; let ${vStart} = 0; let ${vPos}; let ${vName};
|
|
106
|
+
while ((${vPos} = ${vλl}.indexOf('.', ${vStart})) !== -1) {
|
|
107
|
+
${vName} = ${vλl}.substring(${vStart}, ${vPos});
|
|
108
|
+
${!params.names?.allowedValues ? `if (${vName}.startsWith('-') || ${vName}.endsWith('-')) ${errFn("hyphen", "name")};` : ""}
|
|
109
|
+
${nameCode.code};
|
|
110
|
+
${vStart} = ${vPos} + 1;
|
|
111
|
+
${!skipCount ? `${vCount}++;` : ""}
|
|
112
|
+
}
|
|
113
|
+
${!skipCount ? `${vCount}++;` : ""}
|
|
114
|
+
${maxPartsCode}
|
|
115
|
+
${minPartsCode}
|
|
116
|
+
${tldSafeCode};
|
|
117
|
+
`;
|
|
118
|
+
return { code, type: "S" };
|
|
119
|
+
}
|
|
120
|
+
_mock(opts, rt) {
|
|
121
|
+
const params = this.getParams(rt);
|
|
122
|
+
if (params.pattern)
|
|
123
|
+
return this.rootFormatter.mock(opts, rt, params);
|
|
124
|
+
const maxParts = paramVal(params.maxParts || 6);
|
|
125
|
+
const minParts = paramVal(params.minParts || 2);
|
|
126
|
+
const maxLength = paramVal(params.maxLength || 253);
|
|
127
|
+
const minLength = paramVal(params.minLength || 3);
|
|
128
|
+
let tld = this.mockTld(opts, rt, params.tld);
|
|
129
|
+
const tldParts = tld.split(".");
|
|
130
|
+
while (tldParts.length > 1 && tldParts.length >= maxParts)
|
|
131
|
+
tldParts.shift();
|
|
132
|
+
tld = tldParts.join(".");
|
|
133
|
+
const singleNameMax = tldParts.length + 1;
|
|
134
|
+
const noNormalMax = Math.random() < 0.2 ? maxParts : singleNameMax;
|
|
135
|
+
const maxRandom = noNormalMax - tldParts.length;
|
|
136
|
+
const minRandom = minParts - paramVal(tldParts.length);
|
|
137
|
+
const maxRandomParts = random(minRandom, maxRandom);
|
|
138
|
+
const parts = [];
|
|
139
|
+
parts.push(this.mockName(opts, rt, params.names));
|
|
140
|
+
let name = parts[0];
|
|
141
|
+
let domain = `${name}.${tld}`;
|
|
142
|
+
while (domain.length < maxLength && parts.length < maxRandomParts || domain.length < minLength) {
|
|
143
|
+
parts.push(this.mockName(opts, rt, params.names));
|
|
144
|
+
name = parts.join(".");
|
|
145
|
+
domain = `${name}.${tld}`;
|
|
146
|
+
}
|
|
147
|
+
return domain;
|
|
148
|
+
}
|
|
149
|
+
hasNoConstrains(params) {
|
|
150
|
+
return !params.allowedChars && !params.disallowedChars && !params.pattern && !params.allowedValues;
|
|
151
|
+
}
|
|
152
|
+
mockName(opts, rt, params) {
|
|
153
|
+
const hasParams = !!Object.keys(params).length;
|
|
154
|
+
if (!hasParams)
|
|
155
|
+
return randomItem(NAME_SAMPLES);
|
|
156
|
+
const defaultParams = {
|
|
157
|
+
...params,
|
|
158
|
+
maxLength: params.maxLength ?? 63,
|
|
159
|
+
minLength: params.minLength ?? 2,
|
|
160
|
+
pattern: params.pattern,
|
|
161
|
+
allowedValues: params.allowedValues,
|
|
162
|
+
disallowedValues: params.disallowedValues,
|
|
163
|
+
allowedChars: this.hasNoConstrains(params) ? namesAllowedChars : void 0
|
|
164
|
+
};
|
|
165
|
+
return this.nameFormatter.mock(opts, rt, defaultParams);
|
|
166
|
+
}
|
|
167
|
+
mockTld(opts, rt, params) {
|
|
168
|
+
const hasParams = !!Object.keys(params).length;
|
|
169
|
+
if (!hasParams)
|
|
170
|
+
return randomItem(TLD_SAMPLES);
|
|
171
|
+
const defaultParams = {
|
|
172
|
+
...params,
|
|
173
|
+
maxLength: params.maxLength ?? 12,
|
|
174
|
+
minLength: params.minLength ?? 2,
|
|
175
|
+
pattern: params.pattern,
|
|
176
|
+
allowedValues: params.allowedValues,
|
|
177
|
+
disallowedValues: params.disallowedValues,
|
|
178
|
+
allowedChars: this.hasNoConstrains(params) ? tldAllowedChars : void 0
|
|
179
|
+
};
|
|
180
|
+
return this.tldFormatter.mock(opts, rt, defaultParams);
|
|
181
|
+
}
|
|
182
|
+
emitFormat(comp) {
|
|
183
|
+
return { code: `${comp.vλl}.toLowerCase()`, type: "E" };
|
|
184
|
+
}
|
|
185
|
+
_formatMockedValue(opts, _rt, val) {
|
|
186
|
+
return val.toLowerCase();
|
|
187
|
+
}
|
|
188
|
+
validateParams(rt, params) {
|
|
189
|
+
const onlyOne = [params.names, params.pattern].filter(Boolean);
|
|
190
|
+
if (onlyOne.length > 1)
|
|
191
|
+
throw new Error(`Domain can only have one of (names & tld), pattern or allowedValues in type ${this.printPath(rt)}`);
|
|
192
|
+
if (params.maxLength && paramVal(params.maxLength) > 253)
|
|
193
|
+
throw new Error(`Domain maxLength cannot be greater than 253 in type ${this.printPath(rt, "maxLength")}`);
|
|
194
|
+
if (params.minLength && paramVal(params.minLength) < 3)
|
|
195
|
+
throw new Error(`Domain minLength cannot be less than 3 in type ${this.printPath(rt, "minLength")}`);
|
|
196
|
+
if (params.minParts && paramVal(params.minParts) < 2)
|
|
197
|
+
throw new Error(`Domain minParts cannot be less than 2 in type ${this.printPath(rt, "minParts")}`);
|
|
198
|
+
if (params.maxParts && paramVal(params.maxParts) < 2)
|
|
199
|
+
throw new Error(`Domain maxParts cannot be less than 2 in type ${this.printPath(rt, "maxParts")}`);
|
|
200
|
+
if (params.names && !params.tld || !params.names && params.tld)
|
|
201
|
+
throw new Error(`Domain names and tld must be used together in type ${this.printPath(rt, "maxParts")}`);
|
|
202
|
+
if (params.tld && params.tld.minLength && paramVal(params.tld.minLength) < 2)
|
|
203
|
+
throw new Error(`Domain tld.minLength cannot be less than 2 in type ${this.printPath(rt, "tld.minLength")}`);
|
|
204
|
+
if (params.tld && params.tld.maxLength && paramVal(params.tld.maxLength) > 63)
|
|
205
|
+
throw new Error(`Domain tld.maxLength cannot be greater than 63 in type ${this.printPath(rt, "tld.maxLength")}`);
|
|
206
|
+
if (params.names && params.names.maxLength && paramVal(params.names.maxLength) > 63)
|
|
207
|
+
throw new Error(`Domain names.maxLength cannot be greater than 63 in type ${this.printPath(rt, "names.maxLength")}`);
|
|
208
|
+
this.rootFormatter.validateParams(rt, params);
|
|
209
|
+
if (params.names?.allowedValues)
|
|
210
|
+
params.names?.allowedValues.val.forEach((val) => {
|
|
211
|
+
if (val.startsWith("-") || val.endsWith("-"))
|
|
212
|
+
throw new Error(`allowedValues[${val}] can not start or end with a hyphen in type ${this.printPath(rt, "names.allowedValues")}`);
|
|
213
|
+
});
|
|
214
|
+
if (params.names) {
|
|
215
|
+
if (Object.values(params.names).length === 0)
|
|
216
|
+
throw new Error(`Domain names must have at least one validator in type ${this.printPath(rt, "names")}`);
|
|
217
|
+
this.nameFormatter.validateParams(rt, params.names);
|
|
218
|
+
}
|
|
219
|
+
if (params.tld) {
|
|
220
|
+
if (Object.values(params.tld).length === 0)
|
|
221
|
+
throw new Error(`Domain tld must have at least one validator in type ${this.printPath(rt, "tld")}`);
|
|
222
|
+
this.tldFormatter.validateParams(rt, params.tld);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const DOMAIN_RUN_TYPE_FORMATTER = registerFormatter(new DomainRunTypeFormat());
|
|
227
|
+
const __ΩDEFAULT_DOMAIN_PARAMS = [() => DOMAIN_PATTERN, "P", "ggle.com", "mion.io", "mionkit.io", "yahuu.net", "fbook.com", "wiki.org", "ms.net", "S", 253, "maxLength", 5, "minLength", "val", "mockSamples", "invalid domain", "errorMessage", "pattern", "DEFAULT_DOMAIN_PARAMS", `i!c"P.#.$.%.&.'.(.)Gc*P.+4,.-4.Pe#!4/e#"40.142M43Mw4y`];
|
|
228
|
+
const __ΩDEFAULT_DMM_TLD_PARAMS = [() => TLD_ALLOWED_CHARS_PATTERN, "P", "com", "org", "net", "io", "app", "co", "dev", "tech", "ai", "mion", "co.uk", "com.au", "com.br", "S", 12, "maxLength", 2, "minLength", "val", "mockSamples", "top level domain can only contain letters and dots", "errorMessage", "pattern", "DEFAULT_DMM_TLD_PARAMS", `i!c"P.#.$.%.&.'.(.).*.+.,.-.../Gc0P.142.344Pe#!45e#"46.748M49Mw:y`];
|
|
229
|
+
const __ΩDEFAULT_DOM_NAME_PARAMS = [() => DOMAIN_ALLOWED_CHARS_PATTERN, "P", "domain", "ggle", "fbook", "mion", "prot", "yahuu", "hello", "world", "example", "wiki", "mionkit", "S", 63, "maxLength", 2, "minLength", "val", "mockSamples", "domain names can only contain letters, numbers and hyphens", "errorMessage", "pattern", "DEFAULT_DOM_NAME_PARAMS", `i!c"P.#.$.%.&.'.(.).*.+.,.-Gc.P./40.142Pe#!43e#"44.546M47Mw8y`];
|
|
230
|
+
const __ΩDEFAULT_STRICT_DOMAIN_PARAMS = [6, "maxParts", 2, "minParts", () => __ΩDEFAULT_DOM_NAME_PARAMS, "names", () => __ΩDEFAULT_DMM_TLD_PARAMS, "tld", 253, "maxLength", 5, "minLength", "DEFAULT_STRICT_DOMAIN_PARAMS", `P.!4".#4$n%4&n'4(.)4*.+4,Mw-y`];
|
|
231
|
+
const __ΩFormatDomain = [() => __ΩDEFAULT_DOMAIN_PARAMS, "DP", () => ___TypeFormat, "domain", "domain", "FormatDomain", 'n!c"&.$e!!.%o#%w&y'];
|
|
232
|
+
const __ΩFormatDomainStrict = ["D", () => __ΩFormatDomain, () => __ΩDEFAULT_STRICT_DOMAIN_PARAMS, "FormatDomainStrict", 'PMc!Pn#e"!Ko""w$y'];
|
|
233
|
+
export {
|
|
234
|
+
DOMAIN_ALLOWED_CHARS_PATTERN,
|
|
235
|
+
DOMAIN_PATTERN,
|
|
236
|
+
DOMAIN_PATTERN_PUNYCODE,
|
|
237
|
+
DOMAIN_PATTERN_UNICODE,
|
|
238
|
+
DOMAIN_RUN_TYPE_FORMATTER,
|
|
239
|
+
DomainRunTypeFormat,
|
|
240
|
+
TLD_ALLOWED_CHARS_PATTERN,
|
|
241
|
+
__ΩDEFAULT_DMM_TLD_PARAMS,
|
|
242
|
+
__ΩDEFAULT_DOMAIN_PARAMS,
|
|
243
|
+
__ΩDEFAULT_DOM_NAME_PARAMS,
|
|
244
|
+
__ΩDEFAULT_STRICT_DOMAIN_PARAMS,
|
|
245
|
+
__ΩFormatDomain,
|
|
246
|
+
__ΩFormatDomainStrict
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=domain.runtype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.runtype.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseRunType, JitFnCompiler, JitErrorsFnCompiler, StrNumber, JitFnID, JitCode, BaseRunTypeFormat, TypeFormat, RunTypeOptions } from '@mionjs/run-types';
|
|
2
|
+
import { ReflectionKind } from '@deepkit/type';
|
|
3
|
+
import { DEFAULT_STRICT_DOMAIN_PARAMS } from './domain.runtype.ts';
|
|
4
|
+
import { FormatParams_Email, Samples } from '@mionjs/core';
|
|
5
|
+
import { EMAIL_NAME_SAMPLES, EMAIL_SAMPLES, EMAIL_SAMPLES_PUNYCODE } from '../constants.mock.ts';
|
|
6
|
+
export declare const EMAIL_PATTERN: RegExp;
|
|
7
|
+
export declare const EMAIL_PATTERN_PUNYCODE: RegExp;
|
|
8
|
+
export declare class EmailRunTypeFormat extends BaseRunTypeFormat<FormatParams_Email> {
|
|
9
|
+
static id: string;
|
|
10
|
+
kind: ReflectionKind;
|
|
11
|
+
name: string;
|
|
12
|
+
private rootFormatter;
|
|
13
|
+
private domainFormatter;
|
|
14
|
+
private localPartFormatter;
|
|
15
|
+
constructor(parentPath?: StrNumber[]);
|
|
16
|
+
getIgnoredProps(): string[] | undefined;
|
|
17
|
+
canEmbedFormatterCode(fnID: JitFnID, rt: BaseRunType, p?: FormatParams_Email): boolean;
|
|
18
|
+
emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode;
|
|
19
|
+
emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode;
|
|
20
|
+
_mock(opts: RunTypeOptions, rt: BaseRunType): string;
|
|
21
|
+
private mockLocalPart;
|
|
22
|
+
emitFormat(comp: JitFnCompiler): JitCode;
|
|
23
|
+
validateParams(rt: BaseRunType, params: FormatParams_Email): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const EMAIL_RUN_TYPE_FORMATTER: EmailRunTypeFormat;
|
|
26
|
+
export type DEFAULT_STRICT_EMAIL_PARAMS = {
|
|
27
|
+
maxLength: 254;
|
|
28
|
+
localPart: {
|
|
29
|
+
maxLength: 64;
|
|
30
|
+
minLength: 1;
|
|
31
|
+
disallowedChars: {
|
|
32
|
+
val: ` ()<>[]:;\\,{}|+@`;
|
|
33
|
+
errorMessage: 'Invalid characters in email local part';
|
|
34
|
+
mockSamples: EMAIL_NAME_SAMPLES;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
domain: DEFAULT_STRICT_DOMAIN_PARAMS;
|
|
38
|
+
};
|
|
39
|
+
export type DEFAULT_EMAIL_PARAMS<EmailPattern extends RegExp = typeof EMAIL_PATTERN, MockSamples extends Samples = EMAIL_SAMPLES> = {
|
|
40
|
+
maxLength: 254;
|
|
41
|
+
minLength: 7;
|
|
42
|
+
pattern: {
|
|
43
|
+
val: EmailPattern;
|
|
44
|
+
mockSamples: MockSamples;
|
|
45
|
+
errorMessage: 'Invalid email format';
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type FormatEmail<EP extends FormatParams_Email = DEFAULT_EMAIL_PARAMS> = TypeFormat<string, 'email', EP, 'email'>;
|
|
49
|
+
export type FormatEmailStrict<E extends Partial<FormatParams_Email> = {}> = FormatEmail<DEFAULT_STRICT_EMAIL_PARAMS & E>;
|
|
50
|
+
export type FormatEmailPattern<EmailPattern extends RegExp, MockSamples extends Samples> = FormatEmail<DEFAULT_EMAIL_PARAMS<EmailPattern, MockSamples>>;
|
|
51
|
+
export type FormatEmailPunycode = FormatEmailPattern<typeof EMAIL_PATTERN_PUNYCODE, EMAIL_SAMPLES_PUNYCODE>;
|
|
52
|
+
export declare type __ΩDEFAULT_STRICT_EMAIL_PARAMS = any[];
|
|
53
|
+
export declare type __ΩDEFAULT_EMAIL_PARAMS = any[];
|
|
54
|
+
export declare type __ΩFormatEmail = any[];
|
|
55
|
+
export declare type __ΩFormatEmailStrict = any[];
|
|
56
|
+
export declare type __ΩFormatEmailPattern = any[];
|
|
57
|
+
export declare type __ΩFormatEmailPunycode = any[];
|