inferred-types 0.51.3 → 0.51.5
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/index.cjs +76 -2
- package/dist/index.js +68 -2
- package/dist/inferred-types/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/errors/KindError.d.ts.map +1 -1
- package/dist/runtime/errors/KindError.js +2 -2
- package/dist/runtime/literals/stripChars.d.ts +2 -2
- package/dist/runtime/literals/stripChars.d.ts.map +1 -1
- package/dist/runtime/literals/stripChars.js +1 -1
- package/dist/runtime/literals/toKebabCase.d.ts.map +1 -1
- package/dist/runtime/literals/toKebabCase.js +1 -1
- package/dist/runtime/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/type-conversion/index.d.ts +1 -0
- package/dist/runtime/type-conversion/index.d.ts.map +1 -1
- package/dist/runtime/type-conversion/index.js +1 -0
- package/dist/runtime/type-conversion/stripParenthesis.d.ts +9 -0
- package/dist/runtime/type-conversion/stripParenthesis.d.ts.map +1 -0
- package/dist/runtime/type-conversion/stripParenthesis.js +10 -0
- package/dist/runtime/type-guards/date-time/index.d.ts +4 -0
- package/dist/runtime/type-guards/date-time/index.d.ts.map +1 -0
- package/dist/runtime/type-guards/date-time/index.js +3 -0
- package/dist/runtime/type-guards/date-time/isDateTime.d.ts +3 -0
- package/dist/runtime/type-guards/date-time/isDateTime.d.ts.map +1 -0
- package/dist/runtime/type-guards/date-time/isDateTime.js +4 -0
- package/dist/runtime/type-guards/date-time/isIsoDate.d.ts +23 -0
- package/dist/runtime/type-guards/date-time/isIsoDate.d.ts.map +1 -0
- package/dist/runtime/type-guards/date-time/isIsoDate.js +53 -0
- package/dist/runtime/type-guards/date-time/isIsoTime.d.ts +8 -0
- package/dist/runtime/type-guards/date-time/isIsoTime.d.ts.map +1 -0
- package/dist/runtime/type-guards/date-time/isIsoTime.js +25 -0
- package/dist/runtime/type-guards/index.d.ts +1 -0
- package/dist/runtime/type-guards/index.d.ts.map +1 -1
- package/dist/runtime/type-guards/index.js +1 -0
- package/dist/types/errors/KindError.d.ts +2 -2
- package/dist/types/errors/KindError.d.ts.map +1 -1
- package/dist/types/string-literals/DateTime.d.ts +59 -1
- package/dist/types/string-literals/DateTime.d.ts.map +1 -1
- package/dist/types/string-literals/casing/KebabCase.d.ts +7 -5
- package/dist/types/string-literals/casing/KebabCase.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/type-conversion/StripChars.d.ts +1 -1
- package/dist/types/type-conversion/StripChars.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -381,6 +381,13 @@ __export(inferred_types_exports, {
|
|
|
381
381
|
isIso3166Alpha3: () => isIso3166Alpha3,
|
|
382
382
|
isIso3166CountryCode: () => isIso3166CountryCode,
|
|
383
383
|
isIso3166CountryName: () => isIso3166CountryName,
|
|
384
|
+
isIsoDate: () => isIsoDate,
|
|
385
|
+
isIsoDateTime: () => isIsoDateTime,
|
|
386
|
+
isIsoExplicitDate: () => isIsoExplicitDate,
|
|
387
|
+
isIsoExplicitTime: () => isIsoExplicitTime,
|
|
388
|
+
isIsoImplicitDate: () => isIsoImplicitDate,
|
|
389
|
+
isIsoImplicitTime: () => isIsoImplicitTime,
|
|
390
|
+
isIsoTime: () => isIsoTime,
|
|
384
391
|
isItalianNewsUrl: () => isItalianNewsUrl,
|
|
385
392
|
isJapaneseNewsUrl: () => isJapaneseNewsUrl,
|
|
386
393
|
isKrogersUrl: () => isKrogersUrl,
|
|
@@ -557,6 +564,7 @@ __export(inferred_types_exports, {
|
|
|
557
564
|
stripBefore: () => stripBefore,
|
|
558
565
|
stripChars: () => stripChars,
|
|
559
566
|
stripLeading: () => stripLeading,
|
|
567
|
+
stripParenthesis: () => stripParenthesis,
|
|
560
568
|
stripSurround: () => stripSurround,
|
|
561
569
|
stripTrailing: () => stripTrailing,
|
|
562
570
|
stripUntil: () => stripUntil,
|
|
@@ -3889,6 +3897,11 @@ var jsonValues = (...val) => {
|
|
|
3889
3897
|
return val.map((i) => jsonValue(i));
|
|
3890
3898
|
};
|
|
3891
3899
|
|
|
3900
|
+
// src/runtime/type-conversion/stripParenthesis.ts
|
|
3901
|
+
var stripParenthesis = (val) => {
|
|
3902
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
3903
|
+
};
|
|
3904
|
+
|
|
3892
3905
|
// src/runtime/type-guards/hasWhitespace.ts
|
|
3893
3906
|
var hasWhiteSpace = (val) => {
|
|
3894
3907
|
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS.includes(c));
|
|
@@ -4603,6 +4616,59 @@ var isNewsUrl = (val) => {
|
|
|
4603
4616
|
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
4604
4617
|
};
|
|
4605
4618
|
|
|
4619
|
+
// src/runtime/type-guards/date-time/isDateTime.ts
|
|
4620
|
+
var isIsoDateTime = (val) => {
|
|
4621
|
+
return isString(val) && val.includes(":") && val.includes("-") && val.split("-").length === 3 && val.split(":").length > 1;
|
|
4622
|
+
};
|
|
4623
|
+
|
|
4624
|
+
// src/runtime/type-guards/date-time/isIsoTime.ts
|
|
4625
|
+
var isIsoExplicitTime = (val) => {
|
|
4626
|
+
if (isString(val)) {
|
|
4627
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
4628
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
4629
|
+
} else {
|
|
4630
|
+
return false;
|
|
4631
|
+
}
|
|
4632
|
+
};
|
|
4633
|
+
var isIsoImplicitTime = (val) => {
|
|
4634
|
+
if (isString(val)) {
|
|
4635
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
4636
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
4637
|
+
} else {
|
|
4638
|
+
return false;
|
|
4639
|
+
}
|
|
4640
|
+
};
|
|
4641
|
+
var isIsoTime = (val) => {
|
|
4642
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
4643
|
+
};
|
|
4644
|
+
|
|
4645
|
+
// src/runtime/type-guards/date-time/isIsoDate.ts
|
|
4646
|
+
var isIsoExplicitDate = (val) => {
|
|
4647
|
+
if (isString(val)) {
|
|
4648
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
4649
|
+
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
4650
|
+
} else {
|
|
4651
|
+
return false;
|
|
4652
|
+
}
|
|
4653
|
+
};
|
|
4654
|
+
var isIsoImplicitDate = (val) => {
|
|
4655
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
4656
|
+
const year = Number(val.slice(0, 4));
|
|
4657
|
+
const month = Number(val.slice(4, 6));
|
|
4658
|
+
const date = Number(val.slice(6, 8));
|
|
4659
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
4660
|
+
} else {
|
|
4661
|
+
return false;
|
|
4662
|
+
}
|
|
4663
|
+
};
|
|
4664
|
+
var isIsoDate = (val) => {
|
|
4665
|
+
if (isString(val)) {
|
|
4666
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
4667
|
+
} else {
|
|
4668
|
+
return false;
|
|
4669
|
+
}
|
|
4670
|
+
};
|
|
4671
|
+
|
|
4606
4672
|
// src/runtime/literals/stripTrailing.ts
|
|
4607
4673
|
function stripTrailing(content, ...strip) {
|
|
4608
4674
|
let output = String(content);
|
|
@@ -4714,7 +4780,7 @@ function toCamelCase(input, preserveWhitespace) {
|
|
|
4714
4780
|
}
|
|
4715
4781
|
|
|
4716
4782
|
// src/runtime/literals/toKebabCase.ts
|
|
4717
|
-
function toKebabCase(input, _preserveWhitespace) {
|
|
4783
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
4718
4784
|
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
4719
4785
|
const replaceWhitespace = (i) => i.replace(/\s/gs, "-");
|
|
4720
4786
|
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
@@ -4989,7 +5055,7 @@ function kindError(kind, baseContext = {}) {
|
|
|
4989
5055
|
file: i.file ? (0, import_pathe.relative)(process.cwd(), i.file) : void 0
|
|
4990
5056
|
}));
|
|
4991
5057
|
err.name = toPascalCase(kind);
|
|
4992
|
-
err.kind = toKebabCase(kind);
|
|
5058
|
+
err.kind = toKebabCase(stripChars(kind, "<", ">", "[", "]", "(", ")"));
|
|
4993
5059
|
err.file = stackTrace[0].file;
|
|
4994
5060
|
err.line = stackTrace[0].line;
|
|
4995
5061
|
err.col = stackTrace[0].col;
|
|
@@ -6060,6 +6126,13 @@ var asVueRef = (value) => ({
|
|
|
6060
6126
|
isIso3166Alpha3,
|
|
6061
6127
|
isIso3166CountryCode,
|
|
6062
6128
|
isIso3166CountryName,
|
|
6129
|
+
isIsoDate,
|
|
6130
|
+
isIsoDateTime,
|
|
6131
|
+
isIsoExplicitDate,
|
|
6132
|
+
isIsoExplicitTime,
|
|
6133
|
+
isIsoImplicitDate,
|
|
6134
|
+
isIsoImplicitTime,
|
|
6135
|
+
isIsoTime,
|
|
6063
6136
|
isItalianNewsUrl,
|
|
6064
6137
|
isJapaneseNewsUrl,
|
|
6065
6138
|
isKrogersUrl,
|
|
@@ -6236,6 +6309,7 @@ var asVueRef = (value) => ({
|
|
|
6236
6309
|
stripBefore,
|
|
6237
6310
|
stripChars,
|
|
6238
6311
|
stripLeading,
|
|
6312
|
+
stripParenthesis,
|
|
6239
6313
|
stripSurround,
|
|
6240
6314
|
stripTrailing,
|
|
6241
6315
|
stripUntil,
|
package/dist/index.js
CHANGED
|
@@ -3287,6 +3287,11 @@ var jsonValues = (...val) => {
|
|
|
3287
3287
|
return val.map((i) => jsonValue(i));
|
|
3288
3288
|
};
|
|
3289
3289
|
|
|
3290
|
+
// src/runtime/type-conversion/stripParenthesis.ts
|
|
3291
|
+
var stripParenthesis = (val) => {
|
|
3292
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
3293
|
+
};
|
|
3294
|
+
|
|
3290
3295
|
// src/runtime/type-guards/hasWhitespace.ts
|
|
3291
3296
|
var hasWhiteSpace = (val) => {
|
|
3292
3297
|
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS.includes(c));
|
|
@@ -4001,6 +4006,59 @@ var isNewsUrl = (val) => {
|
|
|
4001
4006
|
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
4002
4007
|
};
|
|
4003
4008
|
|
|
4009
|
+
// src/runtime/type-guards/date-time/isDateTime.ts
|
|
4010
|
+
var isIsoDateTime = (val) => {
|
|
4011
|
+
return isString(val) && val.includes(":") && val.includes("-") && val.split("-").length === 3 && val.split(":").length > 1;
|
|
4012
|
+
};
|
|
4013
|
+
|
|
4014
|
+
// src/runtime/type-guards/date-time/isIsoTime.ts
|
|
4015
|
+
var isIsoExplicitTime = (val) => {
|
|
4016
|
+
if (isString(val)) {
|
|
4017
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
4018
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
4019
|
+
} else {
|
|
4020
|
+
return false;
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
var isIsoImplicitTime = (val) => {
|
|
4024
|
+
if (isString(val)) {
|
|
4025
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
4026
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
4027
|
+
} else {
|
|
4028
|
+
return false;
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
4031
|
+
var isIsoTime = (val) => {
|
|
4032
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
4033
|
+
};
|
|
4034
|
+
|
|
4035
|
+
// src/runtime/type-guards/date-time/isIsoDate.ts
|
|
4036
|
+
var isIsoExplicitDate = (val) => {
|
|
4037
|
+
if (isString(val)) {
|
|
4038
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
4039
|
+
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
4040
|
+
} else {
|
|
4041
|
+
return false;
|
|
4042
|
+
}
|
|
4043
|
+
};
|
|
4044
|
+
var isIsoImplicitDate = (val) => {
|
|
4045
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
4046
|
+
const year = Number(val.slice(0, 4));
|
|
4047
|
+
const month = Number(val.slice(4, 6));
|
|
4048
|
+
const date = Number(val.slice(6, 8));
|
|
4049
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
4050
|
+
} else {
|
|
4051
|
+
return false;
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
var isIsoDate = (val) => {
|
|
4055
|
+
if (isString(val)) {
|
|
4056
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
4057
|
+
} else {
|
|
4058
|
+
return false;
|
|
4059
|
+
}
|
|
4060
|
+
};
|
|
4061
|
+
|
|
4004
4062
|
// src/runtime/literals/stripTrailing.ts
|
|
4005
4063
|
function stripTrailing(content, ...strip) {
|
|
4006
4064
|
let output = String(content);
|
|
@@ -4112,7 +4170,7 @@ function toCamelCase(input, preserveWhitespace) {
|
|
|
4112
4170
|
}
|
|
4113
4171
|
|
|
4114
4172
|
// src/runtime/literals/toKebabCase.ts
|
|
4115
|
-
function toKebabCase(input, _preserveWhitespace) {
|
|
4173
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
4116
4174
|
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
4117
4175
|
const replaceWhitespace = (i) => i.replace(/\s/gs, "-");
|
|
4118
4176
|
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
@@ -4387,7 +4445,7 @@ function kindError(kind, baseContext = {}) {
|
|
|
4387
4445
|
file: i.file ? relative(process.cwd(), i.file) : void 0
|
|
4388
4446
|
}));
|
|
4389
4447
|
err.name = toPascalCase(kind);
|
|
4390
|
-
err.kind = toKebabCase(kind);
|
|
4448
|
+
err.kind = toKebabCase(stripChars(kind, "<", ">", "[", "]", "(", ")"));
|
|
4391
4449
|
err.file = stackTrace[0].file;
|
|
4392
4450
|
err.line = stackTrace[0].line;
|
|
4393
4451
|
err.col = stackTrace[0].col;
|
|
@@ -5457,6 +5515,13 @@ export {
|
|
|
5457
5515
|
isIso3166Alpha3,
|
|
5458
5516
|
isIso3166CountryCode,
|
|
5459
5517
|
isIso3166CountryName,
|
|
5518
|
+
isIsoDate,
|
|
5519
|
+
isIsoDateTime,
|
|
5520
|
+
isIsoExplicitDate,
|
|
5521
|
+
isIsoExplicitTime,
|
|
5522
|
+
isIsoImplicitDate,
|
|
5523
|
+
isIsoImplicitTime,
|
|
5524
|
+
isIsoTime,
|
|
5460
5525
|
isItalianNewsUrl,
|
|
5461
5526
|
isJapaneseNewsUrl,
|
|
5462
5527
|
isKrogersUrl,
|
|
@@ -5633,6 +5698,7 @@ export {
|
|
|
5633
5698
|
stripBefore,
|
|
5634
5699
|
stripChars,
|
|
5635
5700
|
stripLeading,
|
|
5701
|
+
stripParenthesis,
|
|
5636
5702
|
stripSurround,
|
|
5637
5703
|
stripTrailing,
|
|
5638
5704
|
stripUntil,
|